PDA

View Full Version : Quick capturing frames



aspsnake
February 9, 2012, 13:05:20
Hello! I have a 22BUC03 Camera. Trying to understand the C++ library code.

I need to get to my internal memory the captured frame. All I found in examples writes the frames to hwnd or to avi file. I need the full 76 fps video stream.

something like:

while(1)
{
QuicklyGetFrame();
ProcessFrame();
}

How Can I realize the QuicklyGetFrame function? I tried something like:

MemBufferCollection::tMemBufferPtr getSingleFrame( Grabber& gr, tColorformatEnum type )
{
smart_ptr<FrameHandlerSink> pHandlerSink = FrameHandlerSink::create(type, 1);
pHandlerSink->setSnapMode(true);

gr.setSinkType(pHandlerSink);

gr.startLive(false);
//Sleep(250); // give the device time to adjust automatic settings i.e. auto exposure
pHandlerSink->snapImages(1, 2000);
gr.stopLive();

// get pointer to the image data
return pHandlerSink->getLastAcqMemBuffer();
}

even without Sleep(250); the capturing is slow, something like 3 fps. What should I do?

Thanks in advance.

P.S. the examples that show video stream to window work perfectly.

Stefan Geissler
February 9, 2012, 13:20:08
Hello,

First of all, start the camera only. Do not call stopLive(). The startLive is the time consuming call.

Secondly: snapImages() will snap the next complete frame. That means, a frame currently in delivery will be dropped. Therefore, you can achieve half frame rate with this only.

What do you want to do with the frames? Maybe the "callback" sample shows, what you need. In case you want to handle each incoming frame automatically, you need to change the snapmode in this sample to false. Then snapImages is no longer needed and CListener::frameReady will be called for every incoming frame automatically.