好奇的探索者,理性的思考者,踏实的行动者。
Table of Contents:
设置文件夹目录 D:\program\opencv\build\include
设置库文件目录 D:\program\opencv\build\x64\vc15\lib
添加lib库 opencv_world460d.lib
设置环境变量 D:\program\opencv\build\x64\vc15\bin
使用cmake+mingw编译opencv的源码
在vscode中用cmake插件生成工程并编译
C++
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include<iostream>
using namespace std;
using namespace cv;
int main()
{"C:/Users/sunxv/Desktop/aa.png");
Mat image = imread("Show Window", image);
imshow(0);
waitKey(return 0;
}
cmakelists
cmake_minimum_required(VERSION 3.0.0)
project(cvTest VERSION 0.1.0)
# message("$ENV{PATH}")
# 设置OpenCVConfig.cmake所在路径
set(OpenCV_DIR D://program//opencv//build-mingw//install//x64//mingw//lib)
find_package(OpenCV REQUIRED)
message("=============================")
message("${OpenCV_INCLUDE_DIRS}")
message("${OpenCV_LIBS}")
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(cvTest main.cpp)
target_link_libraries(cvTest ${OpenCV_LIBS})