waazimreza
February 23, 2010, 16:49:23
Hi all,
I am working in this project in which I need to take more than 1000 continious snaps from my TIS camera. I am using the following code for the purpose,
void main()
{
if( ! InitLibrary( "XXXXXXX" ) ) //I specify my license key here
{
printf("Init Error: Wrong License Key for Camera \n");
exit(0);
}
Grabber grabber;
int nPics =1000;
if( !setupDeviceFromFile( grabber ) )
{
printf("Device Error: Wrong Device Input Data for Camera \n");
exit(0);
}
// Set the image buffer format to eY800. eY800 means monochrome, 8 bits (1 byte) per pixel.
// Let the sink create a matching MemBufferCollection with 1 buffer.
tFrameHandlerSinkPtr pSink = FrameHandlerSink::create( eRGB24, 1 );
// We use snap mode.
pSink->setSnapMode( true );
//bool flag = grabber.setFPS(30.00);
// Set the sink.
grabber.setSinkType( pSink );
// Prepare the live mode, to get the output size if the sink.
if( !grabber.prepareLive( false ) )
{
printf("Could not render the VideoFormat into the sink. \n");
exit(0);
}
// Retrieve the output type and dimension of the handler sink.
// The dimension of the sink could be different from the VideoFormat, when
// you use filters.
FrameTypeInfo info;
pSink->getOutputFrameType( info );
BYTE** pBuf = (BYTE **)malloc(nPics*sizeof(BYTE *));
// Allocate 5 image buffers of the above calculate buffer size.
for( int i = 0; i < nPics; ++i )
{
pBuf[i] = new BYTE[info.buffersize];
}
// Create a new MemBuffer collection that uses our own image buffers.
tMemBufferCollectionPtr pCollection = MemBufferCollection::create( info, nPics, pBuf );
if( pCollection == 0 || !pSink->setMemBufferCollection( pCollection ) )
{
std::cerr << "Could not set the new MemBufferCollection, because types do not match.";
}
// Start live mode for fast snapping. The live video will not be displayed,
// because false is passed to startLive().
grabber.startLive( true );
// Snap 5 images. The images are copied to the MemBufferCollection the
// application created above.
pSink->snapImages( nPics );
// Stop the live video.
grabber.stopLive();
// Close the device.
grabber.closeDev();
// Save the five captured images in the MemBuffer collection to separate files.
pCollection->save( "I_30FPS*.bmp" );
}
I have got the following problems:
1. Here I use nPics as the number of pictures to be captured.
If I specify nPics =1000, pSink->snapImages( nPics ) snaps me 1000 images.
But when I specify nPics as 3000 the code crashes.
Is there any limitation for number of images snapImages() can capture?
Regards,
Waazim Reza
Regards,
Waazim Reza
I am working in this project in which I need to take more than 1000 continious snaps from my TIS camera. I am using the following code for the purpose,
void main()
{
if( ! InitLibrary( "XXXXXXX" ) ) //I specify my license key here
{
printf("Init Error: Wrong License Key for Camera \n");
exit(0);
}
Grabber grabber;
int nPics =1000;
if( !setupDeviceFromFile( grabber ) )
{
printf("Device Error: Wrong Device Input Data for Camera \n");
exit(0);
}
// Set the image buffer format to eY800. eY800 means monochrome, 8 bits (1 byte) per pixel.
// Let the sink create a matching MemBufferCollection with 1 buffer.
tFrameHandlerSinkPtr pSink = FrameHandlerSink::create( eRGB24, 1 );
// We use snap mode.
pSink->setSnapMode( true );
//bool flag = grabber.setFPS(30.00);
// Set the sink.
grabber.setSinkType( pSink );
// Prepare the live mode, to get the output size if the sink.
if( !grabber.prepareLive( false ) )
{
printf("Could not render the VideoFormat into the sink. \n");
exit(0);
}
// Retrieve the output type and dimension of the handler sink.
// The dimension of the sink could be different from the VideoFormat, when
// you use filters.
FrameTypeInfo info;
pSink->getOutputFrameType( info );
BYTE** pBuf = (BYTE **)malloc(nPics*sizeof(BYTE *));
// Allocate 5 image buffers of the above calculate buffer size.
for( int i = 0; i < nPics; ++i )
{
pBuf[i] = new BYTE[info.buffersize];
}
// Create a new MemBuffer collection that uses our own image buffers.
tMemBufferCollectionPtr pCollection = MemBufferCollection::create( info, nPics, pBuf );
if( pCollection == 0 || !pSink->setMemBufferCollection( pCollection ) )
{
std::cerr << "Could not set the new MemBufferCollection, because types do not match.";
}
// Start live mode for fast snapping. The live video will not be displayed,
// because false is passed to startLive().
grabber.startLive( true );
// Snap 5 images. The images are copied to the MemBufferCollection the
// application created above.
pSink->snapImages( nPics );
// Stop the live video.
grabber.stopLive();
// Close the device.
grabber.closeDev();
// Save the five captured images in the MemBuffer collection to separate files.
pCollection->save( "I_30FPS*.bmp" );
}
I have got the following problems:
1. Here I use nPics as the number of pictures to be captured.
If I specify nPics =1000, pSink->snapImages( nPics ) snaps me 1000 images.
But when I specify nPics as 3000 the code crashes.
Is there any limitation for number of images snapImages() can capture?
Regards,
Waazim Reza
Regards,
Waazim Reza