3 releases
| new 0.1.2 | Feb 4, 2026 |
|---|---|
| 0.1.1 | Jan 30, 2026 |
| 0.1.0 | Oct 6, 2023 |
#377 in Hardware support
6MB
1.5K
SLoC
RustCV đĻ
RustCV is a high-performance, native Rust computer vision library designed to be a modern alternative to OpenCV. By leveraging Rust's memory safety and zero-cost abstractions, we provide a seamless, "C++-dependency-free" experience for vision developers and robotics engineers.
đ Introduction
- OpenCV Parity: Provides familiar APIs such as
VideoCapture,Mat, andimshow, significantly reducing migration costs for developers coming from C++. - Hidden Complexity: The backend is powered by a Tokio-based asynchronous driver, while exposing a clean, synchronous blocking interface. You get the performance of async I/O without the boilerplate of
async/await. - Zero-Copy Design: Implements intelligent Buffer Swapping technology to achieve zero-copy data flow from kernel-space drivers directly to user-space
Matstructures.
⨠Key Features
-
đĻ Rust Native: Written entirely in Rust. Say goodbye to C++ shared library "dependency hell" and complex CMake configurations.
-
⥠High Performance:
-
Integrated Lazy Global Runtime for automatic management of asynchronous drivers.
-
Supports Stride memory layout, allowing direct mapping of hardware buffers.
-
đ¨ Out-of-the-box Functionality:
-
VideoIO: Native support for V4L2 (Linux); AVFoundation (macOS) is currently WIP.
-
HighGUI: Lightweight, cross-platform windowing based on
minifbfor real-time debugging. -
ImgProc: Built-in drawing primitives (rectangles, text) and real-time FPS calculation.
-
ImgCodecs: Integrated with
imagefor reading/writing all major image formats. -
đ ī¸ Strong-Typed Configuration: No more "magic numbers." Use ergonomic APIs like
cap.set_resolution(1280, 720).
đĨī¸ Platform Support
The project is currently in a rapid iteration phase, and platform support is as follows:
| Platform | Backend Technology | Status | Development Plan |
|---|---|---|---|
| Linux | V4L2 | đ Initial support, some core functions implemented | Full-scale development to complete full functionality adaptation and deployment. Currently supports MJPEG/YUYV decoding and hot reloading. |
| macOS | AVFoundation | đ§ Under development, core function adaptation in progress | Continuous development to complete full functionality support and compatibility verification. |
| Windows | MediaFoundation | đ Development not yet started, no available functions | Included in the development plan, adaptation will begin after the core functions of the preceding platforms are stable. |
đĻ Quick Start
Add RustCV to your Cargo.toml:
[dependencies]
rustcv = "0.1"
Basic Example: Camera Stream
use anyhow::Result;
use rustcv::prelude::*; // Import VideoCapture, Mat
use rustcv::highgui; // Import GUI
use rustcv::imgproc; // Import Drawing/Image Processing
fn main() -> Result<()> { (V4L2 on Linux)
// 1. Open the camera (index 0)
// The runtime is managed internally; no #[tokio::main] macro is required.
let mut cap = VideoCapture::new(0)?;
// 2. (Optional) Set resolution
cap.set_resolution(640, 480)?;
let mut frame = Mat::empty();
println!("đĨ Start capturing... Press ESC to exit.");
// 3. Main capture loop
while cap.read(&mut frame)? {
if frame.is_empty() { continue; }
// --- Image Processing ---
// Draw resolution info in the top-left corner
imgproc::put_text(
&mut frame,
&format!("Res: {}x{}", frame.cols, frame.rows),
imgproc::Point::new(10, 30),
1.0,
imgproc::Scalar::new(0, 0, 255) // Red
);
// Draw a green rectangle
imgproc::rectangle(
&mut frame,
imgproc::Rect::new(200, 200, 300, 300),
imgproc::Scalar::new(0, 255, 0), // Green
2
);
// Display window
highgui::imshow("RustCV Camera", &frame)?;
// Input Handling
if highgui::wait_key(1)? == 27 { // ESC
break;
}
}
Ok(())
}
Run
cargo run

đ¤ Contributing
We welcome all forms of contribution! Whether it's porting a new algorithm, improving documentation, or testing on new hardware.
- Fork the repository.
- Create your feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
Built with â¤ī¸ by the RustCV Community.
Dependencies
~20â30MB
~463K SLoC