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

Accessing pixel values in a depth image in OpenCV

asked 2012-11-06 04:00:38 -0500

kameleon gravatar image

I need to use the depth image from a Kinect sensor for my next project, but I'm still stuck in the basics. Obtaining a point cloud was way easier.

I tried to use cv_bridge to convert the /camera/depth/image_raw into an OpenCV matrix, and then, just to test it, I saved it in a .pgm and .jpg file. The image was there, but it doesn't look as I expected. Here's the image:

image description

You can see the silhouette, but there are only two colors in the whole image, black and white and nothing in between. I expected a grayscale representation of depth in more shades. I tried printing out the first few pixels in the opencv matrix as floats and like the images would suggest, they are all zero, which doesn't seem right compared to the scene that I recorded. Therefore, it looks as the problem is in the cv_bridge conversion. What exactly should I do to get a proper depth image matrix?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-11-10 02:42:02 -0500

kameleon gravatar image

Solved this eventually.

The problem was that the whole scale would represent a few centimeters of depth in the middle of Kinect's range and the white silhouettes are just some kind of sensor noise.

edit flag offensive delete link more


Were you able to visualize your depth image as you expected? If so, post the details in an edited version of this answer so other people face with the same doubt will know how to do that too.

georgebrindeiro gravatar image georgebrindeiro  ( 2012-11-10 02:56:58 -0500 )edit

Question Tools


Asked: 2012-11-06 04:00:38 -0500

Seen: 942 times

Last updated: Nov 10 '12