Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

IMAQdx Grab images using buffer in memory

Hi Paul & Eric,

 

I also noticed that the circular buffer has the 50% limit around an year ago.

I attached an example code to easily reproduce the issue.

You can try to adjust the time to delay the process loop, then you'll find that the queue elements start to accumlate.

Whenever it goes further than 250, the initial of the ring buffer start to be overwritten.

You'll find that the image "flick" and bump to the latest image instead of the #251 buffer.


I think this is why Paul indicated that he can only utilize "half" of the assigned buffer.

I also really would like to know why the driver acts this way.

If I needs 250 images' buffer for acquisition / processing latency, I really have to address 500 image buffer to make this application work.

 

Do you have any suggestion for us to correctly implement the low-level IMAQdx API?

 

Thank you

 

Ting 

 

0 Kudos
Message 31 of 32
(1,703 Views)

Hi Ting,

 

Due to how buffers are queued to the underlying hardware, there has to be some number of buffers that are inaccessible as they are waiting to be filled by the hardware. Currently as you noticed, this threshold is set to 50% and is not configurable. This value represents the typical usage of a larger ring size, which is to ensure images are not dropped by either the hardware underflowing on available buffers and the user has access to a large number of buffers. There is no single magic value that is best for every application. We are looking into ways to make this easily configurable in the future.

 

As to your application, I'm not sure you're approaching the problem in the best way in your example. You code ends up calling Get Image twice for every buffer, so you end up decoding/copying the buffer twice. My suggestion, which would solve the problem of the 50% threshold and also be more efficient, would be to create your own circular queue of images (probably represented as two individual queues of images that you bounce images between). Your producer loop would acquire into a free buffer, display it and then queue it to the consumer loop. Your consumer loop would de-queue it, process it, and then queue it back to the free image buffer list for the producer loop to use again.

 

Eric

0 Kudos
Message 32 of 32
(1,656 Views)