原创VisualStudio2022配置OpenCV4(详细、简介、有效)
opencv
OpenCV: 开源计算机视觉库
项目地址:https://gitcode.com/gh_mirrors/opencv31/opencv
免费下载资源
·
系统和准备
很多人在正常操作过后就是不成功,所以我把最重要的部分放在最前面,按照如下操作基本不会翻车
win10
visualstudio2022
opencv 4.5.0下载地址
运行.exe得到如下文件夹
- 配置环境变量(vs2017及以上版本都选择D:\opencv4.5.0\opencv\build\x64\vc15\bin)添加到编辑系统环境变量->环境变量->系统变量的path中就行,网上有人添加一大堆大可不必。
- 进行非常关键的操作如下
- 复制下面三个dll文件
- 复制到C:\Windows\System32
- 打开属性管理器方便后续配置
- 确定自己更改为是debug x64 非常关键
- 上面步骤完成基本后续不会有任何问题。
VS中配置OpenCV过程
-
点击属性管理器->debugx64->添加新项目属性表,直接取个名字确定就行
-
添加完成后,会看到自己的属性表,右键设置属性,即对新建的属性表添加属性。
-
VC++目录->包含目录->编辑添加D:\opencv4.5.0\opencv\build\include\opencv2和D:\opencv4.5.0\opencv\build\include
-
在通用属性–>VC++目录–>库目录中,同样的方法添加 D:\opencv4.5.0\opencv\build\x64\vc15\lib
-
复制这个名称添加到链接器–>输入–>附加依赖项,xxxxd代表debug版本如果你使用Release请把d删除,或者将两个名字都添加
-
点击应用和确定
测试
#include <iostream>
#include <fstream>
#include <string>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
using namespace cv;
using namespace std;
int main(){
Mat srcImg = imread("C:\\Users\\DELL\\Desktop\\1.png");
if (srcImg.empty()) {
cout << "could not load image..." << endl;
return -1;
}
imshow("opencv", srcImg);
waitKey(0);}
下次使用重复使用配置
在项目中,可以看到生成了一个opencv4.props就是属性管理器的属性表,下次新建一个项目直接添加现有属性表找到这个文件就可以不用重新配置环境啦!!
参考
https://blog.csdn.net/m0_37360684/article/details/89716881
7.21更新如何将配置好的程序发送给他人且不用重新配环境
1.目前复制三个dll文件是不可获取的步骤,这个需要我们打包好练程序一起发给对方
2.将opencv文件夹放到项目目录中
3.将所有路径改为如下相对路径
GitHub 加速计划 / opencv31 / opencv
142
15
下载
OpenCV: 开源计算机视觉库
最近提交(Master分支:3 个月前 )
d9a139f9
Animated WebP Support #25608
related issues #24855 #22569
### Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
1 天前
09030615
V4l default image size #25500
Added ability to set default image width and height for V4L capture. This is required for cameras that does not support 640x480 resolution because otherwise V4L capture cannot be opened and failed with "Pixel format of incoming image is unsupported by OpenCV" and then with "can't open camera by index" message. Because of the videoio architecture it is not possible to insert actions between CvCaptureCAM_V4L::CvCaptureCAM_V4L and CvCaptureCAM_V4L::open so the only way I found is to use environment variables to preselect the resolution.
Related bug report is [#25499](https://github.com/opencv/opencv/issues/25499)
Maybe (but not confirmed) this is also related to [#24551](https://github.com/opencv/opencv/issues/24551)
This fix was made and verified in my local environment: capture board AVMATRIX VC42, Ubuntu 20, NVidia Jetson Orin.
### Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
- [X] I agree to contribute to the project under Apache 2 License.
- [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [X] The PR is proposed to the proper branch
- [X] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
1 天前
更多推荐
已为社区贡献2条内容
所有评论(0)