opencv3.3+vs2015调用笔记本摄像头成功

时间:2024-04-30 14:18:16

先上代码

成功图片如下:

opencv3.3+vs2015调用笔记本摄像头成功

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
using namespace cv;
int main()
{
VideoCapture cap();
if (!cap.isOpened())
{
return -;
}
Mat frame;
Mat edges;
bool stop = false;
while (!stop)
{
cap >> frame;
cvtColor(frame, edges, CV_BGR2GRAY);
GaussianBlur(edges, edges, Size(, ), 1.5, 1.5);
Canny(edges, edges, , , );
imshow("当前视频", edges);
if (waitKey() >= )
stop = true;
}
return ;
}

前提是你已经正确配置了opencv和vs2015