CMakeLists中配置不同opencv版本的记录

cmake中opencv指定的问题

在Ubuntu系统中,可能会同时安装opencv3和opencv4的版本情况,在编译结束后,假设opencv3安装路径在/usr/local中,opencv4安装路径在/usr中。
如果CMakeList文件中需要find_package opencv4的情况,可以填写一下配置内容:

...
set(OpenCV_DIR /usr/lib/cmake/opencv4)  # 设置opencv4的OpenCVConfig.cmake文件
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
message(STATUS "Opencv_include_Path: " ${OpenCV_INCLUDE_DIRS})
message(STATUS "Opencv_Library_Path: " ${Opencv_LIBRARIES})

如果CMakeList文件中需要find_package opencv3的情况,可以填写一下配置内容:

...
set(OpenCV_DIR /usr/local/share/OpenCV)  # 设置opencv3的OpenCVConfig.cmake文件
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
message(STATUS "Opencv_include_Path: " ${OpenCV_INCLUDE_DIRS})
message(STATUS "Opencv_Library_Path: " ${Opencv_LIBRARIES})
...

你可能感兴趣的:(机器人,opencv,计算机视觉,python)