Crates.io | cv-bridge |
lib.rs | cv-bridge |
version | 0.3.3 |
source | src |
created_at | 2022-12-18 09:42:47.542212 |
updated_at | 2023-02-11 17:58:12.049969 |
description | Rust implemenation of cv_bridge that converts between ROS image messages and OpenCV images |
homepage | |
repository | https://github.com/OmkarKabadagi5823/cv-bridge-rs.git |
max_upload_size | |
id | 740313 |
size | 100,856 |
Rust implemenation of cv_bridge that converts between ROS image messages and OpenCV images
Warning: This package is still under active development. Use at your own risk.
Add the following to your Cargo.toml file under dependencies:
[dependencies]
cv-bridge = "0.3.3"
or you can use cargo to add the dependency:
cargo add cv_bridge
use opencv::highgui;
use cv_bridge::{
CvImage,
msgs::sensor_msgs::Image,
};
fn main() {
// Initialize ros node
rosrust::init("image_viewer");
// Create image subscriber
let _subscriber_raii = rosrust::subscribe(
"/camera/image_raw",
5,
move |image: Image| {
// Convert ros Image to opencv Mat
let mut cv_image = CvImage::from_imgmsg(image).expect("failed to construct CvImage from ros Image");
let mat = cv_image.as_cvmat().expect("failed to convert CvImage to Mat");
// Display image
let window = "view";
highgui::named_window(window, highgui::WINDOW_AUTOSIZE).unwrap();
highgui::imshow(window, &mat).unwrap();
highgui::wait_key(1).unwrap();
}
);
rosrust::spin();
}