LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

producer consumer of images

can someone please help me. I am totally stuck and lost. I am trying to build a procuder consumer architecture but the template from labview is not very clear. many books does not go over this concept.

i have created a vi. but i dont know what to do with the image in buffer.

can someone please guide me. thank you untitled.PNG

Best regards,
Krispiekream
0 Kudos
Message 1 of 9
(4,689 Views)

http://zone.ni.com/devzone/cda/epd/p/id/5859

 

 

Best regards,
Krispiekream
0 Kudos
Message 2 of 9
(4,685 Views)

Okay,

I have looked and went over the example and I have implemented this vi.

The only problem I am seeing is that the CONSUMER loop is not fully working?

It doesnt write the OVERLAY CORRECTLY. eventhough the pattern matches and X/Y values are within range. 

Its like its consuming too fast and the program doesnt have time to draw the overlay? Am I correct? How would I fix that?

 

Best regards,
Krispiekream
0 Kudos
Message 3 of 9
(4,662 Views)

I don't have IMAQ installed so your VI was broken and I don't have the details on much of your code but I suspect if you are using a single buffer to pass your images to the consumer loop for processing you are overwriting the images before it has been fully processed. I believe you will need to maintain some type of buffering to save a copy of each image to be processed.

 

Also, I prefer to use state machines for the consumer loop. I don't like having to scroll VIs. Plus, a state machine makes it easy to add new functionality if and when you need to do that. If on the other hand your processing will not be changed I would consider looking at portions of your processing and turn them into subVIs. you may find that you can reuse those pieces in other code and will help to make the code more readable.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 9
(4,654 Views)

One problem is that you created a queue that transfers Imaq references.  But in your consumer loop, you are transferring a string called elements.  (The red coercion dot on the Enqueue element gave it away.)  You would need to enqueue the purple wire.

 

On the other side you would need to dequeue the purple wire (Imaq reference).

 

One problem is that the purple wire is a reference to a particular memory location and is not a particular instance of an image.  As Mark was saying, you could wind up overwriting the memory location with new image data before you had a chance to do anything with the previous image data.

 

 

Here is a thread from last year that I replied into that talked about this issue.

 

How does labview deal with enqueuing/dequeuing images?

0 Kudos
Message 5 of 9
(4,644 Views)

One problem is that you created a queue that transfers Imaq references.  But in your consumer loop, you are transferring a string called elements.  (The red coercion dot on the Enqueue element gave it away.)  You would need to enqueue the purple wire.

 

On the other side you would need to dequeue the purple wire (Imaq reference).

 

One problem is that the purple wire is a reference to a particular memory location and is not a particular instance of an image.  As Mark was saying, you could wind up overwriting the memory location with new image data before you had a chance to do anything with the previous image data.

 

 

Hi  Ravens Fan! First off, I want to thank you and Mark for looking over my vi.

I formatted the code exactly how example did using this.

 

I don't see any red coercion dot on my Enqueue element. 

 in order to get my program working, I added a wait timer of 200 ms and it did the trick. But I am loosing the frame rate I needed and that's the main reason for moving to producer/consumer architecture.

Can you show me what you mean? I never worked with this time of architecture before and don't know how to use it.

Thanks

 

 

 

 

Best regards,
Krispiekream
0 Kudos
Message 6 of 9
(4,616 Views)

krispiekream wrote:

 

 

I don't see any red coercion dot on my Enqueue element. 

 


This image highlights the coercion dot.

 

 

 

I can't help much with IMAQ because I don't have that toolkit.  Others will have to help you there.

 

Where is the 200 msec wait timer you are referring to?

 

In your attached VI, why are you previewing the queue, then if the number of elements is equal to anything but zero, do you then execute the case structure and do your image processing code?  If you just used the dequeue function, that whole while loop will wait until an element is placed in the queue.  No Preview queue, no case structure needed then.

Message Edited by Ravens Fan on 03-09-2010 11:42 AM
0 Kudos
Message 7 of 9
(4,612 Views)

An IMAQ Image is just a pointer, essentially you keep queuing up the same pointer which is not what you want.

A better approach is to make a circular buffer (just a fancy array) of image spaces ahead of time, and each image, you need to do an Imaq copy into the next destination buffer.  In the consumer loop, you want to process the next element that has not been processed.  This is not all that intuitive but your typical queue consumer producer loop will not function as expected.

 

1.  Allocate an array of image spaces (use Imaq Create)

2.  Keep a circular read/write buffer (shift registers) of the next location to write (copy image into image array using Imaq Copy) and process next unprocessed index.

3.  Keep track of image buffer overruns (write index = read index)

4.  big thing to keep inmind is that the imaq (pruple wire) is just a reference to the image data and is not the same as your typical dataflow.

 

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 8 of 9
(4,609 Views)

Sorry about the confusion.

Initially I have a vi that is working. But its quite slow. I tried moving my code to producer/consumer.

That's when I posted the question. Attempting to do it was the first image with the red coerdion dot. Then I found another about queuing images. 

then I converted my existing code to the new sample I found. 

I then find out that it doesnt really work well. 

If I add a 200ms wait timer. IT WORKS. but I am losing frame rate per second and thats not really want I wanted.

So my question is. Can I still manage to get the outcome I wanted, while maintainging the frame rate as acquire by USB.

 

my application is trying

1. to acquire a color image.

2. covert color image to grayscale.

3. do geometric matching of image with reference image.

4. set coordinates of center point of MATCHED image.

5. draw oval and 2 lines (vertical/horizontal) = crosshairs to the image

 

i have sucessfully done all the above, except maintaining 30 fps as acquire. I just wanted to know if it is possible to do so or just give up trying to maintain 30fps because its not possible?

 

 untitled.PNG

Best regards,
Krispiekream
0 Kudos
Message 9 of 9
(4,604 Views)