opencv打开摄像头无画面显示
编程环境:WIN10+OpenCV3.1.0+Qt5.7.1
使用USB3.0双目视觉相机,免装驱动,
编译通过,程序运行,提示“frame success”弹出窗口,但画面一片黑
int main()
{
Mat frame;
VideoCapture capture(1);
if (!capture.isOpened())
{
cout<<"open camera1 failed"<<endl;
return -1;
}
while(1)
{
capture>>frame;
if(frame.empty())
{
cout<<"NO frame!"<<endl;
break;
}
else cout<<"frame success"<<endl;
imshow("1",frame);
if(waitKey(33)==27)
break;
}
return 0;
}