在VS2017配置好opencv3.2后测试了一段代码,刚开始的代码运行后出现黑屏的现象,在查阅网上资料后修改了代码可以正常显示。
#include <stdafx.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace std;
using namespace cv;
void main()
{
Mat input_image;
VideoCapture cam(0);
if (!cam.isOpened()) exit(0);
namedWindow("摄像头");
while (true) {
cam >> input_image;
imshow("input image", input_image);
if (27 == waitKey(30))
break;
}
}