在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;
}
}
本文介绍了一个在Visual Studio 2017中使用OpenCV 3.2进行摄像头图像捕获时遇到的黑屏问题及解决方案。通过调整代码实现了正确显示摄像头画面。
1864

被折叠的 条评论
为什么被折叠?



