opencv中打开摄像头显示黑屏

<span style="font-size:18px;">搞图像处理时,在QT编程环境下配置了opencv3.0版本。之后尝试打开笔记本摄像头,程序运行之后窗口一直是黑屏。看网上有人说是opencv的库函数的问题。经过尝试,终于如愿打开摄像头显示。源码如下:<span style="color:#cc0000;">(百度贴过来的,十分感谢作者的帮助。)</span></span>
<span style="font-size:18px;">
</span>
<span style="font-size:18px;">#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("input image");
    while(true) {
        cam >> input_image;
        imshow("input image", input_image);
        if(27 == waitKey(30))
            break;
    }
}</span>
原网址:http://zhidao.baidu.com/link?url=lU2N3CnOE484OR-axMYS-rptlYw3LtqRN3Dc-dcubb8Sfysq0YhsksON0BeOH5j5ZF9wF0v_Yu7M47sRFP56HrEtDyo0U1AoL9rDQUXMDsG

你可能感兴趣的:(opencv中打开摄像头显示黑屏)