To download NI software, including the products shown below, visit ni.com/downloads.
Overview
The example demonstrates how to perform a buffered acquisition and write frames to a AVI file.
Description
This example demonstrates a low-level IMAQdx acquisition that uses a configurable number of buffers for asynchronous operation.
The image frames are subsequently saved to a AVI file. Since the low-level function of IMAQdx already features buffering no additional buffering is required.
Requirements
Software
Hardware
Steps to Implement or Execute Code
Additional Information or References
Remark:
A previous version of this example used a queue to store images to use a producer consumer pattern. The problem with this approach is mainly that not the images themselves are buffered but merely the references are buffered in the queue.
So in case the image buffer is overwritten in the maintime, the program can not detect that and therefore produces a false sense of security.
Since the low-level IMAQdx functions already offer buffered acquisition no producer consumer pattern is necessary.
What Is the Difference Between NI-IMAQ, NI-IMAQdx, and NI-IMAQ I/O?
http://digital.ni.com/public.nsf/allkb/0564022DAFF513D2862579490057D42E
**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text 'NIVerified'. Read here for more information about the new Example Guidelines and Community Platform.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
But if the producer grabs images far faster than the consumer, the buffer will always be full. How to slove this situation?
Did you solve this problem? I'm about to implement this code into an application that I'm building and can see this being an issue. My initial thought is to simply time the producer to ensure that the consumer can keep up but I'm not sure if this will be adequate.
Thanks
Stephen
My problem using a similar structure is that with a high quality (around 950-1000) the playback video will be read too fast (in reality it is recorded too slow). I record 1000 frames at 30 fps (camera set to 30 fps, as well as AVI file). I use MJPEG codec. I can see that the processed fps is low while recording, around 23-24 fps. The created video file is 33s, which is entirey correct (1000f/33s=~30 fps). Therefore video seems to be played fast.
I try to understand where the bottleneck is. I though that by using parallel loops (producer/consumer + queue) the processing would run on its own indenpendently of the producer. It seems this is not working in this way. The only way to tackle this problem was to adjust the quality on Create AVI file VI. This is quite unclear what this quality is though. I also checked elements in the queue with Get Queue Status VI, and it seems the number of elements in it is stable and close to 0.