ubuntu环境中使用clion编译opencv samples

1.下载opencv源码

2.使用clion直接加载opencv根目录下的cmakelist.txt

3.在opencv根目录下建文件夹cmakebuild,并在clion加载的cmake-build-debug文件夹中打开终端,使用ccmake . 命令查看需要修改的项,根据提示使用按键进行 configure和generate;

4. 把opencv_root/samples/CMakeLists.txt中的find_package(OpenCV REQUIRED PATHS "..")修改为:find_package(OpenCV REQUIRED PATHS "opencv_root/cmake-build-debug");

5. 使用clion,右键opencv_root/samples/CMakeLists.txt,选择Load cmake project即可;

6. 若使用opencl,自己没有编译或者下载opencl-sdk,则修改如下:

在opencv_root/samples/opencl/CMakeLists.txt中添加

set(OpenCL_INCLUDE_DIR_ "/usr/local/cuda-10.1/targets/x86_64-linux")
set(OpenCL_LIBRARY_ "/usr/local/cuda-10.1/targets/x86_64-linux")
include_directories(${OpenCL_INCLUDE_DIR_}/include)
link_directories(${OpenCL_LIBRARY_}/lib)

把原来的find_package(OpenCL 1.2 QUIET)注释掉即可。

你可能感兴趣的:(opencv,ubuntu,opencv,python)