Why the registered image of depth_image_proc can't be shown?

asked 2017-07-13 07:52:16 -0500

xiaohuang gravatar image

I write a launch file for depth_image_proc/register to register the depth image on rgb image's frame. And there are topics such as /depth_registered/camera_info /depth_registered/image_rect /depth_registered/image_rect/compressed /depth_registered/image_rect/compressed/parameter_descriptions /depth_registered/image_rect/compressed/parameter_updates and so on.

But here is the problem that when I subscribe the /depth_registered/image_rect in my own program and do some processing, the registered image can't be shown. Some of my codes are below, anyone can point out my problem, Thanks:

        cam_info_rgb = ros::topic::waitForMessage<sensor_msgs::CameraInfo>("camera_info_rgb",nh_);
    cam_info_depth = ros::topic::waitForMessage<sensor_msgs::CameraInfo>("camera_info_depth",nh_);
        //image_sub_ = it_.subscribe("image", 1, &RGB_GRAY::convert_callback, this); //定义图象接受器
        //depth_sub_ = it_.subscribe("depth", 1, &RGB_GRAY::convert_callback, this); //定义图象接受器
    image_sub_.subscribe(nh_, "image", 1);
    depth_sub_.subscribe(nh_, "depth", 1);

    //for depth registered image
    register_sub_.subscribe(nh_, "registered", 1);


   // ApproximateTime takes a queue size as its constructor argument, hence MySyncPolicy(10)
    sync_.reset(new Synchronizer(MySyncPolicy(10), image_sub_, register_sub_));
    sync_->registerCallback(boost::bind(&RGB_GRAY::convert_callback, this, _1, _2));
    my_callback_queue_.callOne();

        cv::namedWindow(INPUT);  
        cv::namedWindow(OUTPUT);
    cv::namedWindow(DEPTH_OUTPUT);
    cv::namedWindow(MASKED);
    rgb_model.fromCameraInfo(cam_info_rgb);
    depth_model.fromCameraInfo(cam_info_depth);
    ros::NodeHandle nhp("~");
    nhp.param("ground_frame", ground_plane_tf, std::string("ground"));
    nhp.param("source_frame", source_plane_tf, std::string("source"));

The problem is that when I substitute the "register_sub_" with "depth_sub_" in function"sync_.reset()", everything works well. I can get data from every topic. Why the registered image can't be shown?

edit retag flag offensive close merge delete