View Full Version : MemorySnapImage vs ImageAvailable vs FrameFilter

Stefan Kirschne
May 4, 2010, 18:41:42
Hello everyone,

welcome to my first post ;)
I study in Bochum, Germany, and am currently writing my Bachelor-Thesis on lasertracking. With Imaging-Source cameras ^^

I've read through some of the technical articels from the .NET component documentation, but I'm still quite ansure about one aspect: What is, for my scenario, the best way to acquire images?

The scenario itself is quite simple - grab a frame, search for something that looks like the spot of a laser, have the position of it, do some calculations with it, grab the next frame. The ImagingControl offers several ways to do that.

For a start, I thought about the ImageAvailable event. But the documentation sounds rather like this event is primarily for triggered cameras.

An other option would be writing a FrameFilter, but I am not sure if they are made for manipulating images - while I'm extracting a feature.

Last but not least, there is MemoySnapImage and ImageActiveBuffer.Bitmap. I favor this one, because my first menthal drafts were about something like:

bool capture = true;
while (capture)
findLaser(imagingControl.ImageActiveBuffer.Bitmap) ;

Before running that loop, I'd of course call the LiveStart(); - but how long does MemorySnapImage() really take? The documenation says

If the live video stream is already running, then the maximum duration of MemorySnapImage is double of the frame rates time intervall.

What can I expect to be the "average" duration?
Is MemorySnapImage recommendable for this? I'd prefer it from a modeling point of view, but I'm simply not sure if I shouldn't rather try a FrameFilter (which I wouldn't like ^^).

Any suggestions?

Thanks in advance,

Stefan (btw, the name is "Kirschner", not "Kirschne"... sorry):confused:

Stefan Geissler
May 5, 2010, 10:01:34
Hi Stefan,

There os no straightforward answer to your question. Thus I will start with the disadvantage of MemorySnapImage.

MemorySnapImage snaps the next complete frame from the live video feed. In worst case MemorySnapImage was called directly after a frame has been started. This frame will not be saved, but the next one. Thus in worst case you will wait double frame rate's time interval.

Also MemorySnapImage is a blocking call, thus your GUI is halted. MemorySnapImage is nice, if you want to snap an image time by time.

If you want to do something like realtime processing and your imageprocessing lasts less than the frame rate's time interval, then the ImageAvailable event is want you should use. If your image processing is fast enough, you wont miss a frame.

You may also use frame filters, but this is too much effort.

Stefan Kirschne
May 5, 2010, 16:36:04
Hey Stefan,

again, thanks for the quick answer. Really great support ;)

Thank you also for the explanation on MemorySnapImage's time-consuming. I guess I'll follow your suggestion to youse the ImageAvailable event instead, but I'm a little unsure about which ImageAvailableExecutionMode I should use.

While in processing mode, I won't need to access controls on the UI. But there are some nonvisual objects that are instanciated by the form and which in turn own the ImagingControl-objects. From within the ImageAvailable event, I'll have to access certian variables and arrays. Will that be possible with, say, the MultiThreaded mode? Or is all I can access within the scope of the event handling method?



Stefan Geissler
May 10, 2010, 12:04:09
Hello Stefan,

you can use the controls and access the form global variables from within the ImageAvailable event. Maybe you need to create delegates. Please have a look in the documentation here: http://www.imagingcontrol.com/en_US/support/documentation/dotnet/prop_descICImagingControl_ImageAvailableExecutionM ode.htm

Stefan Kirschne
May 14, 2010, 01:48:19
Hey Stefan (marvelous name by the way ;) ),

thanks for the info, I hadn't had a look at that section back then. Since my image processing per event seems to only take about 10 milliseconds, I think I'm going to use the Invoke ExecutionMode. Then I'll hopefully be able to avoid this multithreading hassle and work without delegates - I have to admit that I don't know too much about them.
There is a nice example about them (this one: http://www.imagingcontrol.com/en_US/library/dotnet/iterating-an-image-sequence/), but I am not sure if they also work for my scenario. On the one side, I have my ImageAvailable-Events, and I set some global variables from within them - I should be able to handle that with delegates. But on the other side, I have a Timer outside of the ImagingControl thread, and that Timer has to read from the same global variables.

So I'm concerned about wether or not I could run into some "multiple access" problems when the ImageAvailable event (with MultiThreaded-Mode) writes to the global variables, while at the same time the Timer could be invoked, trying to read from them.
I guess I really try the Invoke mode first - at least because I *think* that there won't be problems like the one above that I'm afraid of ;)