Why so many nan values appear when depth image convert to cv::mat

asked 2020-03-16 14:09:26 -0500

roovie gravatar image

updated 2020-03-16 14:15:51 -0500

My ROS version is Kinetic

I am using rotor_simulator package.

I subscribe the topic "pelican/vi_sensor/camera_depth/depth/disparity"

and the topic type is sensor/image, and encoding is 32fc1

I try to convert the msg to cv::mat

cv_bridge::CvImageConstPtr cv_ptr;
cv::Mat imgDepth;
try
{
    cv_ptr = cv_bridge::toCvShare(msg, sensor_msgs::image_encodings::TYPE_32FC1);
}
catch (cv_bridge::Exception& e)
{
    ROS_ERROR("cv_bridge exception: %s", e.what());
    return;
}
imgDepth = cv_ptr->image;

Now I print the value in "img"

there are so many nan values, and the image I strored is all black

In rviz view, the depth image is normal

So why so many nan values appear and how to store a normal image?

edit retag flag offensive close merge delete

Comments

Try subscribing to ../depth/image_raw" well it worked for me

rayane gravatar image rayane  ( 2020-09-26 12:00:14 -0500 )edit