首页 > 解决方案 > how to write pybind11_module when used point cloud library

问题描述

I am writing a python project, and I need a module of point cloud reconstruction to polygon mesh and other operations. So I write these modules in C++ by calling Point Cloud Library(PCL), Eigen and Pybind11. Except Eigen::Matrix, pcl::PointCloud, pcl::PolygonMesh, I still define some new classes. But in the interface function "PreProcess"(python call this function) I only use Eigen::Matrix and std::vector, which are all support by pybind11, PCL classes and my self-defined classes are only used in some middle sub functions.

I have tried some easy toy codes(only use Eigen and Pybind11), use the bellow "PYBIND11_MODULE" can be compiled successfully, Pybind can support Eigen::Matrix and C++ std::vector.

Now in my c++ project, when I using the same "PYBIND11_MODULE" with the essy toy code, it can not pass compiling, with error:

/home/helanyi/Documents/pgnn/utils/surface_reconstruct/src/test.cpp:931:16: error: expected constructor, destructor, or type conversion before ‘(’ token PYBIND11_MODULE(process, m) {

So I want to ask that how do I write the "PYBIND11_MODULE"? Need I define the pcl classes and my self-defined classes in the "PYBIND11_MODULE"? Thank you so much!

PYBIND11_MODULE(process, m) {
  m.doc() = "pybind11 example plugin";
  m.def("PreProcess", &PreProcess);
}

标签: pythonc++eigenpoint-cloud-librarypybind11

解决方案


推荐阅读