我想在openCV中对视频帧进行帧比较。让我们说视频文件中的第 10 帧和第 100 帧。如果我在主视频捕获循环中执行此操作,它会起作用。但现在我想将其移至专用方法(将 IplImages 作为输入)。
// MAIN CAPTURE LOOP
while(1) {
cvSetCaptureProperty(capture, CV_CAP_PROP_POS_FRAMES, 10);
frame = cvQueryFrame(capture);
if (!frame) break;
cvShowImage("Window_1", frame);
cvSetCaptureProperty(capture, CV_CAP_PROP_POS_FRAMES, 100);
nextFrame = cvQueryFrame(capture);
if (!nextFrame) break;
cvShowImage("Window_2", nextFrame); // THIS SHOWS ME TWO DIFFERENT FRAMES
// PASS THE IMAGES TO THE NEW METHOD
[self compareFrame: frame withFrame: nextFrame]);
char c = cvWaitKey(5);
if(c==27) {
NSLog(@"ESC pressed!");
break;
}
这是我的方法(简化)
- (int) compareFrame: (IplImage*) firstFrame withFrame: (IplImage*) secondFrame
{
// THIS SHOWS ME ONLY THE firstFrame IN BOTH
// WINDOWS?
cvShowImage("Window_1", firstFrame);
cvShowImage("Window_2", secondFrame);
return 1;
}
为什么会这样?