Hysen Labs
Open-source project
lets-mica/mica-ppocr avatar
lets-mica

mica-ppocr

PP-OCRv6 离线纯 Java 图片识别!

85 stars20 forksJavaApache-2.0
DEEP OPEN-SOURCE ANALYSIS

mica-ppocr runs PP-OCRv6 OCR in pure Java

mica-ppocr is a Java implementation of PP-OCRv6 text detection and recognition using ONNX Runtime, with no PaddlePaddle dependency.

What it implements

mica-ppocr is a Java implementation of PP-OCRv6 text detection and recognition built on pure ONNX Runtime inference. The key claim is zero PaddlePaddle dependency, so you can run OCR inside a Java service without pulling in the Python framework. The project reproduces the preprocessing and postprocessing of the reference pipeline, including DB postprocessing, CTC decoding, and a pyclipper-equivalent polygon unclip done with the JTS library. It also ships a document orientation classification model that corrects the whole image before detection, supporting four classes at 0, 90, 180, and 270 degrees so that upside-down or sideways scans still recognize correctly. The README states the code is ported from the ppocrv6_onnx.py single-file reference by AIwork4me and stays bit-exact with the Python version when run on CPU with a single thread. For teams already on the JVM, that means matching known OCR behavior without standing up a separate Python process. The structured module adds parsers for common documents, so the output is not just raw text but a typed result. The author also notes the preprocessing and postprocessing are reproduced in full, which is what lets the Java port keep parity with the reference instead of approximating it. That fidelity is the reason a Java team would pick this over a looser reimplementation.

Environment and models

The environment table lists what you need. JDK 8 or above is required. ONNX Runtime is pinned at 1.18.0 because the bundled native libraries work across more operating system versions. OpenCV is listed at 4.10.0-0 and includes Windows, Linux, and macOS native libraries. JTS at 1.20.0 handles polygon offset, the pyclipper equivalent. Models are downloaded from the official PP-OCRv6 ONNX release and placed under models/ppocr-v6 by tier. Three tiers are offered. The tiny tier uses 1.7 MB for detection and 4.3 MB for recognition with about 2855 characters, favoring speed over accuracy. The small tier uses 9.4 MB and 20.2 MB and is the recommended default for balanced speed and accuracy. The medium tier uses 59.2 MB and 73.0 MB with about 7180 characters for higher accuracy and broader character coverage. An optional document orientation model of 6.47 MB can be added as well. The README notes the medium tier detection and recognition models ship as onnx.zip and must be unzipped before use, a small but easy-to-miss step. The character counts, about 2855 for tiny and small and about 7180 for medium, tell you which tier covers the symbols your documents actually contain, which is the practical way to choose between them.

How to run it

The quick start says to prepare the models first, then pick an entry point. For Spring Boot you can call the engine directly from a controller. For local debugging each parser ships an XxxMain class you run as a plain main method to do OCR plus structured parsing. The structured module, mica-ppocr-structured, provides parsers for documents and exposes results through a BaseStructuredResult shape. The core engine, mica-ppocr-core, lists public methods and a full example, and the PPOcrV6Config object lets you tune behavior such as whether document orientation classification runs. The README walks through the core public methods, a complete example, and the config knobs in dedicated sections. Modules are published to Maven Central under the net.dreamlu group, so adding the dependency is a normal build step. For Java shops that need offline OCR, mica-ppocr keeps the whole pipeline, including preprocessing and postprocessing, inside the JVM. The structured parsers mean you can go from an image of a license or a form straight to typed fields rather than parsing raw text by hand. That end-to-end path, from camera image to structured record, is what makes the library useful in a real backend instead of only as a research port. The maintainers publish each module separately so you can take only what you need.

Editorial conclusion

mica-ppocr is published under the Apache-2.0 license and requires JDK 8 or newer with ONNX Runtime 1.18.0.

DEEP OPEN-SOURCE ANALYSIS

Official sources

Community notes

Community notes