Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Can't create array of images with vision assistant

Hi Folks,

 

I'm having a problem that has been baffling me.  I'm trying to collect a finite number of single video images from a camera.  I have attached the program.  It is supposed to collect images, once per second, continuously, which it does. It is also supposed to take the first 10 of these images and build an array.  It does indeed build an array, of length ten once the while structure has looped that many times, and the elements of this array are indeed individual images. However they are all of the SAME image, the most recent one.  If I was to use this programs with numerical data, for example, instead of images the resulting array would be of the first 10 data points collected.

 

Yes I know there is a buffer option on the vision assistant but this buffer completely resets every time the next N images are acquired.  Ultimately I want to create a size N "FIFO" type array that records the prior N images at a given moment in time. The image I am interested in will be m images before the present one when a trigger goes off. So I will go to N-m and acquire THAT image when a trigger tells me an event of interest has occured.  Very simple to program. The fundamental problem is that  I can't figure out why ALL the images in the array are always the same as the most recent image.  I move the camera and see that each image is different, it's just that when I try to combine them into an array all I get is the same image repeated 10 times.

 

It seems like it must be something simple - I'm a newb at vision acquision, but not at labview. I have used code like this to create an array thousands of times. Why does it not work here?

 

 

0 Kudos
Message 1 of 6
(3,398 Views)

OK, I managed to create an image FIFO that works - see attached program - by using the buffer, not the image out. I still don't understand the reason why the "image out" from the vi is different from a single indexed component of the image buffer array from the vi, but it is. Partly because the code required to get it to work right is inelegant, and partly because I just would like to know, can someone explain to me this little detail I don't get. There may be good reason for this, but if not it seems like a flaw in the vi.

 

Thanks in advance.

 

0 Kudos
Message 2 of 6
(3,380 Views)

Hey millonas,

 

The wire coming out of the Vision Acquisition Express VI is not an image, but rather a pointer to the image location. So, in the first case you were creating an array of 10 "images" that were actually all pointers to the same memory location and thus the same image. In your second VI, you are calling on the buffered locations, which are unique and therefore you are getting the results you expect. You can find more information here. Have a great weekend!

John B.
Embedded Networks R&D
National Instruments
Certified LabVIEW Developer
Message 3 of 6
(3,377 Views)

Yes, I figured that something like that was what was going on.  I'm not sure why a pointer is an output of a high level vi in Labview. I understand why you would use the pointers inside the vi, but can you explain why this is the best way to output the data from the vi? This is the first time I encountered a pointer "output" from a library vi from Labview.

 

And then, why can't I simply use the "buffer" output with size 1 which would solve my problem.  This 'buffer' output seems like an afterthought and assumes only a certain kind of collection - a one time collection of N(>1) sequential "snapshots". It seem to me the "obvious" thing, which is to have access to the latest data directly so we can code our own arrays of images in the ways we require for our own needs. maybe there is a good reason I just don't get. But I'm trying to do something very elementary, but the labview vi forces me to write extra code to undo this situation. It seems like I shouldn't have to use counters and shift registers to unravel the buffer in a way that will simply allows me to access and store, at high level within Labview,  the individual snapshot at each moment in time.

 

Is there a way to simply deference the pointer so I can just read the actual data at each point in time directly into my virtual FIFO?  Can you give a code example of this dereferencing?  I have been looking at stuff on the web but it is not particularly helpful. All the stuff I can find basically assumes you want to adapt some external C code. I was under the impression that we were discouraged from dealing with this kind of stuff at the highest level in labview. Pointers don't seem to even be referred to in most labview books dealing with simply using the high level language. My "best" labview book, about 1000 pages, does not even have a reference in the index to "pointer/s"

 

Also, why doesn't the spellchecker dictionary in the NI forums automatically recognize the word "Labview". LOL Just kidding, you don't have to answer that one.

 

 

0 Kudos
Message 4 of 6
(3,303 Views)

It's difficult to accomplish the image array that you desire with the Vision Acquisition express VI. However, your acquisition code can be programmed using the IMAQdx tools rather than the express VIs, and it will give you the results that you want. You simply have to use the IMAQ Create VI to reserve space for the images. Here is example code that stores an image captured once a second into an array;

 

Image array.png

 

Hope that helps!

John B.
Embedded Networks R&D
National Instruments
Certified LabVIEW Developer
0 Kudos
Message 5 of 6
(3,290 Views)

Thanks for the advice. I'll try it out.  I succeded in creating my own version of the vision assistant that output a FIFO array of lenght N instead of the buffer that resets.  So the net result is what I wanted, but it probably would be better in the end to do it more like the way you suggest.

 

 

 

0 Kudos
Message 6 of 6
(3,288 Views)