twistedfall/opencv-rust

Rust bindings for OpenCV

What it solves

This project provides Rust bindings for OpenCV, the widely used computer vision library. It allows developers to use OpenCV's extensive image processing and computer vision capabilities within the Rust programming language, bridging the gap between the C++ implementation of OpenCV and Rust's ecosystem.

How it works

The crate uses libclang to parse OpenCV's C++ headers, generates a C interface to the C++ API, and then wraps that C interface in Rust. To keep build times low for users, the generated Rust code is committed directly to the repository rather than being generated during every user's build process. It maps the C++ cv:: namespace into separate Rust modules corresponding to the major OpenCV modules (e.g., opencv::core::Mat).

Who it’s for

It is designed for Rust developers who need to perform computer vision tasks—such as image manipulation, object detection, or feature extraction—using the industry-standard OpenCV library.

Highlights

  • Broad Version Support: Supports OpenCV 4.x and 5.x, with deprecated support for 3.4.
  • Cross-Platform: Works on Linux, macOS, and Windows.
  • Modular Design: Includes features named after OpenCV modules (e.g., imgproc, highgui), allowing users to enable only what they need.
  • C++ Operator Mapping: Converts C++ operators (like +, -, *) into corresponding Rust functions (like add(), sub(), mul()).
  • Integration: Provides integration with the rgb and half (f16) crates.

Related

  • Project
  • Project
  • Project
  • Project
  • Project