Items with no label
公告
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
3338 讨论

PyLibRealsense Saving Aligned PointCloud

MPark8
初学者
3,225 次查看

Hi,

I see there is an example for creating a pointcloud from color and depth frames and saving it as a .ply (export_ply_example.py), and I also see an alignment example (align_depth2color.py).

But, is there an example for saving an aligned pointcloud as a .ply file?

I took a piece of code from export_ply_example.py (marked in red) and put it into align_depth2.color.py as shown below.

pc = rs.pointcloud()

points = rs.points()

# Streaming loop

try:

while True:

# Get frameset of color and depth

frames = pipeline.wait_for_frames()

# frames.get_depth_frame() is a 640x360 depth image

# Align the depth frame to color frame

aligned_frames = align.process(frames)

# Get aligned frames

aligned_depth_frame = aligned_frames.get_depth_frame() # aligned_depth_frame is a 640x480 depth image

color_frame = aligned_frames.get_color_frame()

pc.map_to(color_frame)

# Generate the pointcloud and texture mappings

points = pc.calculate(aligned_depth_frame)

print("Saving to 1.ply...")

points.export_to_ply("1.ply", color_frame)

print("Done")

# Validate that both frames are valid

if not aligned_depth_frame or not color_frame:

continue

depth_image = np.asanyarray(aligned_depth_frame.get_data())

color_image = np.asanyarray(color_frame.get_data())

.

.

.

However, the resulting pointcloud is still not aligned.

Best Regards,

0 项奖励
6 回复数
MartyG
名誉分销商 III
1,823 次查看

Unless you really need to use Python scripting to do the alignment, there is a simple method for creating a color and depth alignment in the 3D point cloud mode of the RealSense Viewer, so you can then export a ply from the Viewer.

0 项奖励
MPark8
初学者
1,823 次查看

MartyG Thank you for the reply.

I am aware of that functionality in the RealSense Viewer, but I need do it in code, but it doesn't have to be in Python.

I am guessing there is some API for doing it since RealSense Viewer can do it, but I am not sure where to find that information.

0 项奖励
MartyG
名誉分销商 III
1,823 次查看

I searched extensively but unfortunately could not find a solution that I would be totally confident in.

You could take a look at the export_ply_example Python program.

https://github.com/IntelRealSense/librealsense/blob/development/wrappers/python/examples/export_ply_example.py librealsense/export_ply_example.py at development · IntelRealSense/librealsense · GitHub

Otherwise, I would recommend posting a request for code for an aligned point cloud on the RealSense GitHub, where the RealSense engineers and developers reside. You can do so by going to the link below and clicking on the 'New Issue' button.

https://github.com/IntelRealSense/librealsense/issues Issues · IntelRealSense/librealsense · GitHub

0 项奖励
idata
员工
1,823 次查看

Hi mpmpmpmp,

 

 

The export_ply_example.py already aligns the color and depth streams. You shouldn't have to align separately.

 

You can also try this example:

 

https://github.com/IntelRealSense/librealsense/tree/master/examples/pointcloud

 

Can you also tell me what makes you think you are not getting an aligned poincloud from export_ply_example.py? Can you send some screenshots?

 

 

Regards,

 

Alexandra

 

 

0 项奖励
idata
员工
1,823 次查看

Hi mpmpmpmp,

 

 

Following up on my colleagues original post.

 

Did you get the opportunity to try the example my colleague, Alexandra, mentioned?

 

 

Can you also tell us what makes you think you are not getting an aligned poincloud from export_ply_example.py? Can you send some screenshots?

 

 

Best regards,

 

Casandra

 

0 项奖励
MPark8
初学者
1,823 次查看

I have verified that export_ply_example.py aligning the color and depth streams.

I must have done something wrong before.

I did reinstall the PyRealsense, although I am not sure if that was the issue.

Thank you.

0 项奖励
回复