I built a code a VI in which I set up a camera acquisition with IMAQdx in a producer-consumer loop (please see VI attached). The code also controls the camera exposure time.
I would like to save images at 10 fps, the camera is set up to acquire at 10 fps in NI MAX, but surprisingly the code saves more than 10 images per second, even if I inserted a timing function in the producer loop.
Any ideas on what's not working?
Solved! Go to Solution.
Figuring out how to set up a (video) camera to take videos is not simple. I'm sure there are examples shipping with LabVIEW (sorry, I don't have time to look right now for you). But look at the Help for IMAQdx Configure Acquisition -- you've specified the one combination of Continuous (T) and Number of Buffers (1) that is not listed in the choices. Look for routines that specify multiple buffers (you need to test to see how many you really need -- we usually double or triple the "default" number).
Mmhh... I see your point. Do you think I have to set-up a buffer of a certain number of images outside of the loop before starting the acquisition?
There are three modes of camera acquisition: Snap, Sequence and Grab based on the parameters you set:
Snap(Single Image acquisition): Continuous = 0; Buffer Count = 1
Sequence(Fixed number of images): Continuous = 0; Buffer Count > 1
Grab(Continuous acquistion): Continuous = 1; Buffer Count > 1
-So i guess you want continuous acquistion which means you need set Buffer count more than 1(generally more than 3) which the driver uses internally to avoid overwriting of images.
-You can check the The Grab and Attributes Setup example VI which allows the user to view the current attributes and settings, update attribute settings, acquire images continuously, and display the images in an image control.
-From the above example you can also see the framerate with which you are acquiring and then proceed to saving images.
-To access the example Help->Find Examples-> Search for Grab.
thanks. I understand. I had not specified anything for the variable "Number of buffers", I will set it to 4 or 5. I guess if you specify nothing, the number of buffers automatically assigned is 1 ... This is the reason of your comment, I guess...
Putting 5 as "number of buffers" I still have the same problem. I am showing the image counting and my codes saves more images than that number. There's still something wrong I have to figure out...
-you are displaying the producer loop count and it is not the image count.
-What is the timeout you set in MAX?
-When you check the images saved all are appropriate images? Duplicate?
-instead try to display the Buffer Number out which is returns the acquired image number.
-Get Image VI has default timeout of 5000ms, which means if there are no images in this duration it can result an error and you might be enqueuing a blank image(is this the case?)
-Can you send screenshot of NI MAX Settings for camera?
-Did you check with the example i pointed and verified are you acquiring the required frame rate?
-You have created just one user buffer, what happens if next image arrives while you are trying to save the current image?
I modified the program and I set up an acquisition using the grab configure and grab architecture. The frame rate indicated as the "proccessed frames", output of the function "Calcuate frame per second" is about 10 fps, the value set both by NI MAX and by the timing within the loop itself.
However, I still have the same problem. The buffer number, output of the function IMAQdx Grab 2 is always lower than the images that are actually saved. I have no blank image.
I think that one of these explanations is possible:
- I am saving more than one images within one loop, sometimes. the number of images saved is proportional to the buffer number (if the buffer number is 50 I save 62 images, if it is 100 I save 120 images and so on...) I tried to frame a moving object but it seems no frames are skipped or duplicated ...
- I have a different actual frame rate. But I don't know how to check it.
Please let me know what you think about this.
IMAQdx Configure grab includes IMAQdx Configure acquisition and Start acquisition, so you don't have to do configure explicitly.
-Either use low-level functions or high level functions.
Few items to check:
-What is the iteration count of Producer loop vs Buffer Count vs Consumer loop count vs images saved.
-Instead of single user buffer, try creating buffer for each iteration inside Producer loop and dispose the image after saving it(If you don't dispose they'll fill up memory).
-And enqueue same image buffer name to the queue and verify if there is anything wrong.
-Since the image buffer is single,you might not be able to differentiate if there are any duplicates is my guess, hence i am suggesting to enque the name along with iteration to check.
I found out that the problem is in the image naming because the number of images saved is the same of the buffer size, however some indexes are missing so the last image number is not the same as the buffer size. This confused me.
I am trying to figure out how to fix this.