Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Using IMAQ create - Suggestions Needed

Solved!
Go to solution

Hi ppl,

 

I've been using lot of IMAQ Create VI to create image buffers in my application. Since there are lot of IMAQ Create instances will it be better to create all the image references in one go and use them. Or is it ok to create image buffers and close them inside each sub VI. My fear is that since these sub VI's are called inside loops it will not be a good idea to open the image reference for each iterations.

 

Thanks 

0 Kudos
Message 1 of 8
(4,653 Views)
I have always made sure to create individual buffers and that too when i am calling subvis. I for sure define individual buffers when the image is getting transformed from color to grey scale and grey scale to binary. So i use 3 buffers for sure if that is the case. Apart from this A buffer involving re-sizing is a must, Else you dont know which image is getting displayed.
0 Kudos
Message 2 of 8
(4,651 Views)

In my case, I do not want to modify the original image in most sub VI's. So I create a image buffer inside the sub VI, copy the input image to that buffer and process it. So I think this process of creating a image buffer is a overhead, and it'll be better to create all these image buffers in one go when the application initializes and use them inside these sub VI's.

 

I want ppl to comment on this and suggest a good solution. I'm not sure if its a good way to handle this.

 

 

Thanks 

Message Edited by lordsathish on 11-08-2009 11:52 PM
0 Kudos
Message 3 of 8
(4,614 Views)

If you want to keep the original image you need another image create for processing. If you call a sub-VI Vision image are not duplicated. Vision image are references. And furthermore if you create an image in a sub VI with a name which you used elsewhere you will get a reference to that image (if hasen't been closed).

 

Many vision VIs take two images as an input. These VIs copy the image data from Image A to image B while processing them. So you don't need an explicit copy before calling most IMAQ VIs. See the help for each IMAQ VI for detailed explanation.

 

I don't know about the internals of IMAQ vision. To your question: I think it makes no difference.

 

Regards

0 Kudos
Message 4 of 8
(4,591 Views)

Hi Jörn,

 

I remember reading somewhere that If we use IMAQ Create to get the reference of the an image already open it will create a new reference to the same image. If this is the case then new references will be created for the same image and this could result in memory leakage. However if we dispose the image and create a reference this process will be a overhead. I'm not sure of the background process. But this is what I have understood. Correct me if I'm wrong. 

0 Kudos
Message 5 of 8
(4,583 Views)
Solution
Accepted by topic author lordsathish

If you create a new reference to an already created image and if you call IMAQ Dispose.VI on this reference then also the image will be removed from memory. Thus, the image will also not be avaible in the other thread where the image was created first.

 

I think that it is best to create the image at program start if you need very often a "helper image" to store processing results. I guess it make only little difference in a sub-VI whether you pass the image reference thru the front panel or get it with IMAQ create. The difference is in not disposing the images every time.

 

With IMAQ dispose you can close all open image at once using a boolean connect to the VI.

 

Regards

Message 6 of 8
(4,571 Views)

Hi Jorn...

Can you suggest me a method to manage these IMAQ image references. As you said passing it through the front panel is better. My application has a hierarchical code. So it will not be good idea to pass all the image references through front panle i.e through the connector pane. As there could be lot of image references going into the top level VI's. So will it better to use a functional global to hold the references of all image references and read from them when required. 

 

Is there a way to reuse image reference by this approach, by using semaphores to lock the references ? Has anyone tried such thing ? 

0 Kudos
Message 7 of 8
(4,562 Views)

I am not sure whether I can answer your questions. So let me give two examples

 

A couple of years ago I made an application where I had to overlay an image with a fluorescence signal over the image from an endoscope in real time. Both had different frame rates and the fluorescence signal image needed to be processed to make a thresholded  colored overlay of the color image from the endoscope camera. There I created all images in advance and used them in a loop. I used a few helper images to separate colors and calculate the overlay. The need for the helper images is obvious after reading the help for the IMAQ Vision VIs and the requires lifetime of the image data. With each loop the image references where reused. No references where closed and reopend in the loop. For the purpose of clearness calculations where placed in sub-VIs and the few references where passed thru the connector pane.

 

My current work needs to process image sets with 600 VGA sized images. As the user shall browse thru the images using a slide all image are loaded at once. To handle this amount of images I have a LVclass containing an array of IMAQ Vision images. To process the images I pick them one after the other, make the required calculation and store it back to the Vision image. If apropriate I use a few helper images for the calculation which is created at program start and close at end. But when I load the next image set I close all images in the LVclass and create new Vision images.

 

So I have never faced the challenge to pass lots of separate image into a subVI. And I don't see the need for semaphores. SubVIs within one loop can be sequenced using the error cluster or passing the images. For parallel loops I would use several sets of helper images.

 

What sort of image processing do you have to do?

 

Regards

0 Kudos
Message 8 of 8
(4,544 Views)