nmellado / Super4PCS

Efficient Global Point-cloud registration
http://nmellado.github.io/Super4PCS/
Other
455 stars 215 forks source link

The "Segmentation fault (core dumped)" error when I compile PCLWrapper with my own Eigen #83

Closed jiangzhiwei2018 closed 1 year ago

jiangzhiwei2018 commented 1 year ago

here is my command

  1. cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./install -DEIGEN3_INCLUDE_DIR=/usr/include/eigen3 ..

  2. cd install/scripts/

  3. ./run-example.sh

    ------------------------------
    Running Super4PCS
    Use Super4PCS
    norm_max_dist: 0.01
    Initial LCP: 0.015
    Score: 0.47est: 0.470000                  
    (Homogeneous) Transformation from ../assets/hippo2.obj to ../assets/hippo1.obj: 
    0.743907    0.112463   -0.658752  -0.0996304
    -0.220342    0.971893  -0.0829012 -0.00848934
    0.630914    0.206821    0.747779  -0.0289328
          0           0           0           1
    Exporting Matrix to mat_super4pcs_fast.txt...
    Export DONE
    Exporting Registered geometry to super4pcs_fast.obj...
    Export DONE
    real 0.57
    user 0.43
    sys 0.14
    ------------------------------
    Running 4PCS
    Use old 4PCS
    Score: 0.79est: 0.790000                  
    (Homogeneous) Transformation from ../assets/hippo2.obj to ../assets/hippo1.obj: 
    0.73984    0.024322   -0.672343  -0.0973797
    -0.0397574    0.999181 -0.00760296 -0.00700102
    0.671607   0.0323556    0.740201  -0.0305548
          0           0           0           1
    Exporting Matrix to mat_4pcs_fast.txt...
    Export DONE
    Exporting Registered geometry to 4pcs_fast.obj...
    Export DONE
    real 2.17
    user 12.20
    sys 0.20
    ------------------------------
    Running PCLWrapper
    > Loading point clouds...
    Failed to find match for field 'curvature'.
    Failed to find match for field 'curvature'.
    > Starting alignment...
    Segmentation fault (core dumped)

The below is my cmake info.

CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- The CXX compiler identification is GNU 9.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_CXX: -fopenmp (found version "4.5") 
-- Found OpenMP: TRUE (found version "4.5")  
-- Enable OpenMP
-- Eigen3 root path: /usr/include/eigen3
-- The C compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Warning (dev) at /home/user/Libs/opencv-4.8/lib/cmake/opencv4/OpenCVConfig.cmake:86 (find_package):
  Policy CMP0146 is not set: The FindCUDA module is removed.  Run "cmake
  --help-policy CMP0146" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

Call Stack (most recent call first):
  /home/user/Libs/opencv-4.8/lib/cmake/opencv4/OpenCVConfig.cmake:108 (find_host_package)
  src/super4pcs/io/CMakeLists.txt:11 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found CUDA: /usr/local/cuda-11.8 (found suitable exact version "11.8") 
-- Found OpenCV: /home/user/Libs/opencv-4.8 (found version "4.8.0") 
-- [Deps] Use OpenCV 4.8.0 for image loading
CMake Warning (dev) at src/super4pcs/accelerators/CMakeLists.txt:33 (target_sources):
  Policy CMP0076 is not set: target_sources() command converts relative paths
  to absolute.  Run "cmake --help-policy CMP0076" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

  An interface source of target "super4pcs_accel" has a relative path.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at /snap/cmake/1329/share/cmake-3.27/Modules/ExternalProject.cmake:3136 (message):
  The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
  not set.  The policy's OLD behavior will be used.  When using a URL
  download, the timestamps of extracted files should preferably be that of
  the time of extraction, otherwise code that depends on the extracted
  contents might not be rebuilt if the URL changes.  The OLD behavior
  preserves the timestamps from the archive instead, but this is usually not
  what you want.  Update your project to the NEW behavior or specify the
  DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
  robustness issue.
Call Stack (most recent call first):
  /snap/cmake/1329/share/cmake-3.27/Modules/ExternalProject.cmake:4345 (_ep_add_download_command)
  tests/CMakeLists.txt:11 (ExternalProject_Add)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at /snap/cmake/1329/share/cmake-3.27/Modules/ExternalProject.cmake:3136 (message):
  The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
  not set.  The policy's OLD behavior will be used.  When using a URL
  download, the timestamps of extracted files should preferably be that of
  the time of extraction, otherwise code that depends on the extracted
  contents might not be rebuilt if the URL changes.  The OLD behavior
  preserves the timestamps from the archive instead, but this is usually not
  what you want.  Update your project to the NEW behavior or specify the
  DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
  robustness issue.
Call Stack (most recent call first):
  /snap/cmake/1329/share/cmake-3.27/Modules/ExternalProject.cmake:4345 (_ep_add_download_command)
  tests/CMakeLists.txt:19 (ExternalProject_Add)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning at demos/MeshlabPlugin/CMakeLists.txt:36 (message):
  Skipping Meshlab plugin preparation - Meshlab not found

  CMake variable EIGEN_ROOT is set to:

    /usr/include/eigen3

  For compatibility, find_package is ignoring the variable, but code in a
  .cmake module might still use it.
Call Stack (most recent call first):
  /usr/local/share/pcl-1.13/PCLConfig.cmake:296 (find_eigen)
  /usr/local/share/pcl-1.13/PCLConfig.cmake:549 (find_external_library)
  demos/CMakeLists.txt:7 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Checking for module 'eigen3'
--   Found eigen3, version 3.4.0
-- Found Eigen: /usr/include/eigen3 (Required is at least version "3.3") 
-- Eigen found (include: /usr/include/eigen3, version: 3.4.0)

  CMake variable FLANN_ROOT is set to:

    /usr

  For compatibility, find_package is ignoring the variable, but code in a
  .cmake module might still use it.
Call Stack (most recent call first):
  /usr/local/share/pcl-1.13/PCLConfig.cmake:253 (find_package)
  /usr/local/share/pcl-1.13/PCLConfig.cmake:298 (find_flann)
  /usr/local/share/pcl-1.13/PCLConfig.cmake:549 (find_external_library)
  demos/CMakeLists.txt:7 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Checking for module 'flann'
--   Found flann, version 1.8.4
-- Found FLANN: /usr/lib/x86_64-linux-gnu/libflann_cpp.so  
-- FLANN found (include: /usr/include, lib: /usr/lib/x86_64-linux-gnu/libflann_cpp.so)
-- The imported target "vtkParseOGLExt" references the file
   "/usr/bin/vtkParseOGLExt-7.1"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtkRenderingPythonTkWidgets" references the file
   "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtk" references the file
   "/usr/bin/vtk"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake"
but not all the files it references.

-- The imported target "pvtk" references the file
   "/usr/bin/pvtk"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake"
but not all the files it references.

-- Could NOT find Pcap (missing: PCAP_LIBRARIES PCAP_INCLUDE_DIRS) 
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")  
-- Found PNG: /usr/lib/x86_64-linux-gnu/libpng.so (found version "1.6.37") 
-- Checking for module 'libusb-1.0'
--   Found libusb-1.0, version 1.0.23
-- Found libusb: /usr/lib/x86_64-linux-gnu/libusb-1.0.so  
-- Eigen found (include: /usr/include/eigen3, version: 3.4.0)
-- Found Qhull: /usr/lib/x86_64-linux-gnu/libqhull_r.so  
-- QHULL found (include: /usr/include, lib: /usr/lib/x86_64-linux-gnu/libqhull_r.so)
-- Found PCL_COMMON: /usr/local/lib/libpcl_common.so  
-- Found PCL_KDTREE: /usr/local/lib/libpcl_kdtree.so  
-- Found PCL_OCTREE: /usr/local/lib/libpcl_octree.so  
-- Found PCL_SEARCH: /usr/local/lib/libpcl_search.so  
-- Found PCL_SAMPLE_CONSENSUS: /usr/local/lib/libpcl_sample_consensus.so  
-- Found PCL_FILTERS: /usr/local/lib/libpcl_filters.so  
-- Found PCL_2D: /usr/local/include/pcl-1.13  
-- Found PCL_GEOMETRY: /usr/local/include/pcl-1.13  
-- Found PCL_IO: /usr/local/lib/libpcl_io.so  
-- Found PCL_FEATURES: /usr/local/lib/libpcl_features.so  
-- Found PCL_ML: /usr/local/lib/libpcl_ml.so  
-- Found PCL_SEGMENTATION: /usr/local/lib/libpcl_segmentation.so  
-- Found PCL_VISUALIZATION: /usr/local/lib/libpcl_visualization.so  
-- Found PCL_SURFACE: /usr/local/lib/libpcl_surface.so  
-- Found PCL_REGISTRATION: /usr/local/lib/libpcl_registration.so  
-- Found PCL_KEYPOINTS: /usr/local/lib/libpcl_keypoints.so  
-- Found PCL_TRACKING: /usr/local/lib/libpcl_tracking.so  
-- Found PCL_RECOGNITION: /usr/local/lib/libpcl_recognition.so  
-- Found PCL_STEREO: /usr/local/lib/libpcl_stereo.so  
-- Found PCL_OUTOFCORE: /usr/local/lib/libpcl_outofcore.so  
-- Found PCL_PEOPLE: /usr/local/lib/libpcl_people.so  
CMake Warning (dev) at demos/PCLWrapper/CMakeLists.txt:3 (find_package):
  Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
  Run "cmake --help-policy CMP0074" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  CMake variable PCL_ROOT is set to:

    /usr/local

  For compatibility, CMake is ignoring the variable.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found Git: /usr/bin/git (found version "2.25.1") 
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) (Required is at least version "1.8.0")
-- Configuring done (2.4s)
-- Generating done (0.1s)
-- Build files have been written to: /home/user/Libs/Super4PCS/build

When I compile with the clean project (Eigen is not be downloaded, and don't use -DEIGEN3_INCLUDE_DIR), it will download Eigen automagically, the the results will be fine (as show below). So, mabye something wrong occurred in the version of Eigen (mine is 3.4).

------------------------------
Running Super4PCS
Use Super4PCS
norm_max_dist: 0.01
Initial LCP: 0.015
Score: 0.47est: 0.470000                  
(Homogeneous) Transformation from ../assets/hippo2.obj to ../assets/hippo1.obj: 
   0.743907    0.112463   -0.658752  -0.0996304
  -0.220342    0.971893  -0.0829012 -0.00848934
   0.630914    0.206821    0.747779  -0.0289328
          0           0           0           1
Exporting Matrix to mat_super4pcs_fast.txt...
Export DONE
Exporting Registered geometry to super4pcs_fast.obj...
Export DONE
real 0.54
user 0.42
sys 0.12
------------------------------
Running 4PCS
Use old 4PCS
Score: 0.79est: 0.790000                  
(Homogeneous) Transformation from ../assets/hippo2.obj to ../assets/hippo1.obj: 
    0.73984    0.024322   -0.672343  -0.0973797
 -0.0397574    0.999181 -0.00760296 -0.00700102
   0.671607   0.0323556    0.740201  -0.0305548
          0           0           0           1
Exporting Matrix to mat_4pcs_fast.txt...
Export DONE
Exporting Registered geometry to 4pcs_fast.obj...
Export DONE
real 2.23
user 12.72
sys 0.16
------------------------------
Running PCLWrapper
> Loading point clouds...
Failed to find match for field 'curvature'.
Failed to find match for field 'curvature'.
> Starting alignment...
norm_max_dist: 0.01
Initial LCP: 0.015
> Final score: 0.4700000                  
Alignment took 152.537ms.

    |  0.744  0.112 -0.659 | 
R = | -0.220  0.972 -0.083 | 
    |  0.631  0.207  0.748 | 

t = < -0.100, -0.008, -0.029 >
jiangzhiwei2018 commented 1 year ago

I used GDB to tracked the error. error occurred in sampled_P_3D_ = P in the match4pcsBase.hpp, but you know ,my sample_size is set to 200, P.size() is larger than 200 (I catch the value by GDB, get the determination value, I an sure it larger than 200), it would not jump into else But I am failed to use GDB to catch the value of options_.sample_size, it cannot get the object of options_

    // prepare P
    if (P.size() > options_.sample_size){
        sampler(P, options_, sampled_P_3D_);
    }
    else
    {
        Log<LogLevel::ErrorReport>( "(P) More samples requested than available: use whole cloud" );
        sampled_P_3D_ = P;  //error occurred
    }

The sampled_P_3D_ = P attempt to copy Point3D failed.

jiangzhiwei2018 commented 1 year ago

I solved this problem by using OpenGR, thanks for your contribution