11-26-2020 03:28 AM - edited 11-26-2020 03:29 AM
Hi,
I'm currently working on a project where I would like to capture real-time footage from a camera and perform some operations on the image based on user input. Currently, I placed all the components into a single while loop and I'm using case structures to decide which operations to perform.
However, I have a feeling that some performance issues might arise later, when I start adding more functionality. I have attached an example of what I'm talking about, where the Grab function and the Count Objects function are in the same while loop.
I'm wondering if it is possible to maybe split this into two loops, where one performs the image acquisition and the other runs the Count Objects function, when the user clicks the "Detect objects" button on the front panel (and stops, when the user clicks the button again).
Thanks in advance.
11-26-2020 05:34 AM
11-26-2020 05:49 AM
Hi rivlin,
please use direct links instead of hiding them behind suspicious 3rd party websites! (They may be blocked by company firewalls!)
Link1: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YGxRCAW&l=de-DE
Link2: https://zone.ni.com/reference/en-XX/help/371361R-01/lvconcepts/labview_threading_model/
11-26-2020 05:53 AM
IMAQdx, that you are using, is already grabbing images in parallel, you're using it in a way that blocks your loop. Rather than a second loop, learn techniques to not block waiting in an image. I use the "frame done" event to have IMAQdx tell me when the image is ready, but I'll bet there are even simpler ways. From your code, you don't even seem to be starting your task to be free running.
11-27-2020 02:36 PM
I echo the comments of @drjdpowell. I was introduced to LabVIEW Vision (and IMAQdx) while helping a colleague trying to record the behavior of a dozen mice (using a dozen cameras). Trust me, handling a dozen image streams is more "interesting" (i.e. a pain-in-the-rear) than doing a single stream.
The key concept that neither of us really understood, but figured out by reading the Help, what that of "Buffers", and how to use them. I just looked through the examples that ship with LabVIEW 2019, and couldn't find anything that really seem to address this, but I recall finding stuff on the Web (sorry, too many years ago to remember the Search terms).
But here's the idea: When you Configure Grab, you configure a number of Buffers, and set up IMAQdx for "Contiguous" Acquisition. What this does is allocate somewhere in PC memory enough space to save "# Buffers" images, and sets up pointers to point to this Storage Area. IMAQdx also associates some numbers with these Buffers, including "Last", "Next", "Last New", and "Every" which you can specify if you use IMAQdx Get Image2.
Suppose you do a default Configure Grab, which in LabVIEW 2019 configures 5 Buffers. The first 5 Grabs will go fill the Buffer space allocated and will be retrievable by specifying a Get Image2 with Buffer Number Mode set to "Buffer Number" and being called with "Buffer Number In" ranging from 0 through 4. What happens with the sixth Image? It overwrites the Image in the first (index 0) Buffer, and if you ask for Buffer 5, you'll get it. The Buffer Number always increase as Frames are acquired -- note that this allows you to look "backward in time" and view images acquired earlier (in the present example, up to 4 buffers earlier than the Current Buffer).
What you want to do is probably something like the following:
Bob Schor