videocapture视频读取问题
我想读取视频中前后两帧图像进行比较,可是为什么我读出显示的图像都是同时变化的呢?
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;
}