wangmj@wangmj:~$ pkg-config opencv --libs
-L/usr/local/lib -lopencv_stitching -lopencv_highgui -lopencv_superres -lopencv_viz -lopencv_shape -lopencv_objdetect -lopencv_ml -lopencv_dnn -lopencv_videostab -lopencv_calib3d -lopencv_videoio -lopencv_imgcodecs -lopencv_features2d -lopencv_photo -lopencv_flann -lopencv_video -lopencv_imgproc -lopencv_core
可以看到我的opencv库安装在/usr/local/lib
路径下。
wangmj@wangmj:~$ pkg-config opencv --modversion
3.4.11
可以看到我的电脑上装的是3.4.11版本的opencv。
wangmj@wangmj:~$ sudo find / -iname "*opencv*"
[sudo] password for wangmj:
find: ‘/proc/31041’: No such file or directory
/usr/include/opencv2
/usr/include/opencv2/opencv_modules.hpp
/usr/include/opencv2/opencv.hpp
/usr/include/opencv
/usr/local/lib/libopencv_flann.so.3.4.11
/usr/local/lib/libopencv_photo.so.3.4
/usr/local/lib/libopencv_highgui.so.3.4.11
/usr/local/lib/libopencv_highgui.so.3.4
/usr/local/lib/libopencv_viz.so
/usr/local/lib/libopencv_stitching.so.3.4
/usr/local/lib/libopencv_imgproc.so.3.4
/usr/local/lib/libopencv_dnn.so.3.4
/usr/local/lib/libopencv_videostab.so
/usr/local/lib/libopencv_highgui.so
/usr/local/lib/libopencv_videostab.so.3.4
/usr/local/lib/libopencv_shape.so
/usr/local/lib/libopencv_video.so.3.4.11
/usr/local/lib/libopencv_videoio.so
/usr/local/lib/libopencv_imgcodecs.so.3.4
/usr/local/lib/libopencv_objdetect.so
/usr/local/lib/libopencv_ml.so.3.4.11
/usr/local/lib/libopencv_features2d.so
/usr/local/lib/libopencv_videoio.so.3.4
/usr/local/lib/libopencv_video.so.3.4
/usr/local/lib/libopencv_flann.so
/usr/local/lib/libopencv_stitching.so.3.4.11
/usr/local/lib/libopencv_features2d.so.3.4
/usr/local/lib/libopencv_superres.so
/usr/local/lib/libopencv_videoio.so.3.4.11
/usr/local/lib/libopencv_ml.so
/usr/local/lib/libopencv_features2d.so.3.4.11
/usr/local/lib/libopencv_viz.so.3.4.11
/usr/local/lib/libopencv_objdetect.so.3.4
/usr/local/lib/libopencv_photo.so
/usr/local/lib/libopencv_dnn.so
/usr/local/lib/libopencv_dnn.so.3.4.11
/usr/local/lib/libopencv_calib3d.so
/usr/local/lib/libopencv_video.so
/usr/local/lib/libopencv_imgcodecs.so
/usr/local/lib/libopencv_imgcodecs.so.3.4.11
/usr/local/lib/libopencv_viz.so.3.4
/usr/local/lib/pkgconfig/opencv.pc
/usr/local/lib/libopencv_flann.so.3.4
/usr/local/lib/libopencv_stitching.so
/usr/local/lib/libopencv_superres.so.3.4.11
/usr/local/lib/libopencv_calib3d.so.3.4.11
/usr/local/lib/libopencv_core.so
/usr/local/lib/libopencv_calib3d.so.3.4
/usr/local/lib/libopencv_shape.so.3.4
/usr/local/lib/libopencv_ml.so.3.4
/usr/local/lib/libopencv_imgproc.so
/usr/local/lib/libopencv_core.so.3.4
/usr/local/lib/libopencv_photo.so.3.4.11
/usr/local/lib/libopencv_shape.so.3.4.11
/usr/local/lib/libopencv_core.so.3.4.11
/usr/local/lib/libopencv_objdetect.so.3.4.11
/usr/local/lib/libopencv_superres.so.3.4
/usr/local/lib/libopencv_imgproc.so.3.4.11
/usr/local/lib/libopencv_videostab.so.3.4.11
/usr/local/include/opencv2
/usr/local/include/opencv2/opencv_modules.hpp
/usr/local/include/opencv2/opencv.hpp
/usr/local/include/opencv
/usr/local/share/licenses/opencv3
/usr/local/share/OpenCV
/usr/local/share/OpenCV/OpenCVConfig.cmake
/usr/local/share/OpenCV/OpenCVConfig-version.cmake
/usr/local/share/OpenCV/OpenCVModules-release.cmake
/usr/local/share/OpenCV/OpenCVModules.cmake
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_plot3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_objdetect3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_optflow3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_phase_unwrapping3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_phase_unwrapping3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_viz3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_imgcodecs3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_viz3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_shape3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_videoio3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_tracking3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_xfeatures2d3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_datasets3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_core3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_xphoto3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_fuzzy3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_xphoto3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_features2d3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_ml3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_rgbd3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_stereo3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_videostab3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_text3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_plot3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_aruco3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_ccalib3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_stitching3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_text3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_fuzzy3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_datasets3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_flann3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_rgbd3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_flann3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_highgui3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_optflow3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_tracking3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_xobjdetect3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_photo3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_superres3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_videoio3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_structured_light3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_hdf3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_features2d3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_core3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_hdf3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_superres3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_surface_matching3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_objdetect3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_ximgproc3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_ccalib3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_cvv3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_face3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_flann3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_ximgproc3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_viz3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_ml3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_rgbd3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_xobjdetect3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_saliency3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_superres3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_bioinspired3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_imgcodecs3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_dpm3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_objdetect3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_dnn3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_structured_light3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_imgproc3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_cvv3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_photo3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_optflow3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_videostab3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_video3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_img_hash3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_saliency3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_bgsegm3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_bgsegm3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_img_hash3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_imgproc3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_imgcodecs3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_video3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_tracking3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_calib3d3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_dnn3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_reg3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_reg3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_stitching3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_line_descriptor3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/pkgconfig/opencv-3.3.1-dev.pc
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_surface_matching3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_aruco3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_text3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_bioinspired3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_img_hash3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_line_descriptor3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_reg3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_hdf3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_highgui3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_surface_matching3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_features2d3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_imgproc3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_ximgproc3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_core3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_cvv3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_bgsegm3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_face3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_structured_light3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_calib3d3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_xfeatures2d3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_xphoto3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_photo3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_ccalib3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_videostab3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_stereo3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_stereo3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_plot3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_fuzzy3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_shape3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_stitching3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_highgui3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_saliency3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_video3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_face3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_shape3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_ml3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_phase_unwrapping3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_line_descriptor3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_bioinspired3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_aruco3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_xobjdetect3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_xfeatures2d3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_dpm3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_calib3d3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_videoio3.so.3.3
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_dpm3.so
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_dnn3.so.3.3.1
/opt/ros/kinetic/lib/x86_64-linux-gnu/libopencv_datasets3.so
/opt/ros/kinetic/include/opencv-3.3.1-dev
/opt/ros/kinetic/include/opencv-3.3.1-dev/opencv2
/opt/ros/kinetic/include/opencv-3.3.1-dev/opencv2/opencv_modules.hpp
/opt/ros/kinetic/include/opencv-3.3.1-dev/opencv2/opencv.hpp
/opt/ros/kinetic/include/opencv-3.3.1-dev/opencv
/opt/ros/kinetic/share/vision_opencv
/opt/ros/kinetic/share/opencv3
/opt/ros/kinetic/share/OpenCV-3.3.1-dev
/opt/ros/kinetic/share/OpenCV-3.3.1-dev/OpenCVConfig.cmake
/opt/ros/kinetic/share/OpenCV-3.3.1-dev/OpenCVConfig-version.cmake
/opt/ros/kinetic/share/OpenCV-3.3.1-dev/OpenCVModules-release.cmake
/opt/ros/kinetic/share/OpenCV-3.3.1-dev/OpenCVModules.cmake
可以看到我的电脑上有两个版本的opencv,一个是我用opencv源码安装的3.4.11版本的(在/usr/local/lib
目录下),一个是ros kinetic自动安装的3.3.1版本的(在/opt/ros/kinetic
目录下)。如果不指定版本,cmake会自动链接3.3.1版本的opencv库,由于此版本较低,好多模块不全,比如dnn模块就不包含,会造成程序运行错误,因此需要链接指定新版本的opencv库。
源码分布情况
├── CMakeLists.txt
├── src
│ └── rs_depth_test.cc
└── build
find_package使用简介
cmake本身不提供任何关于搜索库的便捷方法,也不会对库本身的环境变量进行设置。它仅仅是按照优先级顺序在指定的搜索路径进行查找FindOpencv.cmake
文件和OpenCVConfig.cmake
文件(特别注意的是有大小写之分),cmake能够找到这两个文件中的任何一个,都能成功使用该库。当我们在cmake..
命令之后,cmake 会读取执行CMakeLists.txt
中的代码,当执行find_package()
这条命令后,cmake 就会从某些路径中找FindOpencv.cmake
文件或者OpenCVConfig.cmake
文件,cmake找到任意一个之后就会执行这个文件,然后这个文件执行后就会设置好一些cmake变量。
一般常用的就是OpenCV_FOUND 、OpenCV_INCLUDE_DIRS、OpenCV_LIBS
,分别代表是否找到库的标志、库的头文件路径、库文件路径。find_package()
有两种模式:Module模式和Config模式,分别对应上面的FindOpencv.cmake
文件和OpenCVConfig.cmake
文件。cmake默认优先Module模式,而Config模式是备选项。
Module模式(仅仅查找Findxxx.cmake文件):
cmake会优先搜索CMAKE_MODULE_PATH
指定的路径,如果在CMakeLists.txt中没有设置CMAKE_MODULE_PATH
为存储Findxxx.cmake
的路径,也就是说没有下面的指令:
set(CMAKE_MODULE_PATH "Findxxx.cmake文件所在的路径")
,那么cmake不会搜索CMAKE_MODULE_PATH
指定的路径,此时cmake会搜索第二优先级的路径,也就是
。其中CMAKE_ROOT
是你在安装cmake的时候的系统路径,因为我并没有指定安装路径,所以是系统默认的路径,在我的系统中(ubuntu16.04)系统的默认路径是/usr/loacl
,如果你在安装的过程中使用了
cmake -DCMAKE_INSTALL_PREFIX=自己dir路径
,那么此时CMAKE_ROOT
就代表那个你写入的路径 。刚刚说道第一优先级的路径搜索没有找到Findxxx.cmake
文件,就会到第二优先级的路径下搜索。如果cmake在两个路径下都没有找到Findxxx.cmake文件。那么cmake就会进入Config模式。
Config模式(仅仅查找xxxConfig.cmake文件):
cmake会优先搜索xxx_DIR
指定的路径。如果在CMakeLists.txt
中没有设置这个cmake变量。也就是说没有下面的指令:
set(xxx_DIR "xxxConfig.cmkae文件所在的路径")
,那么cmake就不会搜索xxx_DIR
指定的路径,此时cmake 就会自动到第二优先级的路径下搜索,也就是/usr/local/lib/cmake/xxx/
中的xxxConfig.cmake
文件。
CMakeLists.txt 文件
# 规定cmake最低版本
cmake_minimum_required(VERSION 3.1.0)
# project中的CXX指的是C++,如果不特别指定,则支持所有语言,项目名称一般和项目文件夹对应
project(pallet_test CXX)
# 指定 c++ 标准
set(CMAKE_CXX_STANDARD 11)
# 添加opencv库
# 1、指定opencv版本,找到3.4.11版本的opencv
find_package(OpenCV 3.4.11 REQUIRED)
# 2、如果不需要指定opencv版本,找到默认ROS下3.3.1版本的opencv
# find_package(OpenCV REQUIRED)
# 添加OpenCV头文件
include_directories(${OpenCV_INCLUDE_DIRS})
# 打印OpenCV_INCLUDE_DIRS的值
message(${OpenCV_INCLUDE_DIRS})
# 生成可执行文件
add_executable(rs_depth_test src/rs_depth_test.cc)
# 将库文件链接到可执行程序上,我用到了D435相机,所以这里还链接了realsense库文件librealsense2.so.2.38
target_link_libraries( rs_depth_test ${OpenCV_LIBS} /usr/local/lib/librealsense2.so.2.38)
find_package(OpenCV 3.4.11 REQUIRED)
中的OpenCV
一定要遵循该大小写,这句话会在Ubuntu系统中OpenCV
安装目录按照指定顺序找到FindOpencv.cmake
和OpenCVConfig.cmake
文件,找到这两个文件中的任何一个,我们都能成功使用该库,进而确定你要引入的opencv头文件和库函数在哪里。该文件定义了OpenCV_FOUND
、OpenCV_INCLUDE_DIRS
和OpenCV_LIBS
等变量,分别代表是否找到库的标志、库的头文件路径、库文件路径。可以使用 include_directories
和target_link_libraries
来访问这两个变量。
可以通过打开终端输入locate OpenCVConfig.cmake
来找到这个.cmake
文件,用以确认系统确实安装了OpenCV
。
wangmj@wangmj:~/pallet_test$ locate OpenCVConfig.cmake
/home/wangmj/opencv-3.4.11/build/OpenCVConfig.cmake
/home/wangmj/opencv-3.4.11/build/unix-install/OpenCVConfig.cmake
/home/wangmj/opencv-3.4.11/cmake/templates/OpenCVConfig.cmake.in
/opt/ros/kinetic/share/OpenCV-3.3.1-dev/OpenCVConfig.cmake
/usr/local/share/OpenCV/OpenCVConfig.cmake
本人没有使用这种方法,可参考此此链接。
wangmj@wangmj:~/pallet_test$ cd build/
wangmj@wangmj:~/pallet_test/build$ cmake ..
-- The CXX compiler identification is GNU 5.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenCV: /usr/local (found suitable version "3.4.11", minimum required is "3.4.11")
/usr/local/include/usr/local/include/opencv
-- Configuring done
-- Generating done
-- Build files have been written to: /home/wangmj/pallet_test/build
wangmj@wangmj:~/pallet_test/build$ make
Scanning dependencies of target rs_depth_test
[ 50%] Building CXX object CMakeFiles/rs_depth_test.dir/src/rs_depth_test.cc.o
[100%] Linking CXX executable rs_depth_test
[100%] Built target rs_depth_test
wangmj@wangmj:~/pallet_test/build$ ./rs_depth_test
参考1
参考2
参考3