LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Queuing Imaq images

Hello All,

 

I am writing a code for acquiring 2D grayscal images from a camera. So far I have reached a point where I am able to capture and save images successfully to the disk but due to my system running slow now I want to do all the operations on memory itself.

 

Hence I am trying to store and queue all the images and then dequeue slowly or store in a producer/consumer manner.

 

Second idea is to queue them and apply the signal processing (which I am still working on) and then extract the result out directly.

 

I am attaching a picture which shows my code and the queuing too. This programming is currently running but due to some miss-connection or some silly mistake I am not able to queue my incoming images as it should have been.

 

Note: I would like to work on the second idea more.

If anyone needs the copy of code then I am comfortable to share that too.

 

Hope anyone can help me with something. Any questions are welcome. 

 

Cheers & Thanks.

0 Kudos
Message 1 of 12
(4,992 Views)
Queues are not handled properly... can check ni examples on queues
Please clarify
1.Enqueing in a loop but only one image can be queued for multiple times
2.Dequeing also in loop which is not used anywhere

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 12
(4,958 Views)

First,  IMAQ images don't contain actual image data, they contain a reference to an image location.  So it is possible that you are creating multiple references to the same image location that is continually being overwritten by newer images.  (Not completely sure, because I can't quite decode what you are doing with the IMAQ subVI's.

 

Second, I have no clue what you are trying to do with those upper while loops.  One loop is enqueing the same wire every millisecond.  The other is dequeuing, but not doing anything with it. 

 

It isn't clear what you are trying to do, or what you are actually doing, or what you are saying is going wrong.

 

If you can describe these better, maybe we can help.

0 Kudos
Message 3 of 12
(4,954 Views)

Echoing the last two comments, it is possible to "enqueue IMAQdx Images" in LabVIEW, but because an IMAQ "Image" is not an actual image, but a pointer to memory where the Image is stored (not very well explained in the documentation, to be sure), you need to take special precautions when planning to use Producer/Consumer patterns with IMAQdx.  One thing you need to do is to create a (large) set of Image Buffers, and "worry" about which buffer you are processing (once you put a buffer into the Queue, as long as it is not overwritten, you are Good to Go).

 

Do us all a favor, and post VIs, and never post a picture of a VI (it's almost useless to us -- difficult to see, impossible to test any code, as we can't cut and paste into a new VI and hit the "run" button, etc.).

 

Bob Schor

 

P.S. -- in case it isn't clear, it would help if you posted the actual VI.

Message 4 of 12
(4,933 Views)

I wanted to add a little more detail to what is being said already.

 

You have a while loop set to enqueue data.  You have created a data dependency in this loop by sending in an image reference.

 

This means the while loop will not start until it gets the first image.  From that point forward, it will use the same reference each time.  This is a bad practice.  If you want to use a queue, you want to use it in the same location you're acquiring the data.  As you have it setup, it only updates once and uses that value indefinitely.  You might get lucky as vision uses references rather than actual data and this may work for you.  However, it's not something you want to rely on.  You're also putting yourself into a position where it's possible to lose some of these images as the queue will read the value after the reference is updated elsewhere.

0 Kudos
Message 5 of 12
(4,925 Views)
0 Kudos
Message 6 of 12
(4,918 Views)

Hello Everyone,

 

Following are the replies for everyone. I appreciate your time for giving this a read.

 

@palanivelT: I know what you are saying and that's why I couldn't get the desired output as needed or if I say in simple words then couldn't get the queus working properly but the type of coding I did for queue here is inspired from the example itself however, didn't get the success. 

For point 1. How should I wire so that I queue every image coming in? I put while loop so that it runs and queue images until it receives images. 

2. Dequeue is yet to be called/used in the signal processing loop which I am still working on. 

I hope you could help me as I am may be confused or my brain is saturated with all these blocks now...(kidding). 🙂 THANKS.

 

 

@RavensFan: For your first concern I have included my .vi below to give a clearer picture and I agree that I may be overwriting things but not sure how to rectify it.

 

Second, the loops I am working with for enqueing and de-queing is I want to queue all the images in and do some signal processing on it and then de-queue it as a result. I am working on FFT Pruning algorithms (if you are famliar) that it takes e.g 1000 images, uses their data and gives few of them out of it as a result. This program I am making in MAtlab whichh I will call once ready. However, regarding the queue I tried to this loop after seeing an example in NI on using queues but I guess didn't get it right. The idea behind enqueing (what I want it to work as) to take incoming images continously as coming from the camera and while loop should run until it stops receiving the images and then process it.  I might sound confusing but would answer any more questions if you have.

 

 

@Bob: I have attached the .vi too which has three parallel loops running. One is for a piezo motor, second is for the camera acquiring the images and third is simply reading the FPGA output from FPGA.vi My concern is about the second (as mentioned) loop particularly about the queueing. I tried working with the buffers too but I guess you judged me beforehand as it was overwrting it always I couldn't work with storing it continously. I would not worry about producer/consumer right now as I am still good with my system RAM and working speed however, storing images in a queue seems a problem to me right now.

 

 

 

@natasftw: YOu are right about it but the example I saw about queues expl;ains to keep it in a while loop for storing continously. 

And, the while loops is working for enqueing because it is getting it's first image but I guess it's just overwriting it again and again.

 

 

Note: .vi is attached and any other questions are welcome. Once again I appreciate your time.

 

Thanks,

Nitai.

0 Kudos
Message 7 of 12
(4,890 Views)
It's good that you have taken comments from all the community members who has replied for your query and analyzed the comments in detailed manner and replied back.I like this attitude personally.Hope you can learn more about labview and others stuffs in labview easily with this attitude.

Back to your problem whether still your problem exist or you have modified your code to satisfy your requirements based on above comments from others.
----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 8 of 12
(4,878 Views)

Thanks @palanivelT for your kind comments. It's been few months that I have started learning LabView from scratch for my project and I take learning seriously and the community members here have been very supportive so I NEED to be attentive to be attentive to everyone. 🙂

 

And, I haven't solved my problem yet as you must have seen in the .vi attached that I tried to apply the same logiv as given in NI example "Queue Basics" but somehow I messed up as I am not sure how to wire Imaq images to the "Obtain queue" and "Enqueue" block to have desired queing. Should I keep them out of while loop to avoid overwriting or take the whole logic of queuing outside the bigger while loop? Not sure. Various things running in my mind.

 

Thanks,

Nitai

0 Kudos
Message 9 of 12
(4,851 Views)

Thanks a lot for the link and after reading the details I am now aware of few things but being new I am not sure how to proceed in sequential steps?

0 Kudos
Message 10 of 12
(4,849 Views)