ROS 订阅RealsenseD435图像与opencv保存32位深度图像

一,通过ros订阅realsense图像

int main(int argc, char **argv)
{
    ros::init(argc, argv, "image_listener");
    ros::NodeHandle nh;
    cv::namedWindow("view");
    cv::startWindowThread();
    message_filters::Subscriber image_sub(nh, "/camera/color/image_raw", 1);
    message_filters::Subscriber info_sub(nh, "/camera/aligned_depth_to_color/image_raw", 1);
    message_filters::TimeSynchronizer sync(image_sub, info_sub, 10);
    sync.registerCallback(boost::bind(&callback, _1, _2));
    ros::spin();
    cv::destroyWindow("view");

}

这里使用了message_filters,用于将彩色图像和深度图像设置同一个回调函数,也就是在回调函数里,可以同时取得彩色图与深度图的数据

二,将图像转换为opencv的Mat并获取指针

    cv_bridge::CvImagePtr color_ptr, depth_ptr;
    cv::Mat color_pic, depth_pic;
    color_

你可能感兴趣的:(图像处理,opencv)