LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

queue

Solved!
Go to solution

Hi,
My name is Noy and I'm a student in my last year and working on my final project.
In the project I has to get frames from a camera , put them in a queue in one loop and in another loop I want to get the frames from the queue and save them as a avi file.
When I run the program I see that the enqueue goes well but when it goes to the dequeue loop it seems that the queue is empty.
Can anyone help me to understand how to solve that?
Thanks,
Noy

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

Well your bottom Get Queue Status VI will show zero if your top loop is enqueueing at the same rate as your lower loop because it's reading the queue size right after dequeueing.

I imagine, it's going something like this: Enqueue -> Read # Elements = 1 -> Dequeue -> Read # Elements = 0

 

Is there something else that makes you think the queue is empty? Your producer consumer loop setup (though sloppy) shouldn't have any problems dequeueing unless there's an error.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


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

Thank you for your reply!
I think that it's not going well because when I trying to see the avi file I saved (should be few seconds) it looks empty.
The avi file is attached.

 

0 Kudos
Message 3 of 6
(3,466 Views)
Solution
Accepted by topic author noy118

Never ever tell a consumer to stop when the queue is empty.  That is just asking for strange issues like you are seeing.  Instead, you should send an actual command through the queue telling it to stop.  In a case like this, I would send an empty array.  There is a simple primitive on the comparison palette to test for an empty array.  You also need to release the queue when the consumer loop is complete.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 6
(3,456 Views)

I would suggest setting up some error handling in that consumer loop. You currently don't have any, so maybe there's an error that it's generating that will give you more info. At a minimum, just put an indicator for the error in there.

  • Also, make sure to wire the errors through the IMAQ VIs, as they are currently not wired.
  • You don't need to create the "pic" IMAQ reference with each loop, you can do that before the loop starts and use the same image reference each time.
  • Commonly, the producer loop releases the queue reference when it ends. This should then trigger the end of the consumer loop if you have the error output of the Dequeue Element VI wired to the stop terminal.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 5 of 6
(3,453 Views)

Thank you so much!!
The problem is solved when I did what you said 🙂

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