Windows下Clion+OpenCV开发环境搭建

Posted on 2020-10-22  13 Views


准备

步骤

  1. 安装Clion
  2. 安装MinGW并将MinGW\bin添加到环境变量
  3. 安装CMake
  4. 解压OpenCV源码
  5. 打开CMake,在第一个框中打开源码目录,第二个框为编译目录,点击Configure
    再次点击Configure红色消失

    点击Generate
  6. 打开CMD进入到MinGW-build目录下,执行mingw32-make
  7. 上一步执行完成后执行mingw32-make install,生成install文件夹

Clion中使用OpenCV

  • Clion设置
  • CMakeLists.txt文件配置
cmake_minimum_required(VERSION 3.17)
project(test)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(OpenCV_DIR "C:\\OpenCV")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
find_package(OpenCV)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(test camera_calibration_correct.cpp)
set(OpenCV_LIBS opencv_core opencv_imgproc opencv_highgui opencv_imgcodecs)
target_link_libraries(test ${OpenCV_LIBS})

粉色的花瓣,美丽地缠绕在身上。依在风里。