View Full Version : Capturing a Long Image Stream

October 1, 2004, 22:23:17

I am attempting to capture 450 frames (30 seconds at 15 frames per second) from my Imaging Source DFK 31F03 in the form of an Image Sequence. The current way I am doing this is the following:

ICImagingControl1.ImageRingBufferSize = 450;
MessageBox.Show("Video capture complete. Click OK to save video files to disk.");
ICImagingControl1.MemorySaveImageSequence(450, filename);
// filename is something like "C:\images\image*.bmp"
MessageBox.Show("Image stream successfully saved.");

I am transferring these images over FireWire 400 to a workstation that runs Windows XP Home, has a 7200 RPM 160GB hard disk, and most likely 512MB of RAM. I would like to keep the resolution at 1024x780 and the frame rate at 15 FPS, so there is no flexibility there.

What I am interested in is saving these files as fast as possible.

Question 1: Is the code above the best way to do this given my current setup?

Question 2: What can you recommend in the way of hardware (15000RPM hard drive, RAID array, more RAM, etc.) to optimize this process? Currently it takes about 5 minutes to save these images and that is unacceptable. What is the most likely cause of the Input/Output bottleneck? Do not consider budget constraints for this question.

Question 3: If my requirements are unattainable, would it be a wise move to just save an AVI file of the appropriate length and extract all the images from that?

Thanks very much for any help.

Stefan Geissler
October 4, 2004, 09:34:30

As far as i can see your code is OK. With 450 images you allocate nearly 1 GB of memory: 1024*768*3*450=1061683200 bytes. If you have not enough RAM in your computer, Windows will start to swap memory intensively. This costs a lot of time. Therefore the first step could be upgrading your RAM.

To save the amount of data transferred to the hard disk, you should save the images in JPEG format. With a quality setting of 90 % the file size can be reduced up to 30% of the original size.

int i;
string cFileName;

ICImagingControl1.ImageRingBufferSize = 450;
MessageBox.Show("Video capture complete. Click OK to save video files to disk.");
for(i = 0;i < 450;i++)
cFileName = string.Format("c:\\puffer\\image{0}.jpg",i+1);
MessageBox.Show("Image stream successfully saved.");

Please excuse that i am no able to make hard disk recommendations. But i think the hints above will make the image save faster. If this does not satisfy you, you may save the images into an AVI stream. IC Imaging Control has no capabilities to extract images from an AVI stream. You should set the codec to RGB24 to save the images uncompressed to an AVI file. The Microsoft RLE codec uses a lossless compression too. The AVI solution has the advantage of low memory usage. This would avoid the memory swapping of Windows.

October 5, 2004, 20:43:45
Thanks, Stefan. Your replies are very helpful. :)

March 8, 2007, 18:30:48
I'm snapping image at different moment. And I'd like to save image in seperated files. How can I do that?

That's my code:

MemBufferCollection::tMemBufferPtr pActiveBuf;
smart_ptr<FrameHandlerSink> pHandlerSink = FrameHandlerSink::create( eRGB8, 1 );
pHandlerSink->setSnapMode( true );
gr.setSinkType( pHandlerSink );
gr.startLive( false );
Sleep( 500 );
pHandlerSink->snapImages( 1, 2000 );
pActiveBuf->save( "RGB.bmp");

Stefan Geissler
March 9, 2007, 09:17:55
Hi Toan,

I guess, we discussed this already yesterday here:

In the display function you can generate the file name and save the image to a file.

March 9, 2007, 09:29:33
Ok but each time I save the image, it erase the one before! I'd like to save one picture in one file.

In the Imaging Source sample, there is an example : membuffercollection
where it save in 5 differents files, but only at the end! I need something realtime. Because, the surgeon need all images he's done during the operation.

March 9, 2007, 09:44:49
To be clear, I'd like to know how to save several image in different files with a single buffer.

March 9, 2007, 09:53:18
How can we do that in visual C++? :

Private Sub btnSaveBMP_Click()


CommonDialog1.DefaultExt = "bmp"
CommonDialog1.Filter = "BMP Images (*.bmp)|*.bmp|"

If CommonDialog1.FileName <> "" Then

ICImagingControl1.MemorySaveImage CommonDialog1.FileName

End If

End Sub

March 9, 2007, 09:54:58
Sorry I paste the wrong code, it's this one:

Private Sub btnSaveNextImage_Click()


Dim filename As String
filename = "Image " & ImageNumber & ".bmp"

ICImagingControl1.MemorySaveImage filename

ImageNumber = ImageNumber + 1

End Sub

Stefan Geissler
March 9, 2007, 11:20:24
In C++ this is simple C stuff:

char szFileName[MAX_PATH+1];
sprintf(szFileName,"Image%03d.bmp", ImageNumber);

Then save the as usual with szFileName.