本文将简要介绍如何安装以及在Visual Studio中配置OpenCV
使用环境
Windows 11 专业版
Visual Studio 2022 Community
OpenCV 4.9.0
安装OpenCV
官方Github:https://github.com/opencv/opencv/releases/download/4.9.0/opencv-4.9.0-windows.exe
添加环境变量
在VS项目属性中要添加的
注意:
Debug模式选择:opencv_world490d.lib
Release模式选择:opencv_world490.lib
测试代码
#include <opencv2\opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main()
{
VideoCapture capture;
capture.open(0);
Mat frame;
while (true)
{
capture >> frame;
imshow("摄像头图像", frame);
if (waitKey(30))
break;
}
return 0;
}