Save point cloud as .ply but rotated
Hello,
I would like to save my point cloud as a .ply but it should be rotated by 90 degrees, is there a way to do that ?
Currently, I am doing that in python :
pc = rs.pointcloud()
pc.map_to(image_frame)
points = pc.calculate(depth_frame)
points.export_to_ply('point_cloud.ply', image_frame)
But I want to do some kind of processing on image_frame and depth_frame to rotate the final point cloud saved. For example, I can do
np.rot90(image_data, axes=(1,0))
but that works only on the image data as a numpy array. This does not work on the pyrealsense2 frame objects ...
-
Hi Gueganj As you want to rotate the cloud data and not just change the viewpoint that the cloud is observed from, it sounds as though that an affine transform is what you need. It is typically used to orient multiple point clouds to the same rotation and position so that they can be 'stitched' together into a single cloud.
The RealSense SDK instruction rs2_transform_point_to_point is an example of an affine transform, as described in the Python case in the link below.
-
Hi MartyG, I understand your answer and what I want to do is exactly an affine transform (that is basically just a matrix multiplication) but what I am struggling to do is to make it works with the librealsense. From my understanding, rs2_transform_point_to_point() takes as input a extrinsics structure and a float[3] (the point to transform) and I want to interface this with
pc = rs.pointcloud()
pc.map_to(image_frame)
points = pc.calculate(depth_frame)
points.export_to_ply('point_cloud.ply', image_frame)This code lines does not use float[3] variables but some kind of pyrealsense2.frame object (image_frame, depth_frame and points) and pyrealsense2.pyrealsense2.pointcloud object (pc) .... Also I have checked the source code on github and the documentation but I cannot really find good details/explanation on how to do it
Thank you for your help !
-
There are limited references available on the subject of using rs2_transform_point_to_point for affine transformation of a point cloud. The link below may be helpful in advancing the discussion.
https://github.com/IntelRealSense/librealsense/issues/8333#issuecomment-778252600
Please sign in to leave a comment.
Comments
3 comments