Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

IMAQdx Get Image Data VI not returning the correct buffer number

Dear all,

 

I'm writing LabView VIs for a Basler USB camera (model acA1920-155um). I'm acquiring triggered frames in pairs For each image in the pair I use IMAQdx Grab2.vi followed by IMAQdx Get Image Data.vi where I specify the buffer number. (See mockup screenshot below). It's important that the frames are sequential, and I hope to avoid any dropped frames.

 

Unfortunately if I compare the 'requested' buffer index and the 'actual' buffer index, they sometimes disagree (example screenshot attached). The requested and actual frames differ by 2 in the included example, though trying this several times the difference can be as large as about 20.

 

Other details:

- I'm using 64-bit Windows 10 with LabView version 17.0.1f1 and NI-IMAQdx version 17.0.0

- I tried different options for IMAQdx Configure Acquisition.vi, including 'Snap', 'Sequence', and 'Grab'. I can't tell if these actually affect the performance, and the problem happens in each case.

- If I enclose the attached code in a For loop, and start each iteration with the last buffer number, the 'requested' and 'actual' buffer numbers agree for a time (even if the 'requested' and 'actual' buffer numbers disagreed in the previous iteration).

 

Do you have some recommendations for how to fix this?

 

Thanks for your help!

 

Download All
0 Kudos
Message 1 of 4
(3,593 Views)

Grab only has one or two buffers, so if you miss one before the next buffer arrives, it is gone for good.  Instead, use the low level controls to set up a loop acquisition.  Pretty much a sequence acquisition, but repeats continuously.  This gives you a little more room for system jitter, when Windows goes off to do something else for a fraction of a second.  Set it up with a second or so of buffer images.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 4
(3,574 Views)

Hi pmk01,

 

A few thoughts:

 

1) If it is essential to you to get the buffer number you're asking for, you should change the "Overwrite Mode" attribute. See attached screenshot for how to do that in MAX and LabVIEW. We default to "GetNewest", which means if the buffer you're requesting isn't available, we'll just give you whatever is newest. Another option is "GetOldest", which (as you might expect) will give you the oldest available. What you should use is "Fail." This means if you ask for buffer 512 and it's not available because it's already been overwritten, we'll give you an error instead of returning 514 or 520 or whatever.

 

2) The real question though is why aren't you able to get the buffer you're asking for. My guess is that you're not using enough buffers. Internally, ConfigureGrab uses 5 buffers (you can see that if you drill down into the underlying LabVIEW code). The driver will reserve half of those (rounded down, so 2 in this case) to keep available for the camera to write to, so that means that you as a user only have a window of 3 buffers you can ask for at any given moment. That camera is really fast (~160fps) to have such a small window of available buffer numbers for you to extract, so to me it seems really easy to get into a state where you're asking for a buffer that's so far in the past that it has been overwritten already. I would definitely bump up that number of buffers significantly (try 10? 20? 50? 100?) and see if you're still having problems. You can do that by changing the code behind ConfigureGrab OR you can use the low-level ConfigureAcquisition as a drop in replacement. Configure Acquisition takes the number of buffers as an argument and you'll also have to add "Continuous" as an argument as well.

 

Try that out and let me know how that goes and if you have any questions about this.

 

-Katie

Software Engineer, Vision Acquisition Software

Download All
0 Kudos
Message 3 of 4
(3,572 Views)

I think this suggestion works - I replaced the IMAQdx "Configure Grab" with "Configure Acquisition" (500 frame buffer) followed by "Start Acquisition". Thanks for your help!

0 Kudos
Message 4 of 4
(3,539 Views)