06-11-2019 02:13 PM
Hi all,
I'm currently developing a large(ish) GUI. One part of this is acquiring images from a USB-Vision camera (Pointgrey FLIR Chameleon3) while the GUI is running (single frame, multiframe sequences or just grabbing images continuously without saving)
Recently started using the IMAQ functions and used a few of the examples in LabVIEW to have the camera start and stop using a boolean control and an Event structure.
The LabVIEW example file I worked from registers a dynamic event (Frame Done) outside the While loop and acquires images until the user presses stop.
When I tried this approach but adding an additional event to start and stop the acquisition, it worked, but only the first time. The second time I try to generate a "start acquiring" event via a button press, the camera begins acquisition but the Frame Done event no longer registers so no new images appear on the screen.
I've eventually got it to work by essentially re-registering the event each time the camera begins acquisition again (see image below and VI attached - LabVIEW 2019).
My question is: is this the correct approach and more importantly, why/why not?
When you stop a camera acquisition does that change something about the session info which means the original registered event no longer triggers? This also wasn't camera specific as I saw the same behaviour with my laptop webcam.
Trying to better understand LabVIEW and dynamic events in particular as they seem incredibly useful but I feel i'm missing crucial info.
Thanks for your help
Solved! Go to Solution.
06-11-2019 02:23 PM
Let me start by saying I know nothing about IMAQ and I do not have 2019, so I can't open your code.
I suspect you are losing the IMAQ reference when another event fires. This would happen if you aren't wiring the reference thru all of the events. For this reason, I would suggest that you don't put your IMAQ code inside the event structure. Instead, use a parallel loop for the image grabbing and use some sort of messaging scheme where the event structure sends a message to this loop telling it to grab a picture.
06-11-2019 03:18 PM
That looks just like the code I use, so I must have discovered the need to re-register at some point. So I think your doing it right but I don't know the details why.
06-12-2019 01:34 PM
I have also (just) independently verified that you want to (re-)register for the Frame Done Event at the time you do the IMAQdx Start Acquisition. I built a little test routine that had a Start, Pause, and Stop Button, and set up my Web Cam to simply display sequential Buffers. The Start Button did Start Acquisition and Registered the Event (much as you did), Pause did IMAQdx Stop Acquisition, and Stop did another Stop Acquisition and ended the While Loop, doing the usual IMAQdx cleanup. One curious thing was that when I tried to do an Unregister for Events when the loop exited, I got "interesting" Error Conditions.
Vision and IMAQdx are "different" from other LabVIEW modules -- this is (I suppose) another example of a "Feature" not fully explained.
Bob Schor
06-13-2019 02:20 AM
Thanks for the confirmation. I just assumed I was doing something overly complicated as this type of functionality seems like it should be more transparent to implement.
I'm perhaps oversimplifying it tho, and as aputman suggested, running acquisition in a parallel while loop would potentially work just as well
06-13-2019 06:02 AM
@Oldbhoy wrote:
... running acquisition in a parallel while loop would potentially work just as well
Or be really buggy. Image references are tricky to work with in parallel loops. At best you'll be wasting effort reinventing what the "Frame Done" event already gives you.