PDA

View Full Version : how to syn capture a moving obj by 4 cams



kennyc
December 4, 2007, 16:12:01
I want to use 4 sets of DMM 21F04 (640x480) cams to capture a moving object. Is any method in software that I can do to let all the cams capture at the same time (synchronized capture). Using hardware triggering should be OK but the cost is much higher.

Thanks and rgds,

KC

Stefan Geissler
December 4, 2007, 17:35:49
Hi,

You can start all four cameras at the same time. You would only need four Grabber objects, one per camera.

Synchronization can be done using the GraphStartReferenceTime and the sample times:

http://www.imagingcontrol.com/support/documentation/class/meth_descGrabber_getGraphStartReferenceTime.htm

and the sample times
http://www.imagingcontrol.com/support/documentation/class/c_structrefstruct_tsMediaSampleDesc.htm
http://www.imagingcontrol.com/support/documentation/class/meth_descIFrame_getSampleDesc.htm

of the Membuffer objects. Whith these times you can synchronize proviously captured images.


You may try FrameHandlerSink::snapImagesAsync:

http://www.imagingcontrol.com/support/documentation/class/meth_descFrameHandlerSink_snapImagesAsync.htm

This function advises the framehandler sink to snap an image and return immediatelly, not only after the image has been delivered. You would also add a Grabberlistener inherited object with a frameReady method, that is called, after the image has been captured. This is needed to inform your program, that the image is there.

Thus you would have four grabber objects and four Framehandler sinks:


DShowLib::Grabber m_Grabber[4];
DShowLib::FrameHandlerSink::tFHSPtr m_pSink[4];
CListener m_cListener[4];

I suppose starting the live videos for all for grabbers is easy.
Then you would enter:


for( int i = 0; i<4; i++ )
{
m_pSink[i] = DShowLib::FrameHandlerSink::create( DShowLib::eRGB24, 5 ) ;
m_pSink[i]->setSnapMode( false );
m_Grabber[i].setSinkType( m_pSink[i] );
m_Grabber[i].addListener( &m_cListener[i] );
}

Later:


for( int i = 0; i<4; i++ )
{
m_Grabber[i].LiveStart();
}

If you want to snap all for cameras:


for( int i = 0; i<4; i++ )
{
m_pSink[i].snapImagesAsync(1);
}

This calls automaticall CListener::frameReady() and you can handle the incoming frames. I guess this is fast enough for nearly synchronized image snapping. The image may have a time difference of maximum twice of the frame rate. This is cause by the running live video.

If you test these sources, then may there is an error (Livestart() or startLive()...). But this should give you an idea about how to snap the images.