pcl和opencv多版本共存
在Ubuntu 16.04系统下安装kinetic版本ROS, 会默认安装opencv 3.3.1
和pcl1.7
.
- opencv安装路径
/opt/ros/kinetic/
- pcl安装路径
/usr/
如果想安装opencv2.4版本,或者安装pcl 1.8版本,那么如何设置安装路径,同时在CMakeLists中调用版本。
- opencv 2.4
首先从github上下载相应版本的release压缩包
cd opencv-2.4
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/opencv-2.4 -DOPENCV_EXTRA_MODULES_PATH=path to opencv_contrib-3.2.0/modules/ ..
make -j4
sudo make install -j4
注:如果不设置-DCMAKE_INSTALL_PREFIX
则默认安装位置为: /usr/local/
在CMakeLists.txt
设置,主要是设置OpenCVConfig.cmake
的路径。
set(OpenCV_DIR "/usr/local/opencv-2.4/share/OpenCV/")
find_package(OpenCV)
include_directories(${OpenCV_INCLUDE_DIRS})
link_directories(${OpenCV_LIBRARY_DIRS})
add_definitions(${OpenCV_DEFINATIONS})
- pcl 1.8
首先从github上下载相应版本的release压缩包
cd pcl-1.8
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/pcl-1.8 -DBUILD_GPU=ON -DBUILD_apps=ON -DBUILD_examples=ON ..
make -j4
sudo make install -j4
在CMakeLists.txt
设置,主要是设置PCLConfig.cmake
的路径。
set(PCL_DIR "/usr/local/pcl-1.8/share/pcl-1.8")
find_package(PCL 1.8 REQUIRED COMPONENTS)
include_directiories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definations(${PCL_DEFINATIONS})
注: 依赖库安装没有介绍
- 参考: https://blog.csdn.net/m0_37579176/article/details/83344698