Cannot visualize depth image from turtlebot simulator [closed]
Hi, i'm going deep into my simulated kinect problem. The problem is: I cannot display depth image data from turtlebot simulated kinect. It is correctly published; I can see the messages flowing. The image seen from gazebo camera view is the plane with a cube on it;but when I try to visualize it through cv::imshow, I see skew lines gray colored with rest of window filled of black instead of the cube. The output from gazebo turtlebot simulator is mono8 type. (I can choose it or RGB8 types) The code that I'm using is:
cv_bridge::CvImagePtr bridge; try { bridge = cv_bridge::toCvCopy(image, ""); //cv::imshow("Kinect RGB image", bridge->image); } catch (cv_bridge::Exception& e) { ROS_ERROR("Failed to transform depth image."); return; }
// convert to something visible
cv::Mat img(bridge->image.rows, bridge->image.cols, CV_8UC1);
for(int i = 0; i < bridge->image.rows; i++)
{
char* Di = bridge->image.ptr<char>(i);
char* Ii = img.ptr<char>(i);
for(int j = 0; j < bridge->image.cols; j++)
{
Ii[j] = Di[j];
}
}
// display
cv::imshow(WINDOW_NAME, img);
cv::waitKey(3);
}
that code is taken from depth_viewer.I changed it because depth_viewer expect a 32bit float, while I already has mono8 data. If i try to use image_view it gives OpenCV Error: Image step is wrong () in cvInitMatHeader, file /tmp/buildd/libopencv-2.3.1+svn6514+branch23/modules/core/src/array.cpp, line 162 terminate called after throwing an instance of 'cv::Exception' what(): /tmp/buildd/libopencv-2.3.1+svn6514+branch23/modules/core/src/array.cpp:162: error: (-13) in function cvInitMatHeader
Maybe because the depth image topic in mono8 is not in the right cv format. (i'm using ros electric)
did you try rviz for visualization??