I just wrote a simple video reading example with openCV2.3.1, but it seems that I cannot open avi video anyway :(
VideoCapture capture("guitarplaying.avi");
if(!capture.isOpened()){
std::cout<<"cannot read video!
";
return -1;
}
Mat frame;
namedWindow("frame");
double rate = capture.get(CV_CAP_PROP_FPS);
int delay = 1000/rate;
while(true)
{
if(!capture.read(frame)){
break;
}
imshow("frame",frame);
if(waitKey(delay)>=0)
break;
}
capture.release();
I made a breakpoint in std::cout<<"cannot read video!
"
and find that it stopped here every time. So why avi video cannot be opened? Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…