Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

Get depth and image from point cloud in python

Open walkalone31 opened this issue 7 years ago • 7 comments

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 image

image

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

walkalone31 avatar Jul 15 '19 07:07 walkalone31

answear Q2 by myself with this : http://www.open3d.org/docs/release/tutorial/Basic/working_with_numpy.html?highlight=working

walkalone31 avatar Jul 17 '19 10:07 walkalone31

someone can help me with Q1 ?

walkalone31 avatar Jul 18 '19 05:07 walkalone31

What is pinhole_camera_intrinsic in your example? And do you set the same intrinsic parameters for vis?

griegler avatar Jul 18 '19 06:07 griegler

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 ?

Resays avatar Jul 18 '19 11:07 Resays

@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!!!!

walkalone31 avatar Jul 19 '19 02:07 walkalone31

can you refer any example for "project to pixel space" ... I just wanna know how can I project to pixel space in Open3D?

Resays avatar Jul 21 '19 03:07 Resays

Issue closed due to lack of activity. Feel free to open a new issue if you still consider this is a critical matter.

germanros1987 avatar Aug 07 '20 01:08 germanros1987