Ask Your Question
0

printing kinect point cloud data alone gives garbage

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

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((data.data))
    print msg.data
    listener.unregister()

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

if __name__=='__main__':
    kinect_depth()

Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

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

The PointCloud2 is packed into a format that is not automatically unpacked. sensor_msgs/point_cloud2.py 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

Comments

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 -0500 )edit

Yes, that's what the functions in point_cloud2.py do.

Dan Lazewatsky gravatar image Dan Lazewatsky  ( 2015-02-01 15:12:32 -0500 )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 -0500 )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 -0500 )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

Stats

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

Seen: 575 times

Last updated: Feb 01 '15