[rapidocr] Add new port - #53217
Conversation
|
Drafted due to build failures. GPT 5.6 Sol says:
There are also a lot of vendored dependencies here that likely need to be extracted. Please also make sure you have filled out the "New Port Checklist" we have because it helps people resolve things we're looking for vcpkg/.github/pull_request_template.md Lines 19 to 35 in 2682618 |
|
Thanks for the review — all four points are addressed in d0fba47, and CI is now green on every leg. ONNX Runtime include root. The portfile now rewrites the upstream include to vcpkg's installed public layout rather than trying to reconstruct a compatible root: string(REPLACE "onnxruntime/core/session/onnxruntime_cxx_api.h"
"onnxruntime/onnxruntime_cxx_api.h" contents "${contents}")
Licensing. With the CLI gone, file(REMOVE "${SOURCE_PATH}/include/clipper.hpp" "${SOURCE_PATH}/src/clipper.cpp")
string(REPLACE "\"clipper.hpp\"" "<polyclipping/clipper.hpp>" contents "${contents}")
OpenCV under On the vendored dependencies more generally: Clipper was the only vendored library still compiled into the target, and it is now an external port dependency. The remaining vendored pieces ( The New Port Checklist in the description is filled out, including the licensing rationale above. |
|
I normally try to avoid posting verbatim what the LLM says but in this case I don't have anything to add:
It might be a good idea to add a test port. |
|
Sorry more useful content:
|
That is not what the checklist says.
|
- OcrLiteCApi.h selected dllexport/dllimport from __CLIB__, which a consumer of the installed headers cannot define, so it saw dllimport and required __imp_Ocr*. Strip the storage class; a static-only port should not present __declspec to consumers. __CLIB__ stays defined for the build because it also gates the whole body of src/OcrLiteCApi.cpp. - DbNet/CrnnNet/AngleNet left Ort::Session* indeterminate until initModel() and deleted it unconditionally in their destructors, so destroying a default-constructed OcrLite faulted. Add fix-uninitialized-session.patch. - usage now separates the dictionary the port installs from the ONNX weights that are not redistributed, and documents that the C API is consumable from the triplet include root while the C++ API needs the CMake target because it exposes OpenCV types. - Drop stale comments in the port CMake.
|
Thanks for testing this properly — the artifacts made the failures easy to reproduce. C API linkage — fixedThe header keys its storage class off string(REPLACE "#define _QM_OCR_API __declspec(dllexport)" "#define _QM_OCR_API" contents "${contents}")
string(REPLACE "#define _QM_OCR_API __declspec(dllimport)" "#define _QM_OCR_API" contents "${contents}")
Verified on
|
Exercise the CMake C++ target (default-construct/destroy OcrLite), the C API through the same target, and compile OcrLiteCApi.h with only the triplet include root.
|
Two follow-ups from the last review: Direct C++ include root / OpenCVI still do not think this port can make What the port does instead, and what
If C++ root-include is a hard requirement, please say so and I will go the opaque-interface route. Otherwise I would like to leave the C++ surface as upstream defined it. Test portAdded
Cross-builds compile only; native triplets also execute the two binaries in rel and dbg. |
x64-windows-static Debug failed LNK2019 on cudaMalloc because CI opencv4[cuda] leaves CUDA objects inside static opencv_core without INTERFACE-linking cudart. Link CUDA::cudart from the test port when CUDAToolkit is present. Stop calling OcrInit on missing model paths; that abort is not a supported entry and crashed the native run step on arm64-osx. Taking addresses is enough to prove the C API is in the static library.
|
The x64-windows-static Debug died at CI's overlay arm64-osx compiled, then Pushed
The C++ run step still default-constructs/destroys |

Description
Adds a new port rapidocr — a C++ OCR pipeline built on ONNX Runtime,
packaging RapidAI/RapidOcrOnnx
v1.2.3 (PaddleOCR-style text detection, angle classification, and
recognition).
The upstream CMake expects pre-vendored static OpenCV and ONNX Runtime trees,
so the port supplies a small CMake build that uses vcpkg packages and exports
unofficial::rapidocr::rapidocr.Review fixes, first round
opencv2/...includes work.polyclippingport.usage.Review fixes, second round
OcrLiteCApi.hselecteddllexport/dllimportfrom__CLIB__, which a consumer of the installed headers cannot define, so it sawdllimportand required__imp_Ocr*. The portfile now strips the storageclass, which is correct for a static-only port.
__CLIB__remains defined forthe build because it also gates the whole body of
src/OcrLiteCApi.cpp.DbNet,CrnnNetandAngleNetleftOrt::Session*indeterminate untilinitModel()and deleted itunconditionally in their destructors, so destroying a default-constructed
OcrLitefaulted. Fixed byfix-uninitialized-session.patch.usage. Now separates the dictionary the port installs from the threeONNX weights that are not redistributed, and documents which of the two
installed interfaces suits which integration.
Direct root-include consumption of the C++ API is not achievable while it
exposes OpenCV types:
include/opencv4/opencv2/core.hppincludesopencv2/core/cvdef.h, which exists only underinclude/opencv4, so anyconsumer of an OpenCV header needs that directory regardless of this port. The
C API has no
#includedirectives at all and does compile from the tripletinclude root alone;
usagestates this.New port checklist
Owner-Projectform.vcpkg.json, or explicitly disabled through patches or build system arguments such as CMAKE_DISABLE_FIND_PACKAGE_Xxx or VCPKG_LOCK_FIND_PACKAGEvcpkg.jsonmatches what upstream says.vcpkg.jsonmatches what upstream says../vcpkg x-add-version --alland committing the result.Screenshot for the web-search criterion, as supplied in review: