I am trying to crop a Open3d pointcloud using a SelectionPolygonVolume object. On Open3d's github tutorial, the SelectionPolygonVolume is created by calling
vol = o3d.visualization.read_selection_polygon_volume("../../TestData/Crop/cropped.json")
to build the object from a json file.
I can get this to run fine, but can't generate a SelectionPolygonVolume without loading it first from a json file. How can the class be instantiated without a json file? I've looked all through the docs and online and can't find anything.
Here's what i've tried so far:
bounding_polygon = np.array([
[ 2.6509309513852526, 0.0, 1.6834473132326844 ],
...
[ 2.6579576128816544, 0.0, 1.6819127849749496 ]]).astype("float64")
vol = o3d.visualization.SelectionPolygonVolume()
vol.orthogonal_axis = "Y"
vol.axis_max = 4.022921085357666
vol.axis_min = -0.76341366767883301
vol.bounding_polygon = bounding_polygon
but it throws the following error (when calling vol.bounding_polygon = bounding_polygon
):
TypeError: (): incompatible function arguments. The following argument types are supported:
1. (self: open3d.open3d.visualization.SelectionPolygonVolume, arg0: open3d.open3d.utility.Vector3dVector) -> None
Invoked with: visualization::SelectionPolygonVolume, access its members:
orthogonal_axis, bounding_polygon, axis_min, axis_max, array([[2.65093095, 0. , 1.68344731],
One obvious workaround would be to save json files for new objects but this is obviously clunky and to be avoided if possible.
Any advice/ explanation would be appreciated!
Thanks.
side note: I think it would be reasonable for a open3d tag. to be available for questions regarding the Open3d project (http://www.open3d.org)
This isn't very clear from the docs, but you need to convert the numpy array to type Vector3dVector
first.
bounding_polygon = np.array([
[ 2.6509309513852526, 0.0, 1.6834473132326844 ],
...
[ 2.6579576128816544, 0.0, 1.6819127849749496 ]]).astype("float64")
vol = o3d.visualization.SelectionPolygonVolume()
vol.bounding_polygon = o3d.utility.Vector3dVector(bounding_polygon)