PDA

View Full Version : Frame Difference Problem



taygunkekec
July 5, 2011, 09:27:35
Hello,

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)
{
handler[camIndex]->snapImages(1,0);
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
Hello,

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:
http://www.imagingcontrol.com/en_US/support/documentation/class/meth_descFrameHandlerSink_snapImages.htm

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


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

works fine.

Thank you very much for your support !