[{"data":1,"prerenderedAt":594},["ShallowReactive",2],{"navigation_docs_en":3,"-en-how-to-use-python":173,"-en-how-to-use-python-surround":589},[4,30,109,153],{"title":5,"path":6,"stem":7,"children":8,"page":29},"Getting Started","\u002Fen\u002Fgetting-started","en\u002F01.getting-started",[9,14,19,24],{"title":10,"path":11,"stem":12,"icon":13},"Introduction","\u002Fen\u002Fgetting-started\u002Fintroduction","en\u002F01.getting-started\u002F1.introduction","i-ph-rocket",{"title":15,"path":16,"stem":17,"icon":18},"Installation","\u002Fen\u002Fgetting-started\u002Finstallation","en\u002F01.getting-started\u002F2.installation","i-ph-download",{"title":20,"path":21,"stem":22,"icon":23},"Quick Start","\u002Fen\u002Fgetting-started\u002Fquick-start","en\u002F01.getting-started\u002F3.quick-start","i-ph-play",{"title":25,"path":26,"stem":27,"icon":28},"Live Demo","\u002Fen\u002Fgetting-started\u002Flive-demo","en\u002F01.getting-started\u002F4.live-demo","i-ph-sparkle",false,{"title":31,"path":32,"stem":33,"children":34,"page":29},"How To","\u002Fen\u002Fhow-to","en\u002F02.how-to",[35,40,45,50,55,60,65,70,75,79,84,89,94,99,104],{"title":36,"path":37,"stem":38,"icon":39},"Use Rust","\u002Fen\u002Fhow-to\u002Fuse-rust","en\u002F02.how-to\u002F00.use-rust","simple-icons-rust",{"title":41,"path":42,"stem":43,"icon":44},"Use .NET \u002F C#","\u002Fen\u002Fhow-to\u002Fuse-csharp","en\u002F02.how-to\u002F01.use-csharp","simple-icons-dotnet",{"title":46,"path":47,"stem":48,"icon":49},"Use React Native","\u002Fen\u002Fhow-to\u002Fuse-react-native","en\u002F02.how-to\u002F02.use-react-native","simple-icons-react",{"title":51,"path":52,"stem":53,"icon":54},"Use iOS (Swift)","\u002Fen\u002Fhow-to\u002Fuse-ios-swift","en\u002F02.how-to\u002F03.use-ios-swift","simple-icons-apple",{"title":56,"path":57,"stem":58,"icon":59},"Use Android (Kotlin)","\u002Fen\u002Fhow-to\u002Fuse-android-kotlin","en\u002F02.how-to\u002F04.use-android-kotlin","simple-icons-android",{"title":61,"path":62,"stem":63,"icon":64},"Use C FFI","\u002Fen\u002Fhow-to\u002Fuse-c-ffi","en\u002F02.how-to\u002F05.use-c-ffi","simple-icons-c",{"title":66,"path":67,"stem":68,"icon":69},"Use CLI","\u002Fen\u002Fhow-to\u002Fuse-cli","en\u002F02.how-to\u002F06.use-cli","simple-icons-gnubash",{"title":71,"path":72,"stem":73,"icon":74},"Use Web","\u002Fen\u002Fhow-to\u002Fuse-web","en\u002F02.how-to\u002F07.use-web","simple-icons-javascript",{"title":76,"path":77,"stem":78,"icon":49},"Use React","\u002Fen\u002Fhow-to\u002Fuse-react","en\u002F02.how-to\u002F08.use-react",{"title":80,"path":81,"stem":82,"icon":83},"Use Node.js","\u002Fen\u002Fhow-to\u002Fuse-node","en\u002F02.how-to\u002F09.use-node","simple-icons-nodedotjs",{"title":85,"path":86,"stem":87,"icon":88},"Use Python","\u002Fen\u002Fhow-to\u002Fuse-python","en\u002F02.how-to\u002F10.use-python","simple-icons-python",{"title":90,"path":91,"stem":92,"icon":93},"Use Golang","\u002Fen\u002Fhow-to\u002Fuse-golang","en\u002F02.how-to\u002F11.use-golang","simple-icons-go",{"title":95,"path":96,"stem":97,"icon":98},"Use Java & JVM","\u002Fen\u002Fhow-to\u002Fuse-java","en\u002F02.how-to\u002F12.use-java","simple-icons-openjdk",{"title":100,"path":101,"stem":102,"icon":103},"Use Flutter & Dart","\u002Fen\u002Fhow-to\u002Fuse-flutter","en\u002F02.how-to\u002F13.use-flutter","simple-icons-flutter",{"title":105,"path":106,"stem":107,"icon":108},"Use Decoded RGB Input","\u002Fen\u002Fhow-to\u002Fuse-decoded-rgb","en\u002F02.how-to\u002F14.use-decoded-rgb","lucide-image",{"title":110,"path":111,"stem":112,"children":113,"page":29},"Advance Guide","\u002Fen\u002Fadvance-guide","en\u002F03.advance-guide",[114,119,124,129,134,139,144,149],{"title":115,"path":116,"stem":117,"icon":118},"Models & Tiers","\u002Fen\u002Fadvance-guide\u002Fmodels-and-tiers","en\u002F03.advance-guide\u002F01.models-and-tiers","i-ph-cube",{"title":120,"path":121,"stem":122,"icon":123},"Multilingual OCR","\u002Fen\u002Fadvance-guide\u002Fmultilingual-ocr","en\u002F03.advance-guide\u002F02.multilingual-ocr","i-ph-translate",{"title":125,"path":126,"stem":127,"icon":128},"Spatial Layout Reconstruction","\u002Fen\u002Fadvance-guide\u002Fspatial-layout-reconstruction","en\u002F03.advance-guide\u002F03.spatial-layout-reconstruction","i-ph-layout",{"title":130,"path":131,"stem":132,"icon":133},"Image Preprocessing & Tuning","\u002Fen\u002Fadvance-guide\u002Fimage-preprocessing-and-tuning","en\u002F03.advance-guide\u002F04.image-preprocessing-and-tuning","i-ph-sliders",{"title":135,"path":136,"stem":137,"icon":138},"Classification & Orientation","\u002Fen\u002Fadvance-guide\u002Fclassification-and-orientation","en\u002F03.advance-guide\u002F05.classification-and-orientation","i-ph-arrows-clockwise",{"title":140,"path":141,"stem":142,"icon":143},"Performance & Benchmarks","\u002Fen\u002Fadvance-guide\u002Fperformance-and-benchmarks","en\u002F03.advance-guide\u002F06.performance-and-benchmarks","i-ph-chart-line-up",{"title":145,"path":146,"stem":147,"icon":148},"Troubleshooting","\u002Fen\u002Fadvance-guide\u002Ftroubleshooting","en\u002F03.advance-guide\u002F07.troubleshooting","i-ph-wrench",{"title":150,"path":151,"stem":152,"icon":138},"v0.2 to v0.3","\u002Fen\u002Fadvance-guide\u002Fmigration-guide","en\u002F03.advance-guide\u002F08.migration-guide",{"title":154,"path":155,"stem":156,"children":157,"page":29},"Api Reference","\u002Fen\u002Fapi-reference","en\u002F04.api-reference",[158,163,168],{"title":159,"path":160,"stem":161,"icon":162},"InitializeConfig","\u002Fen\u002Fapi-reference\u002Finitialize-config","en\u002F04.api-reference\u002F01.initialize-config","i-ph-code-block",{"title":164,"path":165,"stem":166,"icon":167},"OcrRunOptions","\u002Fen\u002Fapi-reference\u002Focr-run-options","en\u002F04.api-reference\u002F02.ocr-run-options","i-ph-faders",{"title":169,"path":170,"stem":171,"icon":172},"TextResult & Output Modes","\u002Fen\u002Fapi-reference\u002Ftext-result-and-output","en\u002F04.api-reference\u002F03.text-result-and-output","i-ph-textbox",{"id":174,"title":85,"body":175,"description":581,"extension":582,"links":583,"meta":584,"navigation":585,"path":86,"seo":586,"stem":87,"__hash__":588},"docs_en\u002Fen\u002F02.how-to\u002F10.use-python.md",{"type":176,"value":177,"toc":571},"minimark",[178,195,199,224,227,231,234,330,333,387,389,393,406,473,477,501,503,507,510,567],[179,180,181,182,186,187,194],"p",{},"The ",[183,184,185],"code",{},"rusto"," Python package provides high-performance bindings powered by Mozilla's ",[188,189,193],"a",{"href":190,"rel":191},"https:\u002F\u002Fmozilla.github.io\u002Funiffi-rs\u002F",[192],"nofollow","UniFFI",", allowing Python applications to run pure-Rust OCR with native C-speed and zero Python GIL contention during inference.",[196,197,15],"h2",{"id":198},"installation",[200,201,206],"pre",{"className":202,"code":203,"language":204,"meta":205,"style":205},"language-bash shiki shiki-themes material-theme-lighter github-light github-dark monokai","pip install rusto\n","bash","",[183,207,208],{"__ignoreMap":205},[209,210,213,217,221],"span",{"class":211,"line":212},"line",1,[209,214,216],{"class":215},"sR7ES","pip",[209,218,220],{"class":219},"sLACW"," install",[209,222,223],{"class":219}," rusto\n",[225,226],"hr",{},[196,228,230],{"id":229},"_1-engine-initialization","1. Engine Initialization",[179,232,233],{},"Initialize the engine using template presets or custom JSON configurations:",[200,235,239],{"className":236,"code":237,"language":238,"meta":205,"style":205},"language-python shiki shiki-themes material-theme-lighter github-light github-dark monokai","from rusto import (\n    RustO,\n    InitializeConfig,\n    OcrRunOptions,\n    ImageSource,\n    OutputGranularity,\n)\n\n# Initialize with PP-OCRv6 preset\nconfig = InitializeConfig.ppv6(\n    det=\"models\u002FPPOCR_v6\u002Fdet.rten\",\n    rec=\"models\u002FPPOCR_v6\u002Frec.rten\",\n    dict=\"models\u002FPPOCR_v6\u002Fdict.txt\"\n)\nengine = RustO.initialize(config)\n","python",[183,240,241,246,252,258,264,270,276,282,289,295,301,307,313,319,324],{"__ignoreMap":205},[209,242,243],{"class":211,"line":212},[209,244,245],{},"from rusto import (\n",[209,247,249],{"class":211,"line":248},2,[209,250,251],{},"    RustO,\n",[209,253,255],{"class":211,"line":254},3,[209,256,257],{},"    InitializeConfig,\n",[209,259,261],{"class":211,"line":260},4,[209,262,263],{},"    OcrRunOptions,\n",[209,265,267],{"class":211,"line":266},5,[209,268,269],{},"    ImageSource,\n",[209,271,273],{"class":211,"line":272},6,[209,274,275],{},"    OutputGranularity,\n",[209,277,279],{"class":211,"line":278},7,[209,280,281],{},")\n",[209,283,285],{"class":211,"line":284},8,[209,286,288],{"emptyLinePlaceholder":287},true,"\n",[209,290,292],{"class":211,"line":291},9,[209,293,294],{},"# Initialize with PP-OCRv6 preset\n",[209,296,298],{"class":211,"line":297},10,[209,299,300],{},"config = InitializeConfig.ppv6(\n",[209,302,304],{"class":211,"line":303},11,[209,305,306],{},"    det=\"models\u002FPPOCR_v6\u002Fdet.rten\",\n",[209,308,310],{"class":211,"line":309},12,[209,311,312],{},"    rec=\"models\u002FPPOCR_v6\u002Frec.rten\",\n",[209,314,316],{"class":211,"line":315},13,[209,317,318],{},"    dict=\"models\u002FPPOCR_v6\u002Fdict.txt\"\n",[209,320,322],{"class":211,"line":321},14,[209,323,281],{},[209,325,327],{"class":211,"line":326},15,[209,328,329],{},"engine = RustO.initialize(config)\n",[179,331,332],{},"Alternatively, initialize directly from a JSON string:",[200,334,336],{"className":236,"code":335,"language":238,"meta":205,"style":205},"import json\n\nconfig_json = json.dumps({\n    \"detection\": {\"model_path\": \"models\u002FPPOCR_v6\u002Fdet.rten\"},\n    \"recognition\": {\n        \"model_path\": \"models\u002FPPOCR_v6\u002Frec.rten\",\n        \"dict_path\": \"models\u002FPPOCR_v6\u002Fdict.txt\"\n    }\n})\nengine = RustO.initialize_from_json(config_json)\n",[183,337,338,343,347,352,357,362,367,372,377,382],{"__ignoreMap":205},[209,339,340],{"class":211,"line":212},[209,341,342],{},"import json\n",[209,344,345],{"class":211,"line":248},[209,346,288],{"emptyLinePlaceholder":287},[209,348,349],{"class":211,"line":254},[209,350,351],{},"config_json = json.dumps({\n",[209,353,354],{"class":211,"line":260},[209,355,356],{},"    \"detection\": {\"model_path\": \"models\u002FPPOCR_v6\u002Fdet.rten\"},\n",[209,358,359],{"class":211,"line":266},[209,360,361],{},"    \"recognition\": {\n",[209,363,364],{"class":211,"line":272},[209,365,366],{},"        \"model_path\": \"models\u002FPPOCR_v6\u002Frec.rten\",\n",[209,368,369],{"class":211,"line":278},[209,370,371],{},"        \"dict_path\": \"models\u002FPPOCR_v6\u002Fdict.txt\"\n",[209,373,374],{"class":211,"line":284},[209,375,376],{},"    }\n",[209,378,379],{"class":211,"line":291},[209,380,381],{},"})\n",[209,383,384],{"class":211,"line":297},[209,385,386],{},"engine = RustO.initialize_from_json(config_json)\n",[225,388],{},[196,390,392],{"id":391},"_2-text-recognition","2. Text Recognition",[394,395,397,398,401,402,405],"h3",{"id":396},"structured-output-lines-or-words","Structured Output (",[183,399,400],{},"lines"," or ",[183,403,404],{},"words",")",[200,407,409],{"className":236,"code":408,"language":238,"meta":205,"style":205},"# Configure OCR options\noptions = OcrRunOptions(\n    output=OutputGranularity.LINES,\n    text_score=0.5\n)\n\n# Run recognition on an image file\nresult = engine.detect_text(ImageSource.PATH(\"receipt.jpg\"), options)\n\nif result.is_STRUCTURED():\n    for item in result.results:\n        print(f\"[{item.score:.2f}] {item.text}\")\n        print(f\"  Frame: left={item.frame.left}, top={item.frame.top}, w={item.frame.width}, h={item.frame.height}\")\n",[183,410,411,416,421,426,431,435,439,444,449,453,458,463,468],{"__ignoreMap":205},[209,412,413],{"class":211,"line":212},[209,414,415],{},"# Configure OCR options\n",[209,417,418],{"class":211,"line":248},[209,419,420],{},"options = OcrRunOptions(\n",[209,422,423],{"class":211,"line":254},[209,424,425],{},"    output=OutputGranularity.LINES,\n",[209,427,428],{"class":211,"line":260},[209,429,430],{},"    text_score=0.5\n",[209,432,433],{"class":211,"line":266},[209,434,281],{},[209,436,437],{"class":211,"line":272},[209,438,288],{"emptyLinePlaceholder":287},[209,440,441],{"class":211,"line":278},[209,442,443],{},"# Run recognition on an image file\n",[209,445,446],{"class":211,"line":284},[209,447,448],{},"result = engine.detect_text(ImageSource.PATH(\"receipt.jpg\"), options)\n",[209,450,451],{"class":211,"line":291},[209,452,288],{"emptyLinePlaceholder":287},[209,454,455],{"class":211,"line":297},[209,456,457],{},"if result.is_STRUCTURED():\n",[209,459,460],{"class":211,"line":303},[209,461,462],{},"    for item in result.results:\n",[209,464,465],{"class":211,"line":309},[209,466,467],{},"        print(f\"[{item.score:.2f}] {item.text}\")\n",[209,469,470],{"class":211,"line":315},[209,471,472],{},"        print(f\"  Frame: left={item.frame.left}, top={item.frame.top}, w={item.frame.width}, h={item.frame.height}\")\n",[394,474,476],{"id":475},"from-in-memory-bytes","From In-Memory Bytes",[200,478,480],{"className":236,"code":479,"language":238,"meta":205,"style":205},"with open(\"invoice.png\", \"rb\") as f:\n    image_bytes = f.read()\n\nresult = engine.detect_text(ImageSource.BYTES(image_bytes), OcrRunOptions())\n",[183,481,482,487,492,496],{"__ignoreMap":205},[209,483,484],{"class":211,"line":212},[209,485,486],{},"with open(\"invoice.png\", \"rb\") as f:\n",[209,488,489],{"class":211,"line":248},[209,490,491],{},"    image_bytes = f.read()\n",[209,493,494],{"class":211,"line":254},[209,495,288],{"emptyLinePlaceholder":287},[209,497,498],{"class":211,"line":260},[209,499,500],{},"result = engine.detect_text(ImageSource.BYTES(image_bytes), OcrRunOptions())\n",[225,502],{},[196,504,506],{"id":505},"_3-spatial-layout-reconstruction","3. Spatial Layout Reconstruction",[179,508,509],{},"To preserve invoices, tabular layouts, or multi-column documents:",[200,511,513],{"className":236,"code":512,"language":238,"meta":205,"style":205},"spatial_options = OcrRunOptions(\n    output=OutputGranularity.SPATIAL,\n    line_y_threshold=0.5,\n    word_x_threshold=0.4\n)\n\nresult = engine.detect_text(ImageSource.PATH(\"invoice.png\"), spatial_options)\n\nif result.is_SPATIAL():\n    print(\"--- Reconstructed Spatial Document ---\")\n    print(result.text)\n",[183,514,515,520,525,530,535,539,543,548,552,557,562],{"__ignoreMap":205},[209,516,517],{"class":211,"line":212},[209,518,519],{},"spatial_options = OcrRunOptions(\n",[209,521,522],{"class":211,"line":248},[209,523,524],{},"    output=OutputGranularity.SPATIAL,\n",[209,526,527],{"class":211,"line":254},[209,528,529],{},"    line_y_threshold=0.5,\n",[209,531,532],{"class":211,"line":260},[209,533,534],{},"    word_x_threshold=0.4\n",[209,536,537],{"class":211,"line":266},[209,538,281],{},[209,540,541],{"class":211,"line":272},[209,542,288],{"emptyLinePlaceholder":287},[209,544,545],{"class":211,"line":278},[209,546,547],{},"result = engine.detect_text(ImageSource.PATH(\"invoice.png\"), spatial_options)\n",[209,549,550],{"class":211,"line":284},[209,551,288],{"emptyLinePlaceholder":287},[209,553,554],{"class":211,"line":291},[209,555,556],{},"if result.is_SPATIAL():\n",[209,558,559],{"class":211,"line":297},[209,560,561],{},"    print(\"--- Reconstructed Spatial Document ---\")\n",[209,563,564],{"class":211,"line":303},[209,565,566],{},"    print(result.text)\n",[568,569,570],"style",{},"html pre.shiki code .sR7ES, html code.shiki .sR7ES{--shiki-light:#E2931D;--shiki-default:#6F42C1;--shiki-dark:#B392F0;--shiki-sepia:#A6E22E}html pre.shiki code .sLACW, html code.shiki .sLACW{--shiki-light:#91B859;--shiki-default:#032F62;--shiki-dark:#9ECBFF;--shiki-sepia:#E6DB74}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .sepia .shiki span {color: var(--shiki-sepia);background: var(--shiki-sepia-bg);font-style: var(--shiki-sepia-font-style);font-weight: var(--shiki-sepia-font-weight);text-decoration: var(--shiki-sepia-text-decoration);}html.sepia .shiki span {color: var(--shiki-sepia);background: var(--shiki-sepia-bg);font-style: var(--shiki-sepia-font-style);font-weight: var(--shiki-sepia-font-weight);text-decoration: var(--shiki-sepia-text-decoration);}",{"title":205,"searchDepth":248,"depth":248,"links":572},[573,574,575,580],{"id":198,"depth":248,"text":15},{"id":229,"depth":248,"text":230},{"id":391,"depth":248,"text":392,"children":576},[577,579],{"id":396,"depth":254,"text":578},"Structured Output (lines or words)",{"id":475,"depth":254,"text":476},{"id":505,"depth":248,"text":506},"Using the native UniFFI-powered RustO! OCR library in Python.","md",null,{},{"icon":88},{"title":587,"description":581},"Use Python - RustO!","ACWlcZV44fzzhDLDs6N0WdK_nCQR-j0BKizcDWvuy58",[590,592],{"title":80,"path":81,"stem":82,"description":591,"icon":83,"children":-1},"Using the native RustO! N-API addon in Node.js server and desktop applications.",{"title":90,"path":91,"stem":92,"description":593,"icon":93,"children":-1},"Using RustO! pure-Rust OCR engine in Go applications via Cgo.",1792905888905]