Get depth and image from point cloud in python
I have some question with get the depth and image from point cloud, I read the image and depth to generate the point cloud, and i just do flip with point cloud, and then do capture_depth_float_buffer. but the result depth seems different from input depth.
here is my code:
img = cv2.imread('dataset/image_000010.png', -1)
depth = cv2.imread('dataset/depth_000010.pgm', -1)
o3d_image = o3d.geometry.Image(img)
o3d_depth = o3d.geometry.Image(depth)
imaged_image = o3d.geometry.create_rgbd_image_from_color_and_depth(o3d_image, o3d_depth)
pcd = o3d.geometry.create_point_cloud_from_rgbd_image(imaged_image, pinhole_camera_intrinsic)
pcd.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
vis = o3d.visualization.Visualizer()
vis.create_window('pcl', img_width, img_height, 50, 50, True)
vis.add_geometry(pcd)
out_depth = vis.capture_depth_float_buffer(True)
out_image = vis.capture_screen_float_buffer(True)
here is my result
the upper is input
below is output


Q1 : Is that the problem with view point? (or some method that can project point cloud to rgb and depth without using Visualizer) Q2 : Can i generate point cloud by myself ? (not using create_point_cloud_from_rgbd_image or create_point_cloud_from_depth)
07/16 update: same problem with the data in TestData/
By the way, my purpose is to do some rotate and translate and get the final depth and image from point cloud.
Thanks
answear Q2 by myself with this : http://www.open3d.org/docs/release/tutorial/Basic/working_with_numpy.html?highlight=working
someone can help me with Q1 ?
What is pinhole_camera_intrinsic in your example? And do you set the same intrinsic parameters for vis?
i'm actually trying to get z values from pcd file and want to save depth image from pcd file using this code
pcd_load = o3d.io.read_point_cloud("1.ply")
xyz_load = np.asarray(pcd_load.points)
img = o3d.geometry.Image((xyz_load[:,2] * 255).astype(np.uint8))
o3d.io.write_image("sync.png", img)
o3d.visualization.draw_geometries([img])
but not successfull, am i doing something wrong ? suggest any solution and later i have to save color image of that ply file as well, what sould i do ?
@griegler hi, I use o3d.camera.PinholeCameraIntrinsic() to get the pinhole_camera_intrinsic. I don't set the intrinsic parameters for vis, do you mean vis.get_view_control.convert_from_pinhole_camera_parameters() ? I try this before, but the param for convert_from_pinhole_camera_parameters need extrinsic and intrinsic matrix. I follow this page: http://www.open3d.org/docs/release/tutorial/Advanced/customized_visualization.html?highlight=get%20depth
@Resays you need pixel space image, but you only have point cloud so you need to project to pixel space first!!!!
can you refer any example for "project to pixel space" ... I just wanna know how can I project to pixel space in Open3D?
Issue closed due to lack of activity. Feel free to open a new issue if you still consider this is a critical matter.