View Full Version : SnapImage Crash after snapping 1000 images

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");

Grabber grabber;
int nPics =1000;

if( !setupDeviceFromFile( grabber ) )
printf("Device Error: Wrong Device Input Data for Camera \n");

// 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");

// 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.

// Close the device.

// 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?

Waazim Reza

Waazim Reza

February 23, 2010, 19:10:05
When I use nPics < 2016 , it works prpperly.
but when I use nPics = 2016 or greater I get the following error:

Exception DEBUG: in c:\dev\ic3.1\build\ic\tmp\svn\core\tisudshl\grabbe r.cpp at line 939:

Error = Failed to start the graph. Due to: Not enough storage is available to complete this opration

In file :"c:\dev\ic3.1\build\ic\tmp\svn\core\dshowlib\filegr aph.cpp" at line:307

Continue? (say "no" to rethrow catched exception or "yes" to continue without doing anything)

Please help me out.

Stefan Geissler
February 24, 2010, 09:31:57

for 3000 pics you need 640*480*3*3000 bytes of memory. Does your computer has enough memory?

Due to: Not enough storage is available to complete this opration
I think, this error message clearly sais, you do not have enough memory. You need more memory. Do you use a 32 bit system? Then max is 3 GB, if you use a 64 bit system, then you can allocate more memory.

February 24, 2010, 14:02:18
Few Doubts:
-what memory are you speaking about?
-my computer is 64Bit Windows 7 system.How much memory can it allocoate?

Stefan Geissler
February 24, 2010, 14:33:58
-what memory are you speaking about?

-my computer is 64Bit Windows 7 system.How much memory can it allocoate?
6 GB as far as I know, minus the memory used by the OS, in case you built an 64 bit application.

February 25, 2010, 23:09:38
Hi Stefan,

My application needs to snap more than 50000 continous images and store it on disk.

Is there any way to so this operation without having constraints of RAM memory?

If you have a better solution , can you please tell me the code for that.

Thanks in advance.
Waazim Reza

Stefan Geissler
February 26, 2010, 09:30:03
Dear Mr. Waazim Reza,

Thank you for your email. Yes, saving 50000 and more images is possible by creating an AVI file.
All other will cause memory and operating system problems. I am not sure, how many files Windows can
handle in one directly, but I would expect a limit at 65000 files.

(This is the same text, I have sent by email to you on your email request.)