mirror of
https://github.com/RapidAI/RapidOCR.git
synced 2026-11-11 13:30:51 +08:00
feat: add C ABI, Python package, and CPU ISA paths
Expose the PP-OCRv6 engine through a stable C ABI and installable shared and static libraries, plus a ctypes Python package that follows the RapidOCR call shape. Keep AVX-512 out of the AVX2 object file and speed up GEMM accumulate and the AArch64 GEMM tile. Co-authored-by: Daniel <znsoft@163.com>
This commit is contained in:
32 files changed
+2653
-122
No files matched your search
@@ -0,0 +1,37 @@
|
||||
#include "ppocr/ppocr.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
const auto cpu = ppocr::QueryCpuInfo();
|
||||
if (argc == 2 && std::string(argv[1]) == "--cpu-info") {
|
||||
std::cout << "active_isa=" << cpu.active_isa
|
||||
<< " avx2=" << cpu.avx2
|
||||
<< " avx512=" << cpu.avx512
|
||||
<< " neon=" << cpu.neon
|
||||
<< " threads=" << cpu.threads << '\n';
|
||||
return 0;
|
||||
}
|
||||
if (argc != 5) {
|
||||
std::cerr << "usage: ppocr_cpp_api_demo DET.onnx REC.onnx dict.txt image.ppm\n";
|
||||
return 2;
|
||||
}
|
||||
try {
|
||||
ppocr::Options options;
|
||||
options.backend = ppocr::Backend::cpu_only;
|
||||
ppocr::OCR ocr(argv[1], argv[2], argv[3], options);
|
||||
const ppocr::Image image = ppocr::LoadPPM(argv[4]);
|
||||
const auto results = ocr.Recognize(image);
|
||||
std::cout << "isa=" << cpu.active_isa << " boxes=" << results.size() << '\n';
|
||||
for (const auto& result : results) {
|
||||
std::cout << result.text << '\t' << result.confidence << '\t'
|
||||
<< result.bbox[0] << ',' << result.bbox[1] << ','
|
||||
<< result.bbox[2] << ',' << result.bbox[3] << '\n';
|
||||
}
|
||||
} catch (const std::exception& ex) {
|
||||
std::cerr << "error: " << ex.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user