PDA

View Full Version : Problem of opening 2 grabber at the same time



ray@frontier
December 13, 2006, 05:47:07
Hi all,
When I open 1 grabber, each "snapimage" cost me about 33 ms for snapping 1 image. This is ok i think.

Then I try to open 2 grabbers at the same time with setting the frame rate to 15 fps, each snapimage function now costs me 66 ms for snapping 1 image in 1 camera. I just wonder why it become double in time.

This is my source code:

Grabber grabber;
if( !setupDeviceFromFile( grabber ) )
{
return -1;
}
grabber.setOverlayBitmapPathPosition( ePP_NONE );
tFrameHandlerSinkPtr pSink = FrameHandlerSink::create( eY800, 1 );
pSink->setSnapMode( true );
grabber.setSinkType( pSink );
if( !grabber.prepareLive( false ) )
{
std::cerr << "Could not render the VideoFormat into a eY800 sink.";
return -1;
}

FrameTypeInfo info;
pSink->getOutputFrameType( info );
BYTE* pBuf[100];
for( int i = 0; i < 100; ++i )
{
pBuf[i] = new BYTE[info.buffersize];
}
tMemBufferCollectionPtr pCollection = MemBufferCollection::create( info, 100, pBuf );
if( pCollection == 0 || !pSink->setMemBufferCollection( pCollection ) )
{
std::cerr << "Could not set the new MemBufferCollection, because types do not match.";
return -1;
}
grabber.stopLive();


Grabber grabber2;
if( !setupDeviceFromFile( grabber2 ) )
{
return -1;
}
grabber2.setOverlayBitmapPathPosition( ePP_NONE );
tFrameHandlerSinkPtr pSink2 = FrameHandlerSink::create( eY800, 1 );
pSink2->setSnapMode( true );
grabber2.setSinkType( pSink2 );
if( !grabber2.prepareLive( false ) )
{
std::cerr << "Could not render the VideoFormat into a eY800 sink.";
return -1;
}
FrameTypeInfo info2;
pSink2->getOutputFrameType( info2 );
BYTE* pBuf2[100];
for( int i = 0; i < 100; ++i )
{
pBuf2[i] = new BYTE[info2.buffersize];
}
tMemBufferCollectionPtr pCollection2 = MemBufferCollection::create( info2, 100, pBuf2 );
if( pCollection2 == 0 || !pSink2->setMemBufferCollection( pCollection2 ) )
{
std::cerr << "Could not set the new MemBufferCollection, because types do not match.";
return -1;
}

grabber.startLive( false );
grabber2.startLive( false );

for (int j=0; j<50; j++)
{
pSink->snapImages( 1 );//this now cost me 66 ms now but if only open 1 grabber, it cost me 33 ms only

}

Stefan Geissler
December 13, 2006, 14:07:13
Ray,

If you use 15 fps, then each frame needs 66 milliseconds to be delivered (1000 / 15 = 66.666). snapImages() returns after a complete frame has ben delivered by the video capture device. Thus it takes twice the time for 15 fps as for 30 fps.