PDA

View Full Version : SnapImage Crash after snapping 1000 images



waazimreza
February 23, 2010, 17: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

waazimreza
February 23, 2010, 20: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, 10:31:57
Hi,

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.

waazimreza
February 24, 2010, 15: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, 15:33:58
-what memory are you speaking about?
RAM

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

waazimreza
February 26, 2010, 00: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.
Regards,
Waazim Reza

Stefan Geissler
February 26, 2010, 10: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.)