Repository navigation
Doubt about crop_point_cloud working #7395
Replies: 2 comments
|
When you pass ~43k unordered chair points as vertices, the "polygon" is a huge self-intersecting zig-zag. The even-odd test then marks many interior points as outside, which is where the holes come from. Every point is also tested against all 43k edges, which is why it took so long. I reproduced this on the demo cloud. 2000 random chair points as the polygon give 14908 points with holes, while the reference json gives 31337. If you want to build the polygon from points you already have, take their 2D outline in the plane perpendicular to the axis, for example the convex hull: import numpy as np, open3d as o3d
from scipy.spatial import ConvexHull
d = o3d.data.DemoCropPointCloud()
pcd = o3d.io.read_point_cloud(d.point_cloud_path)
ref = o3d.visualization.read_selection_polygon_volume(d.cropped_json_path)
P = np.asarray(ref.crop_point_cloud(pcd).points) # or your selected chair points
hull = ConvexHull(P[:, [0, 2]]) # 2D hull in X-Z (axis = Y)
outline = P[hull.vertices].copy(); outline[:, 1] = 0.0 # ordered boundary, 22 vertices
vol = o3d.visualization.SelectionPolygonVolume()
vol.orthogonal_axis = "Y"
vol.axis_min, vol.axis_max = ref.axis_min, ref.axis_max
vol.bounding_polygon = o3d.utility.Vector3dVector(outline)
chair = vol.crop_point_cloud(pcd) # 31474 points, instantA convex hull also includes the floor and gaps between the legs. For a tighter shape you need an ordered concave outline, which is what the interactive tool produces. In For your other two cases:
|
|
You used all 42,890 chair points, in file order, as the vertices. That polygon has edges that jump back and forth and cross each other many times. The even-odd rule then sees many areas as "outside", so you get holes. It is also slow, because the cost is (number of cloud points) x (number of polygon vertices). I reproduced this with a polygon built from 3,000 randomly ordered chair points. It kept 15,023 points instead of about 31,000 and took 4.6 s. If you want to build the polygon from points, use their ordered 2D hull: import numpy as np, open3d as o3d
from scipy.spatial import ConvexHull
P = np.asarray(chair_sel.points) # the points you selected
hull = ConvexHull(P[:, [0, 2]]) # x/z plane, because orthogonal_axis = "Y"
poly = P[hull.vertices].copy(); poly[:, 1] = 0.0
vol = o3d.visualization.SelectionPolygonVolume()
vol.orthogonal_axis = "Y"
vol.axis_min, vol.axis_max = -0.763, 4.023
vol.bounding_polygon = o3d.utility.Vector3dVector(poly)
chair = vol.crop_point_cloud(pcd)On the demo cloud, a 22-vertex hull gives 31,474 points in 0.01 s. That is almost the same result as the official You can also get the JSON straight from the editor. Press To remove the floor and parts of the object:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I would like to know how the
o3d.visualization.read_selection_polygon_volume.crop_point_cloudworks, for that I followed this example in this link: https://www.open3d.org/docs/release/tutorial/geometry/pointcloud.html#Crop-point-cloud and reproduced this example by creating my owncropped.jsonfile.I executed the script

/home/victorbg/miniconda3/envs/3Dbce_env/lib/python3.12/site-packages/open3d/examples/visualization/interactive_visualization.pyand I was selecting the chair little by little until reaching this result:After, I created a script (if anyone would like to see the code I can show) without downsampling to get the numpy.array from this .ply with approximately this content:
With this script I generated a custom cropped.json file for test and understanding purposes, the file different from the original one (with only 31 lines being 20 np.arrays) from the example had 214460 lines with this content, also, I decided to use the same values to
axis_max,axis_minand still maintained theorthogonal_axisinY:This is the original cropped.json one:
After I reproduced the same code, only modifying the
o3d.visualization.read_selection_polygon_volumefor the path where there is my cropped_chair.json and I executed the code:I got this result after a very long time:

and this amount of points:
chair:PointCloud with 27027 points.
len np.array(chair.points):27027
Less than in the original one from the example:
chair:PointCloud with 31337 points.
len np.array(chair.points):31337
With lots of holes, also I am without any idea how should I select the correct points to crop the original .ply. Also, I would like how could I do to crop the armrest, isolate the chair from the ground for example to more examples to understand better this concept
All reactions