ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

printing kinect point cloud data alone gives garbage

asked 2015-02-01 04:55:20 -0600

gaussian gravatar image

I have subscribed to /camera/depth/points to get the PointCloud2 data from kinect. When I try to print the PointCloud2 data alone leaving out the headers, height and width etc i get a pool of garbage values. How do i print the 'data' field alone.? I am able to get the output without any garbage if i print the entire msg.

Here is my code.

#!/usr/bin/env python
import roslib
import rospy
from sensor_msgs.msg import PointCloud2

def callback(msg):
    print len((

def kinect_depth():
    rospy.init_node('kinect_depth', anonymous=True)
    global listener 
    listener = rospy.Subscriber("/camera/depth/points", PointCloud2, callback)

if __name__=='__main__':

Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-02-01 10:21:58 -0600

The PointCloud2 is packed into a format that is not automatically unpacked. sensor_msgs/ can help you unpack the data (though it is a bit slow).

Alternatively, if you just want depth, and not x,y,z points, you could subscribe to the depth image and use cv_bridge to get the data.

edit flag offensive delete link more


Thanks for your reply. I will look into it. I want the x,y,z data without converting the pointcloud2 into .pcd file. Is it possible to get that?

gaussian gravatar image gaussian  ( 2015-02-01 10:54:26 -0600 )edit

Yes, that's what the functions in do.

Dan Lazewatsky gravatar image Dan Lazewatsky  ( 2015-02-01 15:12:32 -0600 )edit

@Dan Lazewatsky If I use the latter method of converting the depthimage into grayscale image, how can I convert that into depth in some unit. As the grayscale value in the image are relative to largest depth. Am i right? Is there any const conversion factor between grayscale value and deptin in 'm'?

gaussian gravatar image gaussian  ( 2015-02-02 14:44:13 -0600 )edit

Using openni_camera at least, depth images contain uint16 depths in mm.

Dan Lazewatsky gravatar image Dan Lazewatsky  ( 2015-02-02 14:54:32 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-02-01 04:55:20 -0600

Seen: 647 times

Last updated: Feb 01 '15