How to extract depth value from PCD file?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to extract depth value from PCD file?

TrinhTUHH
I have an exactly same question like this one here:
https://stackoverflow.com/questions/42430479/how-to-extract-depth-information-from-the-3d-point-cloud-data/46234391#46234391
In general, I have a PCD file with format (from  Cornell Grasping Dataset
<http://pr.cs.cornell.edu/grasping/rect_data/data.php>  ):

.PCD v.7 - Point Cloud Data file format
FIELDS x y z rgb index
SIZE 4 4 4 4 4
TYPE F F F F U
COUNT 1 1 1 1 1
WIDTH 253674
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 253674
DATA ascii

So my question is how could I extract depth value from these PCD file?




--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: How to extract depth value from PCD file?

icedoggy
Hi!

In general, the z component will describe the depth or distance from the
camera / scanner. But It could be all different if you have rotated
coordinate frame. So you need to know the orientation of that coordinate
system.
You could calculate the Euclidean distance from the origin of the scanner to
each point, than you get a distance but its not really depth.

Normally, the values stored in PCD from a laser scanner are in meters. Since
your data is from a stereo-rig it may as well be mm which would make sense
looking at the 2 lines of data in the stackoverflow question.

Once you have determined your distance or have decided weather z is your
depth or not you can store the data in a cloud of type pcl::PointXYZRGBA and
misuse the alpha channel as Depth. Don't know if this makes sense for your
application.

Cheers



--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: How to extract depth value from PCD file?

Hilarius

Hi,

have a look at the visualization from CloudCompare of the pcd File pcd0171 from your source.

The camera system or point cloud is aligned differently than you expect from the raw png. I colored it by range from the screenshot calculated to the camera origin in CC (2.6.1) for better recognition of the scene. Seems it was saved in a processed manner and not directly in Col Row Depth, but as you see you can restore the depth or distance from the center. As PCL is able to work with organized point clouds also height and width in the pcd cloud could be set to 640x480 to retain the structured nature of the cloud, but not all pixel are valid so not the 640x480 pixel are saved, but just 253671 or 83% resulting in an unorganized cloud.

I didn't check if indexing as indicated helps to restore the original registration of the picture, but I'd guess. Calculate all distances using the coordinates and the indices, fill in the blanks and view as an depthimage. Also, from the coordinate values, everything seems to be in mm.

Regards,
Felix

Am 18.09.2017 um 11:23 schrieb TrinhTUHH:
I don't get it. If the depth value is the z value then why there are positive
and negative values. The camera is over the object so all the values should
have the same sign right?



--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users