The pixel depth value (OpenCV image) coming out of zed
I am trying to obtain depth value of every pixel in the image coming from a zed camera. I have the following approach. I have created a node based on this. I have changed the topic to be subscribed to as/camera/depth/image_rect_color
and the destination encoding as 32FC1
.
I am running this on Jetson TX1 with ros indigo on ubuntu 14.04.
I have two issues: 1) When I display the depth image in OpenCV, I obtain a black and white image and not a grayscale image(to indicate different depths). What am I doing wrong?
2) I have the following block of code to print the depth values:
for (int i=0; i<cv_ptr->image.rows; i++)
{
for (int j=0; j<cv_ptr->image.cols; j++)
{
cv::Scalar intensity = cv_ptr->image.at<float>(i, j);
double depth = intensity.val[0];
ROS_INFO("DEPTH INFO of pixel(%d,%d): [%lf]", i,j,depth);
}
}
Here cv_ptr->image will give the OpenCV image. When I check the values, I have a lot of nan and infvalues. I believe inf indicates that the depth is out of the range of camera(20m). But why are some values 'nan'? Also is the following line (in the above code block) right in order to obtain a 32 bit float value?
cv::Scalar intensity = cv_ptr->image.at<float>(i, j);
Asked by skr_robo on 2016-09-16 10:39:07 UTC
Comments