I want to crop a poincloud using the segmented mask (rectangle) and depth image, (I can consider that there is no rotation for now).
import open3d as o3d
## dummy pointcloud
demo_icp_pcds = o3d.data.DemoICPPointClouds()
pcd = o3d.io.read_point_cloud(demo_icp_pcds.paths[0])
## dummy depth mask
depth_mask = np.ones((640, 480), dtype=np.uint8)
## Crop PCD
## mask boundaries: [(xmin, xmax), (y_min, y_max)]
rect = [(20, 50), (70, 75)]
o_box = o3d.geometry.OrientedBoundingBox()
o_box.center = [0.0, 0.0, 0.0]
o_box.extent = [1.0, 2.0, 3.0]
o_box.R = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
cropped_pcd = pcd.crop(o_box)
I want to feed the info of the rect (x, y) and depth z to the orietned bounding box. Can anybody please tell me how can do that? thanks.
Cropping is much easier using axis aligned bounding box if your crop volume is cuboid and aligned with x,y,z axis. Anyways, an oriented bounding box with rotation as identity is equivalent. See below code for crop example.
Also, follow 2 tips:-
Also, if you are using axis-aligned bounding box, be careful. Make sure min_bound < max_bound in all three axes. This has been fixed in recent PR by me - https://github.com/isl-org/Open3D/pull/6444, however changes are available only in development releases.