- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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,
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page