ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Extract values in DisparityImage

asked 2013-03-17 04:33:27 -0500

superawesomepandacat gravatar image

I am trying to extract the values of certain points in a stereo_msgs::DisparityImage message. I'm assuming that the values are stored in "sensor_msgs/Image image" inside the DisparityImage message. So I did this:

void disparityrelay::callback(const stereo_msgs::DisparityImage::ConstPtr& disparity)
{
    cv_bridge::CvImagePtr cv_ptr;
    try
    {
        cv_ptr = cv_bridge::toCvCopy(disparity->image, sensor_msgs::image_encodings::TYPE_32FC1);
    }
    catch (cv_bridge::Exception& e)
    {
        ROS_ERROR("cv_bridge exception: %s", e.what());
        return;
    }

    imshow("Display", cv_ptr->image);
    cv::waitKey(3);
}

But all I got is a black and white image. Did I do something wrong, or am I just not approaching this correctly?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-03-17 11:07:14 -0500

superawesomepandacat gravatar image

Float values need to be normalize to 0~1 so that imshow can display it.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-03-17 04:33:27 -0500

Seen: 451 times

Last updated: Mar 17 '13