I have created a c++ function to crop from a input point cloud, by using a list of meshes, the same number of cropped point cloud. I use openMP for speed up the process.
When I try to wrap the function using PYBIND11, I obtain the next error.
TypeError: crop_pcd_from_meshes(): incompatible function arguments.
I create a function based on this prototype:
std::vector<std::shared_ptr<open3d::geometry::PointCloud>> crop_pcd_from_meshes(
const std::vector<std::shared_ptr<open3d::geometry::TriangleMesh>>& meshes,
const open3d::geometry::PointCloud& point_cloud);
I tried creating the next wrap.
PYBIND11_MODULE(crop_module, m) {
m.doc() = "Python wrapper for processing point clouds with Open3D";
// py::class_<open3d::geometry::PointCloud, std::shared_ptr<open3d::geometry::PointCloud>>(m, "PointCloud")
// .def(py::init<>());
// py::class_<open3d::geometry::TriangleMesh, std::shared_ptr<open3d::geometry::TriangleMesh>>(m, "TriangleMesh")
// .def(py::init<>());
m.def("crop_pcd_from_meshes", &crop_pcd_from_meshes, "Process point clouds and return cropped versions", py::arg("meshes"), py::arg("point_cloud"));
I call the function from the next python code:
import open3d as o3d
import crop_module
# Load or create point cloud and meshes in Python
point_cloud = o3d.io.read_point_cloud("/home/javier/python_sources/C2B/c2b-cmp/testData/apartment/alignedPcl.ply")
meshes = [o3d.io.read_triangle_mesh("/home/javier/python_sources/C2B/c2b-cmp/src/cache/pru/IfcWall/186.obj"),
o3d.io.read_triangle_mesh("/home/javier/python_sources/C2B/c2b-cmp/src/cache/pru/IfcWall/269.obj"),
o3d.io.read_triangle_mesh("/home/javier/python_sources/C2B/c2b-cmp/src/cache/pru/IfcWall/323.obj"),
o3d.io.read_triangle_mesh("/home/javier/python_sources/C2B/c2b-cmp/src/cache/pru/IfcWall/367.obj")]
cropped_clouds = crop_module.crop_pcd_from_meshes(meshes, point_cloud)
print(len(cropped_clouds))
I obtain the next error:
Traceback (most recent call last):
File “/home/javier/python_sources/open3d-devel/open3d-cmake-crop/build/test.py”, line 16, in <module>
cropped_clouds = crop_module.crop_pcd_from_meshes(meshes, point_cloud)
TypeError: crop_pcd_from_meshes(): incompatible function arguments. The following argument types are supported:
1. (meshes: List[open3d::geometry::TriangleMesh], point_cloud: open3d::geometry::PointCloud) -> List[open3d::geometry::PointCloud]
Invoked with: [TriangleMesh with 8 points and 12 triangles., TriangleMesh with 8 points and 12 triangles., TriangleMesh with 8 points and 12 triangles., TriangleMesh with 8 points and 12 triangles.], PointCloud with 4127740 points.