Environments:
ubuntu 16.04 + anaconda 2 + pytorch 0.4.0
I’m trying to build a cpp extension for point cloud iterative closest point using the icp function in pcl-1.7 http://pointclouds.org/documentation/tutorials/iterative_closest_point.php.
The data transforming from at::tensor to pcl::Pointcloud is fine. However, as soon as I declare a new icp object, there will be a segmentation fault.
This line triggers the fault:
pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp;
The setup.py file is:
setup(
name='icp_cpp',
version='1.0',
ext_modules=[
CppExtension(
name='icp_cpp',
sources = ['icp_op.cpp'],
library_dirs=['/usr/lib/x86_64-linux-gnu'],
libraries=[*pcl related libraries*],
include_dirs=["/usr/include/pcl-1.7/",
"/usr/include/eigen3"])],
cmdclass={
'build_ext': BuildExtension
})
I also tried to add more arguments to the CppExtension as python-pcl/setup.py at master · strawlab/python-pcl · GitHub. But it doesn’t help.
To repeat the bug, you can clone the related files from https://github.com/onlytailei/icp_extension.
There should be pcl and eigen in the system
sudo apt-get install libpcl-all
sudo apt-get install libeigen3-dev
Then build the extension through:
python setup install.py
Comment/Uncomment line 72 in icp_op.cpp
pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp;
And rebuild the extension, you will see the difference.
python icp_test.py