View Full Version : Frame Difference Problem

July 5, 2011, 09:27:35

I want to implement the most basic frame difference algorithm which is :

at time N,
New Image = Frame N - Frame N-1

But using my DFK 21BF04, sometimes my new image returns to be total zero which means Frame N and N-1 is totally same.

after opening my camera with C++ API, my code to grab images is this :

void cameracontroller::getRGBImage(int camIndex, IplImage *img)
imageBuffers[camIndex] = handler[camIndex]->getLastAcqMemBuffer();
pixelBasedImageData[camIndex] = (RGB24Pixel*)imageBuffers[camIndex]->getPtr();
copyImageData(img, pixelBasedImageData[camIndex]);


And i call this function each step.

What can i do to prevent grabbing same image although i make 2 calls to grab images ?

Stefan Geissler
July 5, 2011, 11:18:17

Your timeout of 0 ms is a little bit short. Therefore snapImages returns immediately. Since you did not implement an error handler, you do not know, whether there was a new image in this 0 ms time intervall. At least, a new image will not be available until the frame rates time interval has been gone.

I suggest following: Set a timeout of 1 second which is 1000ms. Also I recommend to add an error handler (try...catch). Please refer to:

July 5, 2011, 11:31:54
Your advises work fine,

Error e;
e = handler[camIndex]->snapImages(1, 10);
}while( !e.isError() );

works fine.

Thank you very much for your support !