0
$\begingroup$

I am trying to use PCL filters in my rosnode ,where I am trying to perform noise removal on the pointcloud,but while building the package. I am getting CMAKE errors

#include <pcl/filters/statistical_outlier_removal.h>

pcl::StatisticalOutlierRemoval<pcl::PointXYZ> sor;
sor.setInputCloud(cloud_msg);
sor.setMeanK(50);  // Number of neighbors to consider for mean distance estimation
sor.setStddevMulThresh(1.0); // Standard deviation threshold
sor.filter(*cloud_msg); // Apply the noise filter

Here is the catkin_make output:

-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Using Debian Python package layout
-- Using empy: /usr/lib/python3/dist-packages/em.py
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/ketan/MiDaS/ros/build/test_results
-- Forcing gtest/gmock from source, though one was otherwise available.
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /usr/bin/python3 (found version "3.8.10") 
-- Using Python nosetests: /usr/bin/nosetests3
-- catkin 0.8.10
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 1 packages in topological order:
-- ~~  - midas_cpp
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'midas_cpp'
-- ==> add_subdirectory(midas_cpp)
-- Caffe2: CUDA detected: 12.2
-- Caffe2: CUDA nvcc is: /usr/local/cuda/bin/nvcc
-- Caffe2: CUDA toolkit directory: /usr/local/cuda
-- Caffe2: Header version is: 12.2
-- /usr/local/cuda/lib64/libnvrtc.so shorthash is 000ca627
-- USE_CUDNN is set to 0. Compiling without cuDNN support
-- Autodetected CUDA architecture(s):  6.1
-- Added CUDA NVCC flags for: -gencode;arch=compute_61,code=sm_61
-- Eigen found (include: /usr/include/eigen3, version: 3.3.7)
-- 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.

-- OpenNI found (version: 1.5.4.0, include: /usr/include/ni, lib: /usr/lib/libOpenNI.so;libusb::libusb)
-- OpenNI2 found (version: 2.2.0.33, include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so;libusb::libusb)
-- Could NOT find Pcap (missing: PCAP_LIBRARIES PCAP_INCLUDE_DIRS) 
** WARNING ** io features related to pcap will be disabled
-- Eigen found (include: /usr/include/eigen3, version: 3.3.7)
-- OpenNI found (version: 1.5.4.0, include: /usr/include/ni, lib: /usr/lib/libOpenNI.so;libusb::libusb)
-- OpenNI2 found (version: 2.2.0.33, include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so;libusb::libusb)
-- Could NOT find Qhull (missing: QHULL_INCLUDE_DIR) 
** WARNING ** surface features related to qhull will be disabled
-- looking for PCL_COMMON
-- looking for PCL_KDTREE
-- looking for PCL_OCTREE
-- looking for PCL_SEARCH
-- looking for PCL_SAMPLE_CONSENSUS
-- looking for PCL_FILTERS
-- looking for PCL_2D
-- looking for PCL_GEOMETRY
-- looking for PCL_IO
-- looking for PCL_FEATURES
-- looking for PCL_ML
-- looking for PCL_SEGMENTATION
-- looking for PCL_VISUALIZATION
-- looking for PCL_SURFACE
-- looking for PCL_REGISTRATION
-- looking for PCL_KEYPOINTS
-- looking for PCL_TRACKING
-- looking for PCL_RECOGNITION
-- looking for PCL_STEREO
-- looking for PCL_OUTOFCORE
-- looking for PCL_PEOPLE
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- Configuring done (1.6s)
-- Generating done (0.0s)
-- Build files have been written to: /home/ketan/MiDaS/ros/build
####
#### Running command: "make -j12 -l12" in "/home/ketan/MiDaS/ros/build"
####
[ 25%] Built target camera_bringup
[ 50%] Built target realsense2_camera
[ 62%] Linking CXX executable /home/ketan/MiDaS/ros/devel/lib/midas_cpp/depth_pcl
[ 87%] Built target midas_cpp
/usr/bin/ld: warning: libopencv_imgcodecs.so.4.2, needed by /opt/ros/noetic/lib/libcv_bridge.so, may conflict with libopencv_imgcodecs.so.408
/usr/bin/ld: warning: libopencv_core.so.408, needed by /home/ketan/opencv/build/lib/libopencv_imgcodecs.so.4.8.0, may conflict with libopencv_core.so.4.2
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o: in function `DepthPcl::stateCallback(ros::TimerEvent const&)':
depth_pcl.cpp:(.text+0x7d1): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setInputCloud(std::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o: in function `pcl::Filter<pcl::PointXYZ>::filter(pcl::PointCloud<pcl::PointXYZ>&)':
depth_pcl.cpp:(.text._ZN3pcl6FilterINS_8PointXYZEE6filterERNS_10PointCloudIS1_EE[_ZN3pcl6FilterINS_8PointXYZEE6filterERNS_10PointCloudIS1_EE]+0x38): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::initCompute()'
/usr/bin/ld: depth_pcl.cpp:(.text._ZN3pcl6FilterINS_8PointXYZEE6filterERNS_10PointCloudIS1_EE[_ZN3pcl6FilterINS_8PointXYZEE6filterERNS_10PointCloudIS1_EE]+0x205): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::deinitCompute()'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o: in function `pcl::Filter<pcl::PointXYZ>::Filter(bool)':
depth_pcl.cpp:(.text._ZN3pcl6FilterINS_8PointXYZEEC2Eb[_ZN3pcl6FilterINS_8PointXYZEEC5Eb]+0x20): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::PCLBase()'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o: in function `void pcl::PointCloud<pcl::PointXYZ>::assign<__gnu_cxx::__normal_iterator<pcl::PointXYZ const*, std::vector<pcl::PointXYZ, Eigen::aligned_allocator<pcl::PointXYZ> > > >(__gnu_cxx::__normal_iterator<pcl::PointXYZ const*, std::vector<pcl::PointXYZ, Eigen::aligned_allocator<pcl::PointXYZ> > >, __gnu_cxx::__normal_iterator<pcl::PointXYZ const*, std::vector<pcl::PointXYZ, Eigen::aligned_allocator<pcl::PointXYZ> > >, int)':
depth_pcl.cpp:(.text._ZN3pcl10PointCloudINS_8PointXYZEE6assignIN9__gnu_cxx17__normal_iteratorIPKS1_St6vectorIS1_N5Eigen17aligned_allocatorIS1_EEEEEEEvT_SE_i[_ZN3pcl10PointCloudINS_8PointXYZEE6assignIN9__gnu_cxx17__normal_iteratorIPKS1_St6vectorIS1_N5Eigen17aligned_allocatorIS1_EEEEEEEvT_SE_i]+0x36): undefined reference to `pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)'
/usr/bin/ld: depth_pcl.cpp:(.text._ZN3pcl10PointCloudINS_8PointXYZEE6assignIN9__gnu_cxx17__normal_iteratorIPKS1_St6vectorIS1_N5Eigen17aligned_allocatorIS1_EEEEEEEvT_SE_i[_ZN3pcl10PointCloudINS_8PointXYZEE6assignIN9__gnu_cxx17__normal_iteratorIPKS1_St6vectorIS1_N5Eigen17aligned_allocatorIS1_EEEEEEEvT_SE_i]+0x129): undefined reference to `pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl25StatisticalOutlierRemovalINS_8PointXYZEEE[_ZTVN3pcl25StatisticalOutlierRemovalINS_8PointXYZEEE]+0x20): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setInputCloud(std::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl25StatisticalOutlierRemovalINS_8PointXYZEEE[_ZTVN3pcl25StatisticalOutlierRemovalINS_8PointXYZEEE]+0x28): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(std::shared_ptr<std::vector<int, std::allocator<int> > > const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl25StatisticalOutlierRemovalINS_8PointXYZEEE[_ZTVN3pcl25StatisticalOutlierRemovalINS_8PointXYZEEE]+0x30): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(std::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl25StatisticalOutlierRemovalINS_8PointXYZEEE[_ZTVN3pcl25StatisticalOutlierRemovalINS_8PointXYZEEE]+0x38): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(std::shared_ptr<pcl::PointIndices const> const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl25StatisticalOutlierRemovalINS_8PointXYZEEE[_ZTVN3pcl25StatisticalOutlierRemovalINS_8PointXYZEEE]+0x40): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(unsigned long, unsigned long, unsigned long, unsigned long)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl25StatisticalOutlierRemovalINS_8PointXYZEEE[_ZTVN3pcl25StatisticalOutlierRemovalINS_8PointXYZEEE]+0x48): undefined reference to `pcl::FilterIndices<pcl::PointXYZ>::applyFilter(pcl::PointCloud<pcl::PointXYZ>&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl13FilterIndicesINS_8PointXYZEEE[_ZTVN3pcl13FilterIndicesINS_8PointXYZEEE]+0x20): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setInputCloud(std::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl13FilterIndicesINS_8PointXYZEEE[_ZTVN3pcl13FilterIndicesINS_8PointXYZEEE]+0x28): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(std::shared_ptr<std::vector<int, std::allocator<int> > > const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl13FilterIndicesINS_8PointXYZEEE[_ZTVN3pcl13FilterIndicesINS_8PointXYZEEE]+0x30): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(std::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl13FilterIndicesINS_8PointXYZEEE[_ZTVN3pcl13FilterIndicesINS_8PointXYZEEE]+0x38): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(std::shared_ptr<pcl::PointIndices const> const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl13FilterIndicesINS_8PointXYZEEE[_ZTVN3pcl13FilterIndicesINS_8PointXYZEEE]+0x40): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(unsigned long, unsigned long, unsigned long, unsigned long)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl13FilterIndicesINS_8PointXYZEEE[_ZTVN3pcl13FilterIndicesINS_8PointXYZEEE]+0x48): undefined reference to `pcl::FilterIndices<pcl::PointXYZ>::applyFilter(pcl::PointCloud<pcl::PointXYZ>&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_8PointXYZEEE[_ZTVN3pcl6FilterINS_8PointXYZEEE]+0x20): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setInputCloud(std::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_8PointXYZEEE[_ZTVN3pcl6FilterINS_8PointXYZEEE]+0x28): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(std::shared_ptr<std::vector<int, std::allocator<int> > > const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_8PointXYZEEE[_ZTVN3pcl6FilterINS_8PointXYZEEE]+0x30): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(std::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_8PointXYZEEE[_ZTVN3pcl6FilterINS_8PointXYZEEE]+0x38): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(std::shared_ptr<pcl::PointIndices const> const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_8PointXYZEEE[_ZTVN3pcl6FilterINS_8PointXYZEEE]+0x40): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(unsigned long, unsigned long, unsigned long, unsigned long)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_8PointXYZEEE[_ZTVN3pcl7PCLBaseINS_8PointXYZEEE]+0x20): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setInputCloud(std::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_8PointXYZEEE[_ZTVN3pcl7PCLBaseINS_8PointXYZEEE]+0x28): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(std::shared_ptr<std::vector<int, std::allocator<int> > > const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_8PointXYZEEE[_ZTVN3pcl7PCLBaseINS_8PointXYZEEE]+0x30): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(std::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_8PointXYZEEE[_ZTVN3pcl7PCLBaseINS_8PointXYZEEE]+0x38): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(std::shared_ptr<pcl::PointIndices const> const&)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_8PointXYZEEE[_ZTVN3pcl7PCLBaseINS_8PointXYZEEE]+0x40): undefined reference to `pcl::PCLBase<pcl::PointXYZ>::setIndices(unsigned long, unsigned long, unsigned long, unsigned long)'
/usr/bin/ld: CMakeFiles/depth_pcl.dir/src/depth_pcl.cpp.o: in function `pcl::StatisticalOutlierRemoval<pcl::PointXYZ>::applyFilter(std::vector<int, std::allocator<int> >&)':
depth_pcl.cpp:(.text._ZN3pcl25StatisticalOutlierRemovalINS_8PointXYZEE11applyFilterERSt6vectorIiSaIiEE[_ZN3pcl25StatisticalOutlierRemovalINS_8PointXYZEE11applyFilterERSt6vectorIiSaIiEE]+0x23): undefined reference to `pcl::StatisticalOutlierRemoval<pcl::PointXYZ>::applyFilterIndices(std::vector<int, std::allocator<int> >&)'
collect2: error: ld returned 1 exit status
make[2]: *** [midas_cpp/CMakeFiles/depth_pcl.dir/build.make:187: /home/ketan/MiDaS/ros/devel/lib/midas_cpp/depth_pcl] Error 1
make[1]: *** [CMakeFiles/Makefile2:2579: midas_cpp/CMakeFiles/depth_pcl.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
Invoking "make -j12 -l12" failed

From this I understand that it's not able to find the library, or the library is not linked correctly.

    cmake_minimum_required(VERSION 3.0.2)
project(midas_cpp)

find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  image_transport
  roscpp
  rospy
  sensor_msgs
  std_msgs
)

list(APPEND CMAKE_PREFIX_PATH "~/libtorch")
list(APPEND CMAKE_PREFIX_PATH "~/librealsense")
link_directories("/usr/local/include/pcl-1.13/")

list(APPEND CMAKE_PREFIX_PATH "/usr/local/include/")
list(APPEND CMAKE_PREFIX_PATH "/usr/local/lib/python3.6/dist-packages/torch/lib")
list(APPEND CMAKE_PREFIX_PATH "/usr/local/lib/python2.7/dist-packages/torch/lib")

find_package(Torch REQUIRED)
find_package(OpenCV REQUIRED)
find_package(realsense2 REQUIRED)
find_package(PCL)
find_package(pcl_ros)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})


include_directories( ${OpenCV_INCLUDE_DIRS} )
include_directories(${PCL_INCLUDE_DIRS})

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
  ${catkin_INCLUDE_DIRS}
)

add_executable(midas_cpp src/main.cpp)
target_link_libraries(midas_cpp "${TORCH_LIBRARIES}" "${OpenCV_LIBS} ${catkin_LIBRARIES}")
set_property(TARGET midas_cpp PROPERTY CXX_STANDARD 14)

add_executable(realsense2_camera src/realsense_bringup.cpp)
target_link_libraries(realsense2_camera "${OpenCV_LIBS} ${catkin_LIBRARIES}" realsense2::realsense2)
set_property(TARGET realsense2_camera PROPERTY CXX_STANDARD 14)

add_executable(camera_bringup src/camera_bringup.cpp)
target_link_libraries(camera_bringup "${OpenCV_LIBS} ${catkin_LIBRARIES}" )
set_property(TARGET camera_bringup PROPERTY CXX_STANDARD 14)


add_executable(depth_pcl src/depth_pcl.cpp)
target_link_libraries(depth_pcl "${OpenCV_LIBS} ${catkin_LIBRARIES} ${PCL_LIBRARIES}")
set_property(TARGET depth_pcl PROPERTY CXX_STANDARD 14)


#############
## Install ##
#############


#############
## Testing ##
#############

# catkin_package()

I did some google search and have tried various solutions like adding pcl_ros to find packages, adding it in package.xml, adding PCL_LIBRARIES in target_link_libraries. Nothing seems to work.

Thank for the help.

$\endgroup$

1 Answer 1

1
$\begingroup$

I found the solution, I just changed the order of arrangements in CMakeLists.txt

This is what worked for me,

# cmake_minimum_required(VERSION 3.0.2)
project(midas_cpp)

list(APPEND CMAKE_PREFIX_PATH "~/libtorch")
list(APPEND CMAKE_PREFIX_PATH "~/librealsense")
link_directories("/usr/local/include/pcl-1.13/")
link_directories("/usr/local/lib/")
list(APPEND CMAKE_PREFIX_PATH "/usr/local/include/")
list(APPEND CMAKE_PREFIX_PATH "/usr/local/lib/python3.6/dist-packages/torch/lib")
list(APPEND CMAKE_PREFIX_PATH "/usr/local/lib/python2.7/dist-packages/torch/lib")



find_package(Torch REQUIRED)
find_package(OpenCV REQUIRED)
find_package(realsense2 REQUIRED)
find_package(PCL)

find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  image_transport
  roscpp
  rospy
  sensor_msgs
  std_msgs
  PCL
)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})


include_directories( ${OpenCV_INCLUDE_DIRS} )
include_directories(${PCL_INCLUDE_DIRS})

catkin_package(
#  INCLUDE_DIRS include
 LIBRARIES midas_cpp pcl_ros_filters pcl_ros_io pcl_ros_tf
 CATKIN_DEPENDS cv_bridge image_transport roscpp sensor_msgs std_msgs pcl_ros
 DEPENDS PCL
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
  ${catkin_INCLUDE_DIRS}
)

add_executable(midas_cpp src/main.cpp)
target_link_libraries(midas_cpp "${TORCH_LIBRARIES}" "${OpenCV_LIBS} ${catkin_LIBRARIES}")
set_property(TARGET midas_cpp PROPERTY CXX_STANDARD 14)

add_executable(realsense2_camera src/realsense_bringup.cpp)
target_link_libraries(realsense2_camera "${OpenCV_LIBS} ${catkin_LIBRARIES}" realsense2::realsense2)
set_property(TARGET realsense2_camera PROPERTY CXX_STANDARD 14)

# add_executable(depth_image src/depth_image.cpp)
# target_link_libraries(depth_image "${OpenCV_LIBS} ${catkin_LIBRARIES}")
# set_property(TARGET depth_image PROPERTY CXX_STANDARD 14)


add_executable(camera_bringup src/camera_bringup.cpp)
target_link_libraries(camera_bringup "${OpenCV_LIBS} ${catkin_LIBRARIES}" )
set_property(TARGET camera_bringup PROPERTY CXX_STANDARD 14)


# add_executable(depth2cloud src/depth2cloud.cpp)
# target_link_libraries(depth2cloud "${OpenCV_LIBS} ${catkin_LIBRARIES}")
# set_property(TARGET depth2cloud PROPERTY CXX_STANDARD 14)

message("${PCL_LIBRARIES}")
add_executable(depth_pcl src/depth_pcl.cpp)
target_link_libraries(depth_pcl "${OpenCV_LIBS} ${catkin_LIBRARIES}")
$\endgroup$
2
  • $\begingroup$ If you add pcl_ros to your find_package(catkin REQUIRED COMPONENTS you can remove all the PCL related stuff, like DEPENDS PCL, add_definitions(${PCL_DEFINITIONS}) and include_directories(${PCL_INCLUDE_DIRS}) as catkin would do that for you $\endgroup$
    – ignacio
    Commented Oct 6, 2023 at 7:19
  • $\begingroup$ Go it. Thanks!! $\endgroup$
    – lonewolf
    Commented Oct 12, 2023 at 4:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.