Visual Studio Code - 1.46.1
openCV - 3.4.5
MinGW-W64-builds-4.3.5
cmake - 3.9.0 (提取码 85uw )
OpenCV下载
楼主百度云 提取码:ko47
D:\mingw64\bin
cmake下载 提取码:u7vg
4.1添加环境变量-系统变量
D:\Download\cmake-3.9.0-rc3-win64-x64\bin
4.2运行cmake-gui.exe
配置路径:where is the source code、where to build the binaries
点击 configure 按钮,按照下图所示进行选择
4.3选择 MinGW 中的 C 和 C++ 编译的exe程序
设置完毕点击 Finish,耐心等待进度条读完,直到输出窗口看到 Configuring done。再次点击 Configure 等待进度条读完。之后点击Generate 等待进度条读完,出现 Generating done。
如果没有配置Opencv源文件中的ffmpeg文件,则会出现报错信息
解决办法如下:根据报错信息提供的相关文件的下载地址,手动下载相关文件到Opencv源代码的ffmpeg文件夹中,如下所示:
手动下载相关文件到Opencv源代码的ffmpeg文件夹中
可以看到 opencv\build\x64\mingw 的文件夹下新增了好多东西:
在dos框里,利用 cd 命令 切换到 opencv\build\x64\mingw
输入 minGW32-make 命令,这个时候大概花费 40 分钟左右的时间来编译,
minGW32-make
编译完成之后,输入 minGW32-make install 来完成装载。
minGW32-make install
最后,配置环境变量 path :
D:\Download\opencv\build\x64\mingw\bin
将运行调试后文件修改成以下内容,路径需要相应匹配~
6.1 在建立的.cpp文件对应的launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "opencv3.4.5 debuge",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "D:\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": false
}
],
"preLaunchTask": "opencv3.4.5 compile task"
}
]
}
6.2 在建立的.cpp文件对应的c_cpp_properties.json
{
"configurations": [
{
"name": "win32",
"includePath": [
"${workspaceFolder}/**",
"D:/Download/opencv/build/include",
"D:/Download/opencv/build/include/opencv2",
"D:/Download/opencv/build/include/opencv"
],
"defines": [],
"compilerPath": "D:\\mingw64\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
6.3 在建立的.cpp文件对应的tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "opencv3.4.5 compile task",
"type": "shell",
"command": "D:\\mingw64\\bin\\g++.exe",
"args": [ "-g", "${file}","-o","${workspaceFolder}\\${fileBasenameNoExtension}.exe",
"-I","D:/Download/opencv/build/include",
"-I","D:/Download/opencv/build/include/opencv2",
"-I","D:/Download/opencv/build/include/opencv",
"-L","D:/Download/opencv/build/x64/mingw/install/x64/mingw/bin/lib*",
],
"options": {
"cwd": "D:\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
1.将 VSCode 打造成 OpenCV 的 IDE(C++,window10 1803)
2.Windows10下Opencv4+CMake+MinGW64+VSC安装教程
3.CMake编译OpenCV4.0时opencv_ffmpeg.dll等下载失败的解决思路总结