我想读取视频前后两帧图像,可为什么每次读出显示的图像都是一起变化的呢
intmain(intargc,charargv[]){VideoCapturecapture;stringvideo=string("E:\\cxystudy\\cxy...
int main(int argc,char argv[])
{
VideoCapture capture;
string video =string("E:\\cxystudy\\cxystudy\\scene detection\\aa.avi");
capture.open(video);
cv::Mat frame_old;
cv::Mat frame;
capture.open(video);
if (!capture.isOpened())// check if we succeeded
{
cout << "capture device failed to open!" << endl;
}
capture >> frame_old;
while(capture.read(frame))
{
IplImage *current_frame =&IplImage(frame_old) ;
IplImage *next_frame = &IplImage(frame) ;
cvShowImage("frame", next_frame);
cvShowImage("frame_old", current_frame);
cvWaitKey(1000);
swap(frame_old,frame);
}
return 0; 展开
{
VideoCapture capture;
string video =string("E:\\cxystudy\\cxystudy\\scene detection\\aa.avi");
capture.open(video);
cv::Mat frame_old;
cv::Mat frame;
capture.open(video);
if (!capture.isOpened())// check if we succeeded
{
cout << "capture device failed to open!" << endl;
}
capture >> frame_old;
while(capture.read(frame))
{
IplImage *current_frame =&IplImage(frame_old) ;
IplImage *next_frame = &IplImage(frame) ;
cvShowImage("frame", next_frame);
cvShowImage("frame_old", current_frame);
cvWaitKey(1000);
swap(frame_old,frame);
}
return 0; 展开
若以下回答无法解决问题,邀请你更新回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询