# 准备
- Clion
- MinGW
- Cmake
- OpenCV
# 步骤
安装 Clion
安装 MinGW 并将 MinGW\bin 添加到环境变量
安装 CMake
解压 OpenCV 源码
打开 CMake, 在第一个框中打开源码目录,第二个框为编译目录,点击 Configure
再次点击 Configure 红色消失
点击 Generate
打开 CMD 进入到 MinGW-build 目录下,执行 mingw32-make
上一步执行完成后执行 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})