View Full Version : Accessing to Image Buffer

May 3, 2006, 20:28:10
I´m using the DMK21BF04 with external trigger. I have implemented the following steps:

- Setup the grabber.
- create the memory buffer:

__________________________________________________ _______________________
grabber->setSinkType( FrameGrabberSink(
FrameGrabberSink::tFrameGrabberMode::eGRAB, DshowLib::eY8));

pMemBuffColl = grabber->newMemBufferCollection( 1 );

grabber->setActiveMemBufferCollection( pMemBuffColl );
__________________________________________________ _______________________

- Start the live video and enable trigger:


- Access the image data for image processing (executed on a thread):

__________________________________________________ ____________________________
DShowLib::Grabber::tMemBufferPtr pBuffer1 = grabber->getActiveMemBuffer(); (1)

BYTE pbImgData = pBuffer1->getPtr(); (2)
__________________________________________________ ____________________________

If no trigger occured, when the program execute the instruction (2), the error debug window will appear and the program crash. If the trigger has occured before, the instruction (2) is executed and it works fine (i can change the image data).

Why i can´t get the buffer pointer when the buffer is empty ?
The is any procedure to verify is the buffer contain any image ?

Best regards
Rui Costa

Stefan Geissler
May 4, 2006, 12:48:52
Hello Rui,

If no image has been grabbed, then getActiveMemBuffer() will return NULL, because this function returns the last filled memory buffer. This you may check, whether pBuffer1 is not NULL, before you access it.

Another way would be to use a listener (see Callback sample). The frameReady in the Listener object will be called, after an image was delivered. This means after the trigger puls has fired. You have acces to the membuffer, that was filled. And you image processing will only performed, if an image was provided. You do not need poll for new images and you can be sure, that you process no old image.