4 Replies Latest reply on Oct 16, 2018 3:30 AM by Intel Corporation

    PyLibRealsense Saving Aligned PointCloud

    mpmpmpmp

      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,