twistedfall/opencv-rust

OpenCV API bindings for Rust

What it solves

This project provides Rust bindings for OpenCV, allowing developers to use the powerful C++ computer vision library within the Rust programming language. It bridges the gap between OpenCV's extensive vision capabilities and Rust's modern systems programming environment.

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. It organizes the API by creating a Rust module for each major OpenCV module (e.g., opencv::core::Mat instead of the C++ cv::Mat). To make the API more ergonomic, it converts C++ method and field names to snake_case and provides convenience functions for type handling.

Who it’s for

It is designed for Rust developers who need to integrate computer vision functionality into their applications without having to write C++ code directly.

Highlights

  • Broad Version Support: Supports OpenCV 4.x and 5.x, with deprecated support for 3.4.
  • Modular Design: Features are enabled by module name (e.g., imgproc, highgui), allowing users to customize their dependency footprint.
  • Cross-Platform: Works on Linux, macOS, and Windows.
  • C++ Operator Mapping: Maps common C++ operators (like +, -, *, /) to corresponding Rust functions (like add(), sub(), mul(), div()).
  • Automated Documentation: API documentation is automatically translated from OpenCV's doxygen docs.

Related

  • Project
  • Project
  • Project
  • Project
  • Project