// the find
twistedfall/opencv-rust
Rust bindings for OpenCV
Rust bindings for OpenCV, covering nearly the full C++ API surface across computer vision, image processing, DNN, and more. Generated via libclang parsing of OpenCV headers, so the binding coverage stays relatively current without manual maintenance. For anyone doing serious CV work in Rust, this is the only real option.
Binding generation via libclang is the right call — it tracks OpenCV header changes without someone having to manually update thousands of signatures. Feature flags per OpenCV module let you link only what you need, which matters when OpenCV's full static link is several hundred MB. The C++ operator-to-method mapping ([], +, *, () etc.) is thoughtfully named rather than just wrapping unsafe pointers. CI covers Linux, macOS (brew and framework), and Windows (Chocolatey and vcpkg), which is non-trivial to maintain for a C++ FFI crate.
The README admits Mat is reference-counted under the hood but presents a value-type API — you can alias mutable state across two 'separate' Mats with no compiler error, which is exactly the class of bug Rust is supposed to prevent. Callbacks leak unconditionally and Drop is never called on them, which is a memory leak by design with no workaround. Build setup is genuinely painful: you need the right OpenCV version, Clang/LLVM, and often several env vars just to get cargo build to succeed, making onboarding slow. Overloaded methods fall back to _1/_2 suffixes when no better name was found, so you end up calling things like resize_1 and have to cross-reference C++ docs to know which overload you actually want.