Stillcolor snap programming – National Instruments Image Acquisition Software User Manual

Page 36

Advertising
background image

Chapter 3

Programming with NI-IMAQ

NI-IMAQ User Manual

3-16

©

National Instruments Corporation

The main processing loop of the code shows how to process each buffer
acquired in sequential order.

Performing a Ring Acquisition Using Low-Level Functions

The

LLRing.c

example demonstrates how to perform a ring acquisition

using low-level calls. The example sets up a continuous acquisition to
multiple buffers allocated by NI-IMAQ.

As described in the low-level snap example, the program retrieves the
acquisition window width of the selected camera and aligns it on a 32-bit
boundary. It then creates a buffer list to describe the acquisition buffers.
Next, the program sets the ROI to the acquisition window width. The
program calculates the correct memory requirements of the frame buffer.
However, this is not necessary if you choose to use the default acquisition
window width, rowPixels, and ROI. In this case, NI-IMAQ will allocate the
correct size buffer if you pass a NULL as the size parameter to

imgCreateBuffer

. The buffer is created and the buffer list is configured

for each buffer element in the ring. The memory is locked and the image
acquisition is started asynchronously.

The main processing loop of the code shows how to wait for the first buffer
to be filled and subsequently processed. NI-IMAQ returns a value of

0xFFFFFFFF

as the IMG_ATTR_LAST_VALID_BUFFER attribute until

the successful acquisition of the first buffer. To guarantee that you wait for
the acquisition of a new buffer in a ring with more than one buffer, you can
loop on the attribute IMG_ATTR_LAST_VALID_BUFFER until it
changes. If your buffer analysis requires many computations, call

imgSessionExamineBuffer

to extract the desired buffer from the live

sequence. When using

imgSessionExamineBuffer

, the buffer requested

is literally pulled from the looping sequence for the duration of the analysis.
Use

imgSessionReleaseBuffer

to return the buffer to the continuous

sequence.

StillColor Snap Programming

You can use the high-level snap function to acquire StillColor images from
either composite or RGB video sources. As shown in Figure 4-6, acquiring
a StillColor image is identical to acquiring a monochrome image except for
two session attribute settings. For more information on StillColor, see
Appendix A, StillColor.

UM.book Page 16 Monday, July 13, 1998 9:49 AM

Advertising