From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Two vision aquisition in the same VI

Hello everyone,

 

so i have a VI, where i have to use Vision aquisition.

 

In this VI i have to take a live online cam, and then if i activate a button: it takes 5 shots for example.

 

So i tried to put two vision aquisitions, one is for the online show (Mode: continuous aquisition without logging) and another one with the mode (finite aquisition with logging). 

 

when i run the VI, it stops when after i press the button to take the finite shots, and the VI stops. How could i solve this problem? 

 

Thanks a lot!! 

0 Kudos
Message 1 of 9
(938 Views)

@AymanB95 wrote:

when i run the VI, it stops when after i press the button to take the finite shots, and the VI stops. How could i solve this problem? 


You wired the stop condition of the while loop. It will stop the while loop...

 

If you don't want the while loop to stop, don't wire a true to it's stop condition.

 

But more generally, you probably want to acquire continuously. Most definitely not 2X in parallel.

 

I'd (try to) make a loop that acquires images, and then let the buttons decide how to use the data (e.g. show live data and\or sample 5 frames). 

0 Kudos
Message 2 of 9
(932 Views)

Thank you for ypur answer.

 

Thats exactly my problem or my question: i want to  acquire continuously, and at some point later in the code i want to acquire 5 samples (if somthing happens). and my question is: is it possible to use the vision aquisition somehow to switch from doing online images to acquire just 5 images and then go back to the online show?

0 Kudos
Message 3 of 9
(911 Views)

@AymanB95 wrote:

Thank you for ypur answer.

 

Thats exactly my problem or my question: i want to  acquire continuously, and at some point later in the code i want to acquire 5 samples (if somthing happens). and my question is: is it possible to use the vision aquisition somehow to switch from doing online images to acquire just 5 images and then go back to the online show?


In a loop, acquire your images.

 

If you want to acquire 5 images, start a counter (or array with 5 elements) and in the next 5 iterations, copy the incoming images. Keep the images (and counter) in a shift register. The images can be an array of 5 images.

0 Kudos
Message 4 of 9
(898 Views)

Thank you so much for your reply 🙂 

 

That sounds exactly what i would like to do, but since im really new to LabView, could you please if you have time show me an example how can i do the counter and copy the images to the shift register? that would be really a big help for me!!

 

Best regards

0 Kudos
Message 5 of 9
(893 Views)

@AymanB95 wrote:

Thank you so much for your reply 🙂 

 

That sounds exactly what i would like to do, but since im really new to LabView, could you please if you have time show me an example how can i do the counter and copy the images to the shift register? that would be really a big help for me!!

 

Best regards


That's not that easy without IMAQ installed.

 

It's a lot easier then you'd think though.

 

Have a look at the IMAQ Copy function. That does most of the work.

 

The copied IMAQ image and a build array function give you an array of images.

 

A shift register keeps this array over iterations.

0 Kudos
Message 6 of 9
(886 Views)

I have often mentioned the Dreaded DAQ Assistant (which I affectionately call the DDA) when users new to LabVIEW want to do something a little more complicated than "Sample 1000 points at 1 kHz and plot the results".  Fortunately, NI has published a number of excellent White Papers on DAQmx, including my favorite (which taught me a lot!), "Learn 10 Functions in NI-DAQmx and Solve 80 Percent of your Data Acquisition Applications.

 

About a decade ago, after using LabVIEW for a number of years, a colleague who was collecting videos as part of a behavioral study came to me to ask for some comments on a LabVIEW problem he was having.  He wanted to save video starting 1 second before a behavior Event (analogous to a bar press) occurred.  He was taking 10 seconds of video, and if the bar press happened, he would mark that Video as "Save me", and continue taking more video until the behavior ended.  A messy problem, particularly since I had never dabbled in LabVIEW Vision (and there was, as I recall, no "Vision Assistant" to drive us crazy, we had to use IMAQdx.

 

Well, it turns out that IMAQdx has a nifty feature that lets you define multiple "buffers" in the Driver that hold successive images, not unlike the "ring buffer" (implemented in Shift Registers in Wiebe's post, or alternatively in a Finite Lossy Queue, or similar structure).  But it took two of us, one with a fair amount of experience with "plain IMAQdx" (my colleague) and one who had dabbled in many Dark Corners of LabVIEW (and had learned how to write "understandable" LabVIEW VIs, namely me) a week or two of writing and running test code to learn how this works.

 

This is not for beginners.  Find yourself someone who has experience with IMAQdx and be prepared to spend a week or two getting up to speed with this interesting, but somewhat under-documented, feature of LabVIEW.

 

Bob Schor

0 Kudos
Message 7 of 9
(869 Views)

I have used an array for that as well. It's a slightly different situation, as you have a back log of images, and here you want to trigger a future log. 

 

Simply remove the last image in the array of images and use it for the new image. Put it on top. (Of course, it's more efficient to rotate the array or even better, to keep a pointer).

 

If you treat IMAQ images the right way, they can be handled just like any other object. It never felt that messy to me.

 

I agree that Vision Assistant usually make things harder.

 

It could indeed be a lot simpler to always have a record of the last n samples. Then, if there is a trigger use that buffer. It will be easier to debug, as you can the behavior you want to study is always present, not just when an event happens.

 

I haven't seen the build in buffer. How do you access it?

0 Kudos
Message 8 of 9
(853 Views)

wiebe@CARYA wrote:

I haven't seen the build in buffer. How do you access it?


Oops, I haven't (yet) installed Vision on this Laptop, so can't even look at my own (older!) code where I did this.  Will get back to you in a day or two.

 

Bob Schor

0 Kudos
Message 9 of 9
(834 Views)