Open fjulian opened 1 year ago
Please carefully check your data, its current values (maybe units are wrong) or your code.
See sample code below to show proper clipping.
import numpy as np
import open3d as o3d
if __name__ == "__main__":
print("Read Redwood dataset")
dataset = o3d.data.SampleRedwoodRGBDImages()
rgbd_images = []
depth_raw = o3d.io.read_image(dataset.depth_paths[0])
color_raw = o3d.io.read_image(dataset.color_paths[0])
d = np.asarray(depth_raw)
non_zero_d = d[np.nonzero(d)]
print("Number of depth values less than 1 meter are ", np.count_nonzero(non_zero_d < 1000))
pcd = o3d.geometry.PointCloud.create_from_depth_image(
depth_raw,
o3d.camera.PinholeCameraIntrinsic(
o3d.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault
),
np.identity(4),
depth_scale=1000.0,
depth_trunc=1,
)
print(pcd)
pcd.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
o3d.visualization.draw_geometries([pcd])
which gives output
Read Redwood dataset
Number of depth values less than 1 meter are 4828
PointCloud with 4828 points.
Image using depth_trunc of 1.5 meter to show chair getting clipped:-
Would you like to share this depth in a npy file: depth = 1.0 * near * far / (far - (far - near) * d)
? That will help me identify the problem. Thank you!
Thanks for looking into this!
@theNded I attached the npy file with the depth image (it's also zipped since github didn't like the file ending): depth.zip
Regarding the example of @saurabheights, your depth image seems to be in mm, which you account for using depth_scale=1000.0
. In my case, the depth image is already in m, so to my understanding, depth_scale=1.0
should be correct. Or am I missing something there?
Yes, if its already in meter, depth_scale=1.0
is fine.
I am encountering the same issue (same python and o3d versions, but on ubuntu 22.04)
had a quick look at the code, and it seems that the depth_trunc
parameter is never used by the PointCloud::CreateFromDepthImage
function if the input depth image is in float64. Will try to fix it
Checklist
master
branch).Describe the issue
When trying to compute a cloud based on a depth image, the
depth_trunc
parameter of the functiono3d.geometry.PointCloud.create_from_depth_image
seems to be ignored. In the point cloud, there are points at where the far plane would be, i.e. further than the specified truncation. In the code snippet below,depth_trunc
is set tofar
, but also changing this to lower values, e.g. 1.0, doesn't change the resulting point cloud. Is this a mistake/misunderstanding in how I use the function or a bug?A work around is to remove the
depth_trunc
value altogether, and instead include the linedepth = np.where(depth < far - 0.01, depth, 0.0)
which is currently commented out in the snippet below. However, it would be nice to usedepth_trunc
instead of this "hack".Steps to reproduce the bug
Error message
No response
Expected behavior
No response
Open3D, Python and System information
Additional information
No response