opencv配置安装
opencv配置安装
1、安装方式
https://blog.csdn.net/qq_45022687/article/details/120241068
根据这个网址的配置进行安装
2、解编译
-
mutex/thread等
似乎因为mingw的问题,#include 等直接引入线程无法直接引用,这导致了原有代码中直接使用mutex/thread的部分需要修改
https://blog.csdn.net/qq_41940001/article/details/127319079
-
opengl未成功链入
-
问题描述
-
解决过程
-
尝试在出问题的文件中,添加头文件
#include <windows.h>
,解决参考:https://blog.csdn.net/zhongjling/article/details/7535585
-
-
-
重复定义
-
问题描述
-
解决过程
在同一个文件中定义了同一个宏定义,在对应的定义和使用的地方做相应的修改
-
-
返回类型不完全
-
问题描述
-
解决过程
把有问题的函数全部注释了
-
-
ERROR: Unable to start debugging. Unexpected GDB output from command “-exec-run”. During startup program exited with code 0xc0000135.
-
问题描述
-
解决过程
https://blog.csdn.net/flyaaa123/article/details/125069936
调整
mingw/bin
在环境变量中的相对位置
-
3、文档配置
1)launch.json
{"version": "0.2.0","configurations": [{"name": "Python: Current File","type": "python","request": "launch","program": "${file}","python": "D:\\\\BasicSetting\\\\python\\\\python.exe","args": ["--source"]},{"name": "(gdb) Launch", // 配置名称,将会在启动配置的下拉菜单中显示 "type": "cppdbg", // 配置类型,这里只能为cppdbg "request": "launch", // 请求配置类型,可以为launch(启动)或attach(附加) "program": "${workspaceFolder}/exe/${fileBasenameNoExtension}.exe", // 将要进行调试的程序的路径 "args": [], // 程序调试时传递给程序的命令行参数,一般设为空即可 "stopAtEntry": false, // 设为true时程序将暂停在程序入口处,一般设置为false "cwd": "${workspaceFolder}", // 调试程序时的工作目录,一般为${workspaceFolder}即代码所在目录 "environment": [],"externalConsole": false, // true则弹出终端,false会在下方terminal直接输出"MIMode": "gdb",// 这里的路径需要修改。改成自己的路径"miDebuggerPath": "D:/BasicSetting/mingw64/bin/gdb.exe","preLaunchTask": "g++", // 调试会话开始前执行的任务,一般为编译程序,c++为g++, c为gcc "setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}]}]
}
2)c_cpp_properties.json
{"configurations": [{"name": "Win32","includePath": ["${workspaceRoot}",// 以下7行需要修改 "D:/BasicSetting/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++","D:/BasicSetting/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32","D:/BasicSetting/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward","D:/BasicSetting/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include","D:/BasicSetting/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed","D:/BasicSetting/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include","D:/BasicSetting/protoc-21.9-win64/include","D:/BasicSetting/opencv/build/x64/mingw/install/include"],"defines": ["_DEBUG","UNICODE","__GNUC__=6","__cdecl=__attribute__((__cdecl__))"],"intelliSenseMode": "msvc-x64","browse": {"limitSymbolsToIncludedHeaders": true,"databaseFilename": "","path": ["${workspaceRoot}",// 以下7行需要修改 "D:/BasicSetting/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++","D:/BasicSetting/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32","D:/BasicSetting/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward","D:/BasicSetting/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include","D:/BasicSetting/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed","D:/BasicSetting/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include","D:/BasicSetting/protoc-21.9-win64/include","D:/BasicSetting/opencv/build/x64/mingw/install/include"]}}],"version": 4
}
3)tasks.json
{"version": "2.0.0","command": "g++","args": ["-g","${file}","-o","${workspaceFolder}/exe/${fileBasenameNoExtension}.exe","-std=c++17","D:/BasicSetting/opencv/build/x64/mingw/bin/libopencv_world460.dll","-I","D:/BasicSetting/opencv/build/x64/mingw/install/include"// "-lprotobuf -lpthread"],"problemMatcher": {"owner": "cpp","fileLocation": ["relative","\\\\"],"pattern": {"regexp": "^(.*):(\\\\d+):(\\\\d+):\\\\s+(warning|error):\\\\s+(.*)$","file": 1,"line": 2,"column": 3,"severity": 4,"message": 5}},"tasks": [{"type": "cppbuild","label": "C/C++: g++.exe 生成活动文件","command": "D:\\\\BasicSetting\\\\mingw64\\\\bin\\\\g++.exe","args": ["-fdiagnostics-color=always","-g","${file}","-o","${fileDirname}\\\\${fileBasenameNoExtension}.exe","D:/BasicSetting/opencv/build/x64/mingw/bin/libopencv_world460.dll","-I","D:/BasicSetting/opencv/build/x64/mingw/install/include"],"options": {"cwd": "${fileDirname}"},"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true},"detail": "调试器生成的任务。"}]
}
4、安装编译mediapipe
1)python下载mediapipe
-
pip install mediapipe
-
下载mediapipe库
-
地址:https://pypi.org/project/mediapipe/#files
-
命令:
pip install --user mediapipe-0.8.9.1-cp310-cp310-win_amd64.whl
安装失败了……
-
opencv-contrib-python
-
opencv-contrib-python
-
下载资源包
-
地址:https://pypi.tuna.tsinghua.edu.cn/packages/b2/b8/d5c14d6a0b1d898f7fe273de9b41f84dd94a5cc4c816a32da300fc70a1d5/opencv_contrib_python-4.7.0.68-cp37-abi3-win_amd64.whl#sha256=7a75f1775790106e54bcfb101c0e00e1f801a57d9baebc82d0b6758fc83a4ca0
-
pip install --user opencv_contrib_python-4.7.0.68-cp37-abi3-win_amd64.whl
-
安装成功
-
-
-
再次安装mediapipe
-
2) c++安装
-
MSYS2安装
-
下载地址:https://www.msys2.org
-
安装
-
配置环境变量
地址:
D:\\Setting\\msys64\\usr\\bin
-
升级msys2包数据库
pacman -Syu
-
下载unzip
MSYS2没有内置unzip,需要手动安装
pacman -S git patch unzip
-
-
python配置
装过了
-
安装VS2019和WinSDK
VS官网:https://aka.ms/vs/17/release/vs_BuildTools.exe
-
配置Bazel
-
地址:https://github.com/bazelbuild/bazel/releases/download/5.2.0/bazel-5.2.0-windows-x86_64.exe
-
移动到目的位置,并修改为bazel.exe
-
修改环境变量
set BAZEL_VS=D:\\Software\\Microsoft Visual Studio\\2022\\Community set BAZEL_VC=D:\\Software\\Microsoft Visual Studio\\2022\\Community\\VC set BAZEL_VC_FULL_VERSION=14.34.31938.0 set BAZEL_WINSDK_FULL_VERSION=10.1.22000.832
-
设置Bazel变量
-
-
mediapipe仓库克隆及bazel的编译文件WORKSPACE的修改
-
git clone https://github.com/google/mediapipe.git
-
设置opencv地址-WORKSPACE
-
设置open_windows.BUILD
-
-
编译
切换打破media仓库目录,运行:
bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 --action_env PYTHON_BIN_PATH="D:\\\\Setting\\\\Python\\\\python.exe" mediapipe/examples/desktop/hello_world
-
执行
set GLOG_logtostderr=1
bazel-bin\\mediapipe\\examples\\desktop\\hello_world\\hello_world.exe