Image Streaming to Binary File (with Backlog)

Publish Date: Oct 11, 2012 | 0 Ratings | 0.00 out of 5 | Print | Submit your review

The attached code shows two different LabVIEW coding architectures for streaming IMAQ images to a binary file. One VI uses a Producer-Consumer loop design pattern, while the other uses a Single loop design pattern. The Producer-Consumer architecture has the added benefit of using a queue system to transfer data from the image acquisition loop (producer) to the processing loop (consumer). The Single loop architecture is slightly less complex and is a good starting point for less-experienced LabVIEW users.

In general vision applications, if image processing takes longer than image acquisition, then it is inevitable that an error or unexpected behavior will occur. A "backlog" will be present when this happens, meaning that the processing portion of the code lags behind the acquisition portion (e.g. buffer #40 may have just been acquired and transferred to memory, but the code is still processing buffer #25). The backlog in these examples is not meant to prevent such behavior from happening, but serves as an indicator to the user that eventually a buffer overflow could occur.

With its queue system, the Producer-Consumer VI has the added benefit of never missing any frames while streaming images to disk, even when a backlog occurs. This is not something that is guaranteed in the Single loop architecture. Both VI's can simulate the backlog by a user-modifiable "Delay" field on their respective front panels. Begin incrementing the delay from 0ms until you see the backlog slowly rise, indicating the processing lag.

Once the acquisition has completed, the binary file that was created can be read back with the Read Binary File from Disk VI.

Steps for Using the Code

  1. Download and extract the attached zip file.
  2. Open the main project file, Image Streaming Project.lvproj
  3. Underneath the My Computer heading, launch either Producer-Consumer Stream to Disk.vi or Single Loop Stream to Disk.vi.
  4. Enter the correct information in the controls and file path fields on the front panel.
  5. Run the VI. Stop the VI when ready.
  6. Open Read Binary File From Disk.vi and point to the correct file path for the binary file to display the image frames.

Please refer to the comments within the block diagrams for more information about the code.

Please Note: Currently, the example is only written for IMAQ image acquisitions. Code for IMAQdx-based acquisitions will come soon.

Back to Top

Bookmark & Share


Downloads


Ratings

Rate this document

Answered Your Question?
Yes No

Submit