#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
//VideoCapture capture;
//capture.open("./bike.avi");
VideoCapture capture(0);
//capture.set(CV_CAP_PROP_FRAME_WIDTH , 640);
//capture.set(CV_CAP_PROP_FRAME_HEIGHT ,480);
if(!capture.isOpened())
{
printf("[%s][%d]could not load video data...\n",__FUNCTION__,__LINE__);
return -1;
}
Mat frame;
while(capture.read(frame))
{
imshow("video-demo",frame);
char c = waitKey(66);
if(c == 27)
{
break;
}
}
waitKey(0);
return 0;
}
编译方法见:
https://blog.csdn.net/StruggleToLife/article/details/98480725
注意事项:
select timeout
VIDIOC_DQBUF: Resource temporarily unavailable
虚拟机自动重启,重新插拔(我这里刚开始重启后不行,后面重新插拔一下就行了)