NI-IMAQ User Manual
NI-IMAQ User Manual
TM
Worldwide Offices
Australia 1800 300 800, Austria 43 0 662 45 79 90 0, Belgium 32 0 2 757 00 20, Brazil 55 11 3262 3599,
Canada (Calgary) 403 274 9391, Canada (Montreal) 514 288 5722, Canada (Ottawa) 613 233 5949,
Canada (Québec) 514 694 8521, Canada (Toronto) 905 785 0085, Canada (Vancouver) 514 685 7530,
China 86 21 6555 7838, Czech Republic 420 2 2423 5774, Denmark 45 45 76 26 00,
Finland 385 0 9 725 725 11, France 33 0 1 48 14 24 24, Germany 49 0 89 741 31 30, Greece 30 2 10 42 96 427,
India 91 80 51190000, Israel 972 0 3 6393737, Italy 39 02 413091, Japan 81 3 5472 2970,
Korea 82 02 3451 3400, Malaysia 603 9131 0918, Mexico 001 800 010 0793, Netherlands 31 0 348 433 466,
New Zealand 1800 300 800, Norway 47 0 66 90 76 60, Poland 48 0 22 3390 150, Portugal 351 210 311 210,
Russia 7 095 238 7139, Singapore 65 6226 5886, Slovenia 386 3 425 4200, South Africa 27 0 11 805 8197,
Spain 34 91 640 0085, Sweden 46 0 8 587 895 00, Switzerland 41 56 200 51 51, Taiwan 886 2 2528 7227,
Thailand 662 992 7519, United Kingdom 44 0 1635 523545
For further support information, refer to the Technical Support and Professional Services appendix. To comment
on the documentation, send email to [email protected].
Warranty
The media on which you receive National Instruments software are warranted not to fail to execute programming instructions, due to defects
in materials and workmanship, for a period of 90 days from date of shipment, as evidenced by receipts or other documentation. National
Instruments will, at its option, repair or replace software media that do not execute programming instructions if National Instruments receives
notice of such defects during the warranty period. National Instruments does not warrant that the operation of the software shall be
uninterrupted or error free.
A Return Material Authorization (RMA) number must be obtained from the factory and clearly marked on the outside of the package before
any equipment will be accepted for warranty work. National Instruments will pay the shipping costs of returning to the owner parts which are
covered by warranty.
National Instruments believes that the information in this document is accurate. The document has been carefully reviewed for technical
accuracy. In the event that technical or typographical errors exist, National Instruments reserves the right to make changes to subsequent
editions of this document without prior notice to holders of this edition. The reader should consult National Instruments if errors are suspected.
In no event shall National Instruments be liable for any damages arising out of or related to this document or the information contained in it.
EXCEPT AS SPECIFIED HEREIN, NATIONAL INSTRUMENTS MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AND SPECIFICALLY DISCLAIMS ANY WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. CUSTOMER’S RIGHT TO RECOVER DAMAGES CAUSED BY FAULT OR NEGLIGENCE ON THE PART OF
NATIONAL INSTRUMENTS SHALL BE LIMITED TO THE AMOUNT THERETOFORE PAID BY THE CUSTOMER. NATIONAL INSTRUMENTS WILL NOT BE LIABLE FOR
DAMAGES RESULTING FROM LOSS OF DATA, PROFITS, USE OF PRODUCTS, OR INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY
THEREOF. This limitation of the liability of National Instruments will apply regardless of the form of action, whether in contract or tort, including
negligence. Any action against National Instruments must be brought within one year after the cause of action accrues. National Instruments
shall not be liable for any delay in performance due to causes beyond its reasonable control. The warranty provided herein does not cover
damages, defects, malfunctions, or service failures caused by owner’s failure to follow the National Instruments installation, operation, or
maintenance instructions; owner’s modification of the product; owner’s abuse, misuse, or negligent acts; and power failure or surges, fire,
flood, accident, actions of third parties, or other events outside reasonable control.
Copyright
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying,
recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National
Instruments Corporation.
Trademarks
CVI™, IMAQ™, LabVIEW™, Measurement Studio™, National Instruments™, NI™, NI-CAN™, ni.com™, NI-DAQ™, NI Developer Zone™,
NI-IMAQ™, RTSI™, and StillColor™ are trademarks of National Instruments Corporation.
Product and company names mentioned herein are trademarks or trade names of their respective companies.
Patents
For patents covering National Instruments products, refer to the appropriate location: Help»Patents in your software, the patents.txt file
on your CD, or ni.com/patents.
Chapter 1
Introduction to NI-IMAQ
About the NI-IMAQ Software .......................................................................................1-1
Application Development Environments ........................................................1-2
Fundamentals of Building Applications with NI-IMAQ ...............................................1-2
Architecture .....................................................................................................1-2
The NI-IMAQ Libraries ..................................................................................1-3
Creating an Application...................................................................................1-4
Sample Programs.............................................................................................1-4
Chapter 2
Software Overview
Introduction....................................................................................................................2-1
Generic Functions ..........................................................................................................2-2
High-Level Functions ....................................................................................................2-2
Camera Control Functions...............................................................................2-2
Snap Functions ................................................................................................2-3
Grab Functions ................................................................................................2-3
Ring and Sequence Functions .........................................................................2-3
Signal I/O Functions........................................................................................2-4
Miscellaneous Functions .................................................................................2-5
Low-Level Functions .....................................................................................................2-5
Acquisition Functions......................................................................................2-5
Attribute Functions..........................................................................................2-6
Buffer Management Functions ........................................................................2-6
Interface Functions ..........................................................................................2-7
Utility Functions..............................................................................................2-7
Serial Communication Functions ....................................................................2-8
Chapter 3
Programming with NI-IMAQ
Introduction ................................................................................................................... 3-1
High-Level Functions ..................................................................................... 3-1
Low-Level Functions ...................................................................................... 3-2
Generic Functions ........................................................................................... 3-2
Establishing Interface Connections and Sessions.......................................................... 3-2
Interface Functions.......................................................................................... 3-2
Session Functions............................................................................................ 3-4
Managing Buffers.......................................................................................................... 3-4
Camera Attributes.......................................................................................................... 3-5
NI-IMAQ Status Signals ............................................................................................... 3-6
Line Scan Image Acquisition ........................................................................................ 3-8
Geometric Definitions ................................................................................................... 3-8
Introductory Programming Examples ........................................................................... 3-9
High-Level Snap Functions ............................................................................ 3-9
High-Level Grab Functions ............................................................................ 3-10
High-Level Sequence Functions ..................................................................... 3-12
High-Level Ring Functions............................................................................. 3-13
High-Level Signal I/O Functions.................................................................... 3-16
Advanced Programming Examples ............................................................................... 3-17
Performing a Snap Using Low-Level Functions............................................. 3-17
Performing a Grab Using Low-Level Functions............................................. 3-18
Performing a Sequence Acquisition Using Low-Level Functions.................. 3-18
Performing a Ring Acquisition Using Low-Level Functions ......................... 3-19
Chapter 4
Programming with NI-IMAQ VIs
Introduction ................................................................................................................... 4-1
Location of NI-IMAQ Examples................................................................................... 4-2
Location of the NI-IMAQ VIs....................................................................................... 4-2
Common NI-IMAQ VI Parameters ............................................................................... 4-5
Buffer Management....................................................................................................... 4-6
NI-IMAQ Acquisition Types ........................................................................................ 4-7
Snap................................................................................................................. 4-7
Grab................................................................................................................. 4-7
Sequence ......................................................................................................... 4-8
Ring................................................................................................................. 4-9
Acquisition VIs.............................................................................................................. 4-9
High-Level ...................................................................................................... 4-9
Low-Level ....................................................................................................... 4-9
Bayer Decoded Acquisition ............................................................................ 4-10
Triggering ......................................................................................................................4-11
Image Display ................................................................................................................4-12
Camera Attributes ..........................................................................................................4-13
Error Handling ...............................................................................................................4-15
Error Code Format .........................................................................................................4-16
Chapter 5
Programming with ActiveX Controls
Introduction....................................................................................................................5-1
Documentation and Examples .......................................................................................5-1
IMAQ Vision for Visual Basic Organization ................................................................5-2
cwimaq.ocx......................................................................................................5-2
CWIMAQ Control ............................................................................5-2
CWIMAQVision Control..................................................................5-3
CWIMAQViewer Control.................................................................5-3
cwmv.ocx.........................................................................................................5-3
CWMachineVision Control ..............................................................5-3
ActiveX Objects ..............................................................................................5-4
Buffer Management .......................................................................................................5-4
Acquire an Image...........................................................................................................5-4
One-Shot Acquisition ......................................................................................5-5
Continuous Acquisition ...................................................................................5-5
Triggering ......................................................................................................................5-6
Display an Image ...........................................................................................................5-7
Camera Attributes ..........................................................................................................5-8
Error Handling ...............................................................................................................5-9
Warnings ........................................................................................................................5-10
Appendix A
Color Basics
Appendix B
Variable Height Acquisition
Chapter C
NI-IMAQ for LabVIEW Real-Time
Appendix D
Technical Support and Professional Services
Glossary
Index
The NI-IMAQ User Manual contains information you need to get started
with NI-IMAQ.
Conventions
The following conventions appear in this manual:
» The » symbol leads you through nested menu items and dialog box options
to a final action. The sequence File»Page Setup»Options directs you to
pull down the File menu, select the Page Setup item, and select Options
from the last dialog box.
♦ The ♦ symbol indicates that the following text applies only to a specific
product, a specific operating system, or a specific software version.
bold Bold text denotes items that you must select or click in the software, such
as menu items and dialog box options. Bold text also denotes parameter
names.
monospace Text in this font denotes text or characters that you should enter from the
keyboard, sections of code, programming examples, and syntax examples.
This font is also used for the proper names of disk drives, paths, directories,
programs, subprograms, subroutines, device names, functions, operations,
variables, filenames and extensions, and code excerpts.
monospace bold Bold text in this font denotes the messages and responses that the computer
automatically prints to the screen. This font also emphasizes lines of code
that are different from the other examples.
monospace italic Italic text in this font denotes text that is a placeholder for a word or value
that you must supply.
Related Documentation
The following documents contain information that you might find helpful
as you read this manual:
• Your National Instruments IMAQ hardware user manual
• Getting Started With Your IMAQ System
• NI-IMAQ Function Reference Help
• NI-IMAQ VI Reference Help
NI-IMAQ has both high-level I/O functions for maximum ease of use
and low-level I/O functions for maximum flexibility and performance.
Examples of high-level functions are snap and grab image acquisition.
Examples of low-level functions are buffer setup and video configuration.
NI-IMAQ enhances the performance of National Instruments IMAQ
devices because it lets multiple devices operate at their peak performance.
Note Although NI-IMAQ has been tested with these ADEs, it also may work with
other ADEs.
If you are using Visual Basic, NI-IMAQ supports the CWIMAQ control in
IMAQ Vision for Measurement Studio. For more information about the
CWIMAQ control, refer to Chapter 5, Programming with
ActiveX Controls.
LabVIEW
Vision Builder
C Applications IMAQ Vision Applications
NI-IMAQ DLL
(Low- and High-Level API)
Creating an Application
This section outlines the process for developing NI-IMAQ applications
using C for Windows 2000/NT/XP/Me/98. Detailed instructions about
creating project and source files are not included. For information about
creating and managing project files, refer to the documentation included
with your particular development environment.
Sample Programs
Refer to the readme.rtf file located in your target installation directory
for the latest details on NI-IMAQ sample programs. These programs are
installed in the sample subdirectory under the target installation folder if
you elected to install the sample files.
Introduction
NI-IMAQ functions are grouped according to the following classes:
• Generic functions
• High-level functions
– Camera Control functions
– Snap functions
– Grab functions
– Ring and Sequence functions
– Signal I/O functions
– Miscellaneous functions
• Low-level functions
– Acquisition functions
– Attribute functions
– Buffer Management functions
– Interface functions
– Utility functions
– Serial Communication functions
The generic and high-level functions appear within each function class in
the logical order you might need to use them. The low-level functions
appear within each function class in alphabetical order.
Generic Functions
Use generic functions in both high-level and low-level applications.
High-Level Functions
Use high-level functions to quickly and easily capture images. If you need
more advanced functionality, you can mix high-level functions with
low-level functions.
Snap Functions
Snap functions capture all or a portion of a single frame or field to the user
buffer.
Grab Functions
Grab functions start a continuous image acquisition to a user buffer. Any
frame or field can be copied from the grab buffer to another user buffer.
Miscellaneous Functions
Miscellaneous functions set and get the acquisition window region of
interest and return information such as session status and buffer sizes.
Low-Level Functions
Use low-level functions when you require more direct hardware control.
Acquisition Functions
Use acquisition functions to configure, start, and abort an image
acquisition, or examine a buffer during an acquisition.
Attribute Functions
Use attribute functions to examine and change NI-IMAQ or camera
attributes.
Interface Functions
Interface functions load and control the selected IMAQ device and
cameras. These functions use information stored by Measurement &
Automation Explorer (MAX).
Utility Functions
Use utility functions to display an image in a window, save an image to a
file, or get detailed error information.
Introduction
The NI-IMAQ application programming interface (API) is divided into
three groups: high-level functions, low-level functions, and generic
functions. With the high-level functions, you can write programs quickly
without having to learn the details of the low-level API and driver. The
low-level functions give you finer granularity and control over the image
acquisition process, but you must understand the API and driver in greater
detail. Generic functions allow you to set up interfaces and sessions and
close both when you are finished.
Note The high-level functions call low-level functions and use certain attributes that are
listed in the high-level function description in the NI-IMAQ Function Reference Help.
Changing the value of these attributes while using low-level functions affects the operation
of the high-level functions.
High-Level Functions
The high-level function set supports four basic types of image acquisition:
• Snap acquires a single frame or field to a buffer.
• Grab performs an acquisition that loops continually on one buffer. You
obtain a copy of the acquisition buffer by grabbing a copy to a separate
buffer that can be used for analysis.
• Sequence performs an acquisition that acquires a specified number of
buffers, then stops.
• Ring performs an acquisition that loops continually on a specified
number of buffers.
The high-level function set also allows simple triggered acquisitions and
the generation of external signals on the trigger lines.
Low-Level Functions
The low-level function set supports all types of acquisition. Use low-level
functions to perform the following tasks:
• Create a custom acquisition sequence or ring.
• Create and manage buffers.
• Set session and interface attributes to adjust image quality and size.
• Start a synchronous or asynchronous acquisition.
• Extract buffers out of a live acquisition for analysis.
Generic Functions
The generic function set can be used in combination with both high- and
low-level functions to perform the following tasks:
• Set up the interface and session.
• Close the interface and session when you are finished with the
application.
Interface Functions
Use interface functions to query the number of available interfaces,
establish a connection to, control access to, and initialize hardware.
All parameters configured in MAX for an IMAQ device are associated
with an interface name. You can have one device associated with more
than one interface name, which allows you to have several different
configurations for one device. You use the interface name to refer to
the device in the programming environment.
You can edit existing interfaces or create new interfaces by using MAX.
You also can use MAX to configure the default state of a particular
interface.
Before you can acquire image data successfully, you must open an interface
by using the imgInterfaceOpen function. imgInterfaceOpen requires
an interface name and returns a handle to this interface. NI-IMAQ then uses
this handle to reference this interface when using other NI-IMAQ
functions.
Session Functions
Use session functions to configure the type of acquisition you want
to perform using a particular interface. After you have established a
connection to an interface, create a session and configure it to perform
the type of acquisition you require.
This example opens an interface named img0 and then creates a session
to acquire images. When the program is finished with the interface and
session, it then closes both handles using the imgClose function.
For a complete list of the available session functions, refer to the NI-IMAQ
Function Reference Help.
Managing Buffers
NI-IMAQ can automatically perform buffer management, or you can
perform buffer management manually. If the high-level acquisition
routines (imgSnap, imgGrab, imgSequenceSetup, and imgRingSetup)
are initialized with NULL pointers for buffer addresses, NI-IMAQ
automatically allocates a buffer and returns the value of the buffer pointer.
After you obtain a buffer pointer, you can use this pointer in successive
calls.
For greater control of the acquisition buffers, create buffers with a memory
allocation routine (for example, malloc) or use the low-level function
imgCreateBuffer. When creating buffers using either approach, dispose
of the buffers using free or imgDisposeBuffer when applicable to free
PC memory.
Camera Attributes
The camera attributes allow you to control camera-specific functions, such
as integration time and pixel binning, directly from NI-IMAQ. You also
can set these attributes in MAX on the Advanced tab. Information about
specific attributes for your camera is contained in <my camera>.txt,
which can be found in the ni-imaq/camera info directory. For more
information about camera attributes and their uses, refer to the camera
documentation.
All parameters configured for a camera type are stored in a camera (.icd)
file. The camera file is then associated with a specific channel on an IMAQ
device. The camera file includes information about the video signal timing
and the input signal range of the video signal.
The camera attribute file lists all attributes for the camera. Each attribute
description contains the following four fields:
• Attribute Name contains the name of the attribute in quotes.
• Description contains a brief description of the camera.
• Data Type contains the data type of the attribute—String, Integer,
or Float.
– String indicates that there are several valid values for this attribute
that are expressed as strings.
– Integer indicates that the attribute value is a numeric value of type
integer.
– Float indicates that the attribute value is a numeric value of type
floating point.
• Possible Values contains a list of valid String, Integer, or Float
values.
Note The spelling and syntax of the Attribute Name and string values must match the
camera attribute file exactly.
AQ_IN_PROGRESS
Board Initiates All Image
Acquisition Data In
Memory
FRAME_START
First Valid Last Valid
Pixel Acquired Pixel Acquired
By Board By Board
FRAME_DONE
BUF_COMPLETE
Board Initiates
Acquisition
All Image
Data In
Memory
You can use the NI-IMAQ status signals for many purposes. You can
generate pulses based on the assertion of any of these signals. Pulse
generation allows you to generate specific timing pulses based on
acquisitions to control other aspects of your system, such as a strobe light.
Furthermore, you can configure callback functions that are invoked based
on any of these signals. For example, to initiate an image processing routine
as soon as an image is in memory, configure a callback containing image
processing code to be invoked when Buffer Complete is asserted.
Triggering line scan images is similar to triggering area scan images. Using
the imgSessionTriggerConfigure function, you can trigger the start of
each buffer. The imgSessionLineTrigSource function also allows you
to trigger each line of the image, not just the start of the image.
For example, if you are using a conveyor belt, you can use an encoder to
trigger each line of the image and synchronize the movement of the
conveyor belt and the image acquisition.
FRAME_START and FRAME_DONE status signals are not valid for a line
scan acquisition unless each buffer is triggered. Skip count is not supported
for line scan acquisitions. A continuous line scan acquisition into onboard
memory is not supported. A continuous line scan acquisition into system
memory is supported.
Geometric Definitions
The following list defines several terms you should be familiar with when
performing image acquisition tasks:
• A sync window is the area defined by the horizontal synchronization
pulse (HSYNC) and the vertical synchronization pulse (VSYNC).
• An acquisition window is the image size specific to a video standard or
camera resolution. The default is set by your specific camera file.
The window starting position varies according to camera.
• A region of interest (ROI) is a hardware-programmable rectangular
portion of the acquisition window. This is a specific area of the image
to acquire.
Interface Type
(640,480)
Note You can find the code examples discussed in this section in the ni-imaq\samples
directory.
When you invoke a snap, it initializes the device and acquires the next
incoming video frame (or field) to a buffer. Use a snap for low-speed or
single-capture applications in which ease of programming is essential.
Figure 3-3 illustrates a typical snap programming order.
imgInterfaceOpen opens
imgInterfaceOpen and configures the interface
according to the file set up by
Measurement & Automation Explorer.
The sample then calls a process function to analyze the image. When the
program is finished, it calls imgClose with the interface handle and sets
the freeResources flag to TRUE. This instructs NI-IMAQ to free all of the
resources associated with this interface, which releases the session as well
as the memory buffer allocated by imgSnap.
imgInterfaceOpen opens
imgInterfaceOpen and configures the interface
according to the file set up by MAX.
imgSessionStartAcquisition starts
imgSessionStartAcquisition
the acquisition into a driver buffer.
imgInterfaceOpen opens
imgInterfaceOpen and configures the interface
according to the file set up by MAX.
For certain applications, you can temporarily extract a buffer from the ring
to prevent it from being overwritten during the next pass of the ring. Use
the imgSessionExamineBuffer and imgSessionReleaseBuffer
functions to do this. Figure 3-6 illustrates a typical ring programming order.
imgInterfaceOpen opens
imgInterfaceOpen and configures the interface
according to the file set up by MAX.
You can initiate any of the four types of acquisitions from an external
trigger source by using imgSessionTriggerConfigure. For sequence
and ring acquisitions, you can choose to trigger only the first buffer in the
list, or you can choose to trigger each buffer in the list. After you use this
function to set up the trigger, any acquisition performed on the session
waits for a trigger. Use imgSessionTriggerClear to remove the trigger
settings from the session.
Some applications need to send signals out from the IMAQ hardware to an
external device. You can drive many types of signals out of the trigger lines
by using imgSessionTriggerDrive. The parameters of this function
include a trigger line number, the polarity of the line, and what to drive on
the line. You can use a steady state value of high or low or one of the
internal state signals of the hardware, such as acquisition in progress. When
you need to generate specific pulses, use imgPulseCreate and
imgPulseStart.
Figure 3-7 shows the outline of a program that waits for an external
trigger on line 1 before acquiring a single image. The program also
configures the driver to assert RTSI trigger line 3 when the acquisition is
finished. The trigsnap.c example contains C code that implements this
program.
imgInterfaceOpen opens
imgInterfaceOpen and configures the interface
according to the file set up by
Measurement & Automation Explorer.
imgSessionTriggerConfigure
imgSessionTriggerConfigure configures the session so that an acquisition does not
occur until a trigger is received on external trigger line 1.
After the program sets the ROI, it locks the memory and acquires the
image. If you choose to plot the image using the imgPlot function,
you must align the image width on a 32-bit boundary as well.
Keep your analysis code fast to minimize the number of missed frames
during analysis. If you need more time to examine a buffer, set up a
multiple-buffer ring and call imgSessionExamineBuffer to extract
the appropriate buffer from the live sequence.
The main processing loop of the code shows how to process each buffer
acquired in sequential order.
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 appropriate buffer from the
live sequence. When you use imgSessionExamineBuffer, the driver
does not allow you to write new data into that buffer during the analysis.
Use imgSessionReleaseBuffer to return the buffer to the continuous
sequence.
Introduction
LabVIEW is a development environment based on graphical programming.
In contrast to text-based programming languages, where instructions
determine program execution, LabVIEW uses dataflow programming,
where the flow of data determines execution. The NI-IMAQ VI Library,
a series of virtual instruments (VIs) for using LabVIEW with your IMAQ
device, is included with the NI-IMAQ software.
Before you start building your IMAQ application, you should be familiar
with the following basic NI-IMAQ for LabVIEW concepts:
• Location of the NI-IMAQ examples
• Location of the NI-IMAQ VIs in LabVIEW
• Common NI-IMAQ VI parameters
• Buffer management
• NI-IMAQ acquisition types
• Acquisition VIs
• Triggering
• Image Display
• Camera attributes
• Error handling
• Error code format
Figure 4-1. LabVIEW 6.0 and 6.1 Functions Palette with IMAQ Palette
The most commonly used IMAQ VIs are on the Image Acquisition palette.
You can find VIs for basic acquisition and changing attributes. The
Image Acquisition»IMAQ Low Level palette contains VIs for more
advanced applications.
The Image Acquisition»IMAQ Signal I/O palette contains VIs for using
triggers and pulse generation with IMAQ devices.
Many acquisition VIs require that you supply an image buffer to receive the
captured image. You can create this image buffer with the IMAQ Create VI.
Refer to the Buffer Management section for more information. The input
that receives the image buffer is Image in. The Image out output returns
the captured image.
The acquisition VIs use the Step x and Step y inputs to specify a horizontal
and vertical sampling step. The sampling step causes a reduction in spatial
resolution.
Buffer Management
IMAQ Create and IMAQ Dispose manage image buffers in LabVIEW.
IMAQ Create, shown in Figure 4-3, allocates an image buffer. Image
Name is a label for the buffer created. Each buffer must have a unique
name. Image Type specifies the type of image being created. Use 8 bits for
8-bit monochrome images, 16 bits for 10-, 12-, and 14-bit monochrome
images, RGB for RGB color images, and HSL for HSL color images.
If you do not know the image type at design time, you can get the image
type programatically from the session with the LabVIEW property node.
New Image contains information about the buffer, which is initially empty.
When you wire New Image to the Image in input of an image acquisition
VI, the image acquisition VI allocates the correct amount of memory for the
acquisition. If you are going to process the image, you might need to wire
to Border Size. Border Size is the width in pixels created around an image.
Some image processing functions, such as labeling and morphology,
require a border.
IMAQ Dispose, shown in Figure 4-4, frees the memory allocated for the
image buffer. Call this VI only after the image is no longer required for
processing.
Note In LabVIEW 7.0 and later, images appear on LabVIEW block diagrams as purple
wires. In previous LabVIEW versions, images appear as pink wires. There is no difference
in functionality.
Snap
A snap acquires a single image into a memory buffer. Use this acquisition
mode to acquire a single frame or field to a buffer. When you invoke a snap,
it initializes the device and acquires the next incoming video frame (or
field) to a buffer. Use a snap for low-speed or single-capture applications.
Use the IMAQ Snap VI for snap applications. Figure 4-5 shows a
simplified block diagram for using IMAQ Snap.
Grab
A grab is a continuous, high-speed acquisition of data to a single buffer in
host memory. This function performs an acquisition that loops continually
on one buffer. You can get a copy of the acquisition buffer by grabbing a
copy to a LabVIEW image buffer.
You must use two VIs—IMAQ Grab Setup and IMAQ Grab Acquire—for
a grab acquisition in LabVIEW. IMAQ Grab Setup, which you call only
once, initializes the acquisition and starts capturing the image to an internal
software buffer. IMAQ Grab Acquire, which you can call multiple times,
copies the image currently stored in the internal buffer to a G image buffer.
The Immediate? input to IMAQ Grab Acquire determines if the copy takes
place immediately or if it waits for the next vertical blank. If Immediate?
is FALSE, IMAQ Grab waits for the next vertical blank signal and then
transfers the image from the internal buffer to the G image buffer. If
Immediate? is TRUE, IMAQ Grab immediately transfers the image from
the internal buffer to the image buffer, which could result in portions of the
image transferred being acquired at different times. A typical application
for an immediate transfer is the acquisition of images of stationary objects.
After the program finishes copying images, call IMAQ Close once to shut
down the acquisition.
Figure 4-6 shows a simplified block diagram for using IMAQ Grab Setup
and IMAQ Grab Acquire. In this example, you perform an immediate copy
by wiring a TRUE to the Immediate? input.
Sequence
A sequence initiates a variable-length and variable-delay transfer to
multiple buffers. Use a sequence for applications that process multiple
images. You can configure a sequence to acquire every frame or skip a
variable number of frames between each image.
Figure 4-7 shows a simplified block diagram for using IMAQ Sequence.
Place IMAQ Create inside a For Loop to create an array of images for
the Images in input to IMAQ Sequence. To Decimal and Concatenate
create a unique name for each image in the array.
Ring
A ring initiates a continuous high-speed acquisition to multiple buffers.
Use a ring for high-speed applications where you need to perform
processing on every image. You must use multiple buffers because
processing times may vary, depending on other applications and processing
results. You can find an example of a ring acquisition in the
examples\imaq\IMAQ Low Level.llb file.
You can configure a ring to acquire every frame or to skip a fixed number
of frames between acquisitions. In LabVIEW, you must use the NI-IMAQ
low-level VIs to perform a ring.
Acquisition VIs
Two acquisition VI types are available in LabVIEW—high-level and
low-level.
High-Level
You can use the high-level acquisition VIs for basic image acquisition
applications. NI-IMAQ includes VIs for snap, grab, and sequence as
described in the NI-IMAQ Acquisition Types section. You can find
examples of using the high-level acquisition VIs in the
examples\imaq\IMAQ High Level.llb file.
Low-Level
Use the low-level acquisition VIs for more advanced image acquisition
applications, including ring acquisitions and acquisitions to onboard
memory. The low-level VIs configure an acquisition, start an acquisition,
retrieve the acquired images, and stop an acquisition. You can use these VIs
in conjunction with the event VIs to construct advanced IMAQ
applications.
3. Call IMAQ Configure Buffer once for each buffer in the buffer list.
The buffer contains the channel from which to acquire and the number
of frames to skip before acquiring into the buffer.
4. After configuring the buffer list and individual buffers, call
IMAQ Start to start the acquisition asynchronously. IMAQ Start
returns immediately after the acquisition has started.
5. Access the acquired images using either IMAQ Get Buffer or
IMAQ Extract Buffer. IMAQ Get Buffer returns acquired images from
the buffer list and is normally used for snap and sequence acquisitions.
IMAQ Get Buffer waits until the requested buffer has been acquired to
return the image. You also can use this VI to return all images in the
buffer list. IMAQ Get Buffer can retrieve images from a continuous
acquisition only if the acquisition has been stopped.
IMAQ Extract Buffer extracts a buffer from a continuous acquisition
and allows for the examination of a buffer during acquisition. This VI
removes the buffer from the acquisition. NI-IMAQ does not write new
data into the buffer until this VI is called again. Use IMAQ Extract
Buffer in ring acquisitions when you must process images during the
acquisition. IMAQ Copy returns a copy of an acquired image.
IMAQ Copy allows you to create a copy of any buffer at any time
during the acquisition.
6. After an acquisition, release the resources associated with the
acquisition using IMAQ Close. IMAQ Close also stops the acquisition
if one is in progress. If you want to stop the acquisition without
releasing the resources (such as the image buffers), use IMAQ Stop.
Note To find the appropriate values for the gains, use the White Balancing Utility located
at Programs»National Instruments»Vision»Bayer White Balancing Utility.
Triggering
You can use trigger lines on the IMAQ device to link or coordinate a vision
action or function with events external to the computer, such as receiving a
strobe pulse for lighting or a pulse from an infrared detector that indicates
the position of an item on an assembly line. A trigger on an IMAQ device
can be any TTL-level signal. All of the trigger lines are fully bidirectional
so that the device can generate or receive the triggers on any line. The
IMAQ PCI/PXI-1407 and PCI/PXI-1411 have one external trigger line.
The PCI/PXI-1409, PCI/PXI-1422, PCI-1424, and PCI-1428 have four
external trigger lines and seven Real-Time System Integration (RTSI) bus
lines for general purpose use. Use the RTSI triggers to coordinate your
IMAQ device with other National Instruments devices, such as data
acquisition (DAQ) devices.
Note You can use only four of the seven RTSI triggers at once.
Figure 4-9 shows how to use IMAQ Configure Trigger to perform a snap
acquisition based on a trigger.
Image Display
Many image acquisition applications require that one or more images
be displayed. You have three options for displaying images in LabVIEW.
If you have LabVIEW 7.0 or later, you display an image directly on the
front panel using the Image Display control, which is available on the
Vision Controls palette. To display an image on the Image Display control,
place the image control on the front panel of your VI. On the block
diagram, wire the Image Out from an acquisition VI to the Image Display
control terminal. Figure 4-10 illustrates using an Image Display control to
display an image. To view examples using the Image Display control in
LabVIEW 7.0 and later, select Help»Find Examples.
If you have IMAQ Vision 7 for LabVIEW, the image processing and
analysis software for LabVIEW, you can display an image in an external
window using the External Display VIs on the External Display palette.
IMAQ WindDraw, located at Vision Utilities»Display, displays an image
in a separate image window. Figure 4-11 illustrates using
IMAQ WindDraw to display an image acquired using IMAQ Snap. You can
display images in the same way using any acquisition type. For more
information about the display capabilities of IMAQ Vision, refer to the
IMAQ Vision Concepts Manual.
If you do not have either LabVIEW 7.0 or later or IMAQ Vision, you can
display an image on a LabVIEW picture control.
Camera Attributes
The camera attribute VIs allow you to control camera functions, such as
integration time and pixel binning, directly from LabVIEW. These camera
attributes are camera-specific, and you also can set them from MAX on the
Advanced tab in the Properties dialog box. You can find information about
specific attributes for your camera in the <my camera>.txt file, which is
in the camera info directory in your ni-imaq directory. For more
information about the camera attributes and their uses, refer to the camera
documentation.
Note Currently only the IMAQ PCI/PXI-1409, IMAQ PCI/PXI-1422, IMAQ PCI-1424,
and IMAQ PCI-1428 devices support camera attributes.
Use the Set Camera Attribute VI to set the value of a camera attribute.
The camera attribute file mentioned above lists all attributes for the camera
and each attribute description contains four fields: Attribute Name,
Description, Data Type, and Possible Values. The Attribute Name field
contains the name of the attribute in quotes. Wire this field to the Camera
Attribute input on Set Camera Attribute VI. The Data Type field contains
the data type of the attribute which can either be String, Integer, or Float.
String indicates that there is a list of possible values which are listed in
Possible Values in quotes. To set the value of a string attribute, wire the
desired string value to Attribute Value on Set Camera Attribute.
Note The spelling and syntax of the Attribute Name and string values must match the
camera attribute file exactly.
A data type of Integer indicates that NI-IMAQ converts the string wired to
Attribute Value to an integer. Float indicates that NI-IMAQ converts the
string wired to Attribute Value to a floating point number. The valid
numeric values for integer and float data types are listed in Possible
Values. Use Format into String, located on the String subpalette, to
convert numerics into strings for use with the IMAQ Set Camera Attribute
VI. Figure 4-13 shows how to use IMAQ Set Camera Attribute to set the
value of a float camera attribute.
Use the IMAQ Get Camera Attribute VI to get the value of a camera
attribute. Use the camera attribute file described above to find information
about the attributes for your camera. All camera attributes are returned in
string format. If the data type of the attribute is integer or float, use the
Scan from String function, located on the String subpalette, to convert the
string into a numeric. Figure 4-14 shows how to use IMAQ Get Camera
Attribute with Scan from String to get the value of a float camera attribute.
Many cameras are configured with serial commands. Camera files provided
by National Instruments are already programmed with the appropriate
camera serial command set. All serial commands set in the camera file will
be automatically sent to the camera when IMAQ Init is called. If you need
more low-level control over the serial communication between the camera
and your IMAQ device, use the IMAQ Serial Read and IMAQ Serial
Write VIs.
Error Handling
Every NI-IMAQ VI contains an error in input cluster and an error out
output cluster, as shown in Figure 4-16. The clusters contain a Boolean
value that indicates if an error occurred, the code for the error, and the
source or the name of the VI that returned the error. If error in indicates an
error, the VI passes the error information to error out and does not execute
any NI-IMAQ function.
error in (no error) is a cluster that describes the error status before this VI
executes. If error in indicates that an error occurred before this VI was
called, this VI may choose not to execute its function, but just pass the error
through to its error out cluster. If no error has occurred, then this VI
executes normally and sets its own error status in error out. Use the error
handler VIs to look up the error code and to display the corresponding error
message. Using error in and error out clusters is a convenient way to
check errors and to specify execution order by wiring the error output from
one subVI to the error input of the next.
error out is a cluster that describes the error status after this VI executes.
If an error occurred before this VI was called, error out is the same as
error in. Otherwise, error out shows the error, if any, that occurred in
this VI. Use the error handler VIs to look up the error code and to display
the corresponding error message. Using error in and error out clusters is
a convenient way to check errors and to specify execution order by wiring
the error output from one subVI to the error input of the next.
Introduction
Programming with ActiveX controls allows you to easily configure and
perform image acquisition tasks using IMAQ Vision for Visual Basic and
the CWIMAQ control.
cwimaq.ocx
cwimaq.ocx contains three ActiveX controls and a collection of ActiveX
objects. The ActiveX controls are the CWIMAQ control, the
CWIMAQVision control, and the CWIMAQViewer control. Refer to the
ActiveX Objects section for more information about the ActiveX objects.
CWIMAQ Control
Use this control to configure and perform an acquisition from an IMAQ
acquisition device. The CWIMAQ control has property pages that allow
you to modify various properties to configure your acquisition and gather
information about your IMAQ device. All of the functionality available
from the property pages during design time is also available through the
properties of the CWIMAQ control during run-time. The control has
methods that allow you to perform and control acquisitions, as well.
NoteYou must have the NI-IMAQ device driver installed on the target system for the
CWIMAQ control to function.
CWIMAQVision Control
Use this control to analyze and process images and their related data. The
CWIMAQVision control provides methods for reading and writing images
to and from files, analyzing images, and performing a variety of image
processing algorithms on images.
Note You must purchase IMAQ Vision for Measurement Studio to use this control.
CWIMAQViewer Control
Use this control to display images and provide the interface through which
the user will interact with the displayed image. This control includes the
ability to zoom and pan images and to draw regions of interest (ROIs) on
an image. The CWIMAQViewer control has property pages that allow you
to configure the appearance and behavior of the viewer during design time
as well as properties that you can configure during run-time. The control
has methods that allow you to attach images to and detach images from the
viewer for display purposes.
This control is available only if you have Vision for Measurement Studio installed. Contact
your National Instruments sales representative, or visit ni.com to purchase IMAQ Vision
for Measurement Studio.
cwmv.ocx
cwmv.ocx contains one ActiveX control and a collection of ActiveX
objects. Refer to the ActiveX Objects section for more information about
ActiveX objects.
CWMachineVision Control
Use this control to perform high-level machine vision tasks, such as
measuring distances. This control is written entirely in Visual Basic using
the methods on the CWIMAQVision and CWIMAQViewer controls. The
source code for the CWMachineVision control is included in the product.
Note This control is available only if you have Vision for Measurement Studio installed.
Contact your National Instruments sales representative, or visit ni.com to purchase IMAQ
Vision for Measurement Studio.
ActiveX Objects
ActiveX objects are classified as input and output objects. Use the objects
to group related input parameters and output parameters to certain methods,
thus reducing the number of parameters that you actually need to pass to
those methods.
Note ActiveX objects in cwimaq.ocx have a CWIMAQ prefix, and objects in cwmv.ocx
have a CWMV prefix.
You must create an ActiveX object before you can use it. You can use the
New keyword in Visual Basic to create these objects. For example, use the
following syntax to create and store an image in a variable named image:
Dim image as New CWIMAQImage
Tip If you intend to develop your application in Visual C++, National Instruments
recommends that you use IMAQ Vision for LabWindows/CVI. However, if you decide
to use IMAQ Vision for Visual Basic to develop applications for Visual C++, you can
create objects using the respective Create methods on the CWIMAQVision control or
CWMachineVision control. For example, to create a CWIMAQImage object, use the
CWIMAQVision.CreateCWIMAQImage method.
Buffer Management
The CWIMAQ control uses the CWIMAQImage object in a
CWIMAQImages collection as the image buffer when performing an
acquisition. You can access this collection using the Images property on the
CWIMAQ control. Set the count property of the collection to the number
of buffers that your application requires.
You also can set the number of buffers during design time by setting the
value of Image Count on the Acquisition property page for the CWIMAQ
control. When you start the acquisition, the CWIMAQ control
automatically manages the image type and the size of the images in
the collection.
Acquire an Image
Use the CWIMAQ control to acquire images with a National Instruments
IMAQ device. You can use IMAQ Vision for Visual Basic to perform
one-shot and continuous acquisitions. You can choose the acquisition type
during design time by setting the value of the Acquisition Type combo box
One-Shot Acquisition
Use a one-shot acquisition to start an acquisition, perform the acquisition,
and stop the acquisition using a single method. The number of frames
acquired is equal to the number of images in the images collection. Use the
CWIMAQ.AcquireImage method to perform this operation synchronously.
Use the CWIMAQ.Start method to perform this operation asynchronously.
If you want to acquire a single field or frame into a buffer, set the image
count to 1. This operation is also referred to as a snap. Use a snap for
low-speed or single capture applications. The following code illustrates
a synchronous snap:
Private Sub Start_Click()
CWIMAQ1.AcquisitionType = cwimaqAcquisitionOneShot
CWIMAQ1.AcquireImage
End Sub
If you want to acquire multiple frames, set the image count to the number
of frames you want to acquire. This operation is called a sequence. Use a
sequence for applications that process multiple images. The following code
illustrates an asynchronous sequence when numberOfImages is the
number of images that you want to process:
Private Sub Start_Click()
CWIMAQ1.AcquisitionType = cwimaqAcquisitionOneShot
CWIMAQ1.Images.RemoveAll
CWIMAQ1.Images.Add numberOfImages
CWIMAQ1.Start
End Sub
Continuous Acquisition
Use a continuous acquisition to start an acquisition and continuously
acquire frames into the image buffers, and then explicitly stop the
acquisition. Use the CWIMAQ.Start method to start the acquisition.
Use the CWIMAQ.Stop method to stop the acquisition. If you use a single
buffer for the acquisition, this operation is called a grab. The following
code illustrates a grab:
Private Sub Start_Click()
CWIMAQ1.AcquisitionType = cwimaqAcquisitionContinuous
CWIMAQ1.Start
End Sub
A ring operation uses multiple buffers for the acquisition. Use a ring for
high-speed applications that require processing on every image. The
following code illustrates a ring, where numberOfImages is the number
of images that you want to process:
Private Sub Start_Click()
CWIMAQ1.AcquisitionType = cwimaqAcquisitionContinuous
CWIMAQ1.Images.RemoveAll
CWIMAQ1.Images.Add numberOfImages
CWIMAQ1.Start
End Sub
Triggering
You may need to coordinate a vision event with events that are occurring
outside the computer, such as receiving a strobe pulse for lighting or an
infrared detector pulse indicating the position of an item on an assembly
line. Any TTL-level signal can serve as a trigger for IMAQ image
acquisition devices. All of the lines are fully bidirectional, allowing your
IMAQ device to generate or receive the triggers on any line. The
IMAQ PCI/PXI-1407 and IMAQ PCI/PXI-1411 feature one external
trigger line. The IMAQ PCI/PXI-1409, IMAQ PCI/PXI-1422,
IMAQ PCI-1424, and IMAQ PCI-1428 each feature four external trigger
lines and seven Real-Time System Integration (RTSI) bus lines for general
purpose use. Use these RTSI triggers to coordinate the IMAQ device with
other National Instruments boards, such as data acquisition (DAQ) boards.
Note You can use only four of the seven RTSI triggers at one time.
You can configure triggers during both design time and run-time. At design
time, use the Signal I/O property page of the CWIMAQ control to
configure the triggers. At run-time, use the CWIMAQSignals object, which
you can access through CWIMAQ.Signals to configure the triggers.
Display an Image
Display an image using the CWIMAQViewer control. Use the
CWIMAQViewer.Attach method to attach the image you want the viewer
to display. When you attach an image to a viewer, the image automatically
updates the viewer whenever an operation modifies the contents of the
image. You can access the image attached to the viewer using the
CWIMAQViewer.Image property. Before you attach an image to the
viewer, the viewer already has an image attached by default. Therefore, the
viewer has an image attached to it at all times. You can use the attached
image as either a source image, destination image, or both using the Image
property.
You also can set a default palette during design time using the Menu
property page for the CWIMAQViewer control. You also can change the
color palette during run-time by using the pop-up menu on the viewer.
Camera Attributes
Camera attributes allow you to control camera functions, such as
integration time and pixel binning. These camera attributes are
camera-specific. You can access the camera attributes using
CWIMAQ.CameraAttribute. You also can set them in MAX on the
Advanced tab in the Properties dialog box. You can find information about
specific attributes for your camera in the <my camera>.txt file, which is
in your ni-imaq/camera info directory. For more information about
specific camera attributes and their uses, refer to your camera
documentation.
Note Currently, only the IMAQ PCI/PXI-1422, IMAQ PCI-1424, and IMAQ PCI-1428
devices support camera attributes.
The camera attribute file lists all attributes for the camera where each
attribute description contains four fields: Attribute Name, Description,
Data Type, and Possible Values. The Attribute Name field contains the
name of the attribute in quotation marks. Pass the value of this field to the
Attribute parameter of the CameraAttribute property.
The Data Type field contains the data type of the attribute, which can be
String, Integer, or Float. String indicates that possible values are listed in
quotes in the Possible Values section. To set the value of a String attribute,
set the desired string value for the CameraAttribute.
Note The spelling and syntax of the Attribute Name and string values must match the
camera attribute file exactly.
Error Handling
Errors generated by the CWIMAQ control have an Error Context and a
Status Code associated with them. The CWIMAQErrorContext constants
specify the Error Contexts. The Status Code for an error is a negative value
that corresponds to the actual error that occurred.
There are three ways that errors are reported by the CWIMAQ control:
• Return value of the methods
• Exceptions
• IMAQError event
Warnings
Warnings are different from errors in the following respects:
• They have a positive Status Code.
• They do not generate exceptions, even if ExceptionOnError is
True.
• They generate an IMAQWarning event instead of an IMAQError
event.
You can handle warnings by checking the return value of the methods or by
providing an IMAQWarning event handler.
Introduction to Color
Color is the wavelength of the light the human eye receives when we look
at an object. In theory, the color spectrum is infinite. Humans, however, can
see only a small portion of this spectrum—the portion that goes from the
red edge of infrared light (the longest wavelength) to the blue edge of
ultraviolet light (the shortest wavelength). This continuous spectrum is
called the visible spectrum.
Image Representations
Color images can be represented in several different formats. These
formats can contain all color information from the image or they can
consist of just one aspect of the color information, such as hue or
luminance. The following image representations can be produced using
NI-IMAQ or color IMAQ devices.
RGB
The most common image representation is 32-bit RGB format. In this
representation, the three 8-bit color planes—red, green and blue—are
packed into an array of 32-bit integers. This representation is useful for
displaying the image on the monitor. The 32-bit integer is organized as
where the high-order byte is not used and blue is the low-order byte.
Color Planes
Each color plane can be returned individually. The red, green, or blue plane
is extracted from the RGB image and represented as an array of 8-bit
integers.
Hue, Saturation, and Luminance (HSL) are defined using the Red, Green,
and Blue values in the following formulas:
Luminance = 0.299 × Red + 0.587 × Green + 0.114 × Blue
2 2
Saturation = X +Y
where
Y = (Green – Blue) / 2 and
X = (2 × Red – Green – Blue) / 6
Y X PI 128
Hue = ATN2 (---------,---------) + ------ × ---------
255 255 2 PI
where
Y = (Green – Blue) / 2 and
32-Bit HSL
You also can pack the three 8-bit HSL planes in one array of 32-bit integers,
which is equivalent to the 32-bit RGB representation.
Camera Types
You can use two basic video camera types for color acquisition—RGB
cameras and composite color video cameras.
NI-IMAQ can acquire multiple frames, decode the color information, and
rebuild the image automatically. The output image can be a simple RGB
color image or one of many image representations supported by NI-IMAQ.
You can connect the composite video signal to any of the four input
channels on the PCI/PXI-1408 or PCI/PXI-1409.
Note The IMAQ PCI/PXI-1411 can acquire continuous color images from NTSC or PAL
at 30 frames per second.
Bayer Cameras
Bayer encoding is a method to produce color images with a single imaging
sensor, as opposed to three individual sensors for the red, green, and blue
components of light. This technology greatly reduces the cost of cameras.
The Bayer color filter array (CFA) is a primary color, mosaic pattern of
50% green, 25% red, and 25% blue pixels. Green pixels comprise half of
the total pixels because the human eye gets most of its sharpness
information from green light.
Light travels through the camera lens onto an image sensor that provides
one value for each sensor cell. The sensor is an array of tiny, light-sensitive
diodes called photosites, which converts light into electrical charges. The
sensor is covered by the Bayer CFA so that only one color value reaches any
given pixel. The raw output is a mosaic of red, green, and blue pixels of
different intensity.
When the image is captured, the accumulated charge for each cell is
read and analog values are converted to digital pixel values using an
analog-to-digital (A/D) converter.
In this mode, you supply the IMAQ board a trigger which is asserted when
you want to begin capture. The IMAQ board continues to acquire lines until
the trigger is unasserted. When the acquisition is complete, the driver
returns the number of lines acquired. By using the variable line mode, you
acquire only the amount of data that you need. This technology greatly
enhances performance by minimizing the total amount of data to process.
Examples
If you install the IMAQ examples for your compiler, you can find a
ready-to-run example showing how to acquire a variable number of lines
with a line scan camera.
• In LabVIEW, refer to the LL VHA Ring.vi in the IMAQ Signal
IO.llb.
• In LabWindows/CVI, refer to the VHA Ring.prj in the CVI Samples
folder.
• In Microsoft C++ version 6, refer to the VHA Ring.mdp in the
NI-IMAQ Samples folder.
Development System
The development system is made up of two components—a Pentium-based
host machine using a Windows operating system and a National
Instruments PXI chassis housing a PXI controller. Use the host machine to
configure the PXI controller as an RT target and to develop the application.
Execute the application remotely on the PXI controller.
The two machines communicate with each other over a network connection
and use Measurement & Automation Explorer (MAX) to share
Note You must have a network connection during development to configure your
RT target and download software and code from your host machine. This network
connection is optional at runtime.
Device Functionality
NI 8175 or NI 8176 Supports full functionality
NI 8170 or NI 8156B Does not support RT Video Out
NI 8140 RT Series Does not support RT Video Out or
configuration.
Note The NI 8140 device does not support configuration. The device does not boot into
Windows, where you use MAX to configure the camera and acquisition device settings. If
you choose to use an NI 8140 device as a deployed LabVIEW RT target, you must first use
a controller that supports configuration to configure the camera and acquisition device
settings, and then transfer those settings to the NI 8140 device.
The PXI system must also meet the following minimum system
requirements:
• Windows 2000/NT/XP/Me/98
• Network adapter, floppy disk drive, keyboard, and mouse
• National Instruments IMAQ PXI image acquisition device
• Analog or digital camera and associated cables
• LabVIEW RT run-time license
Deployed System
Once you have configured the host development system, you can set up and
configure additional LabVIEW RT targets for deployment. These deployed
systems use the same hardware and software as the development LabVIEW
RT target, and do not require Windows for configuration.
Host Machine IX
P
IA
M
FN
AR
EM
PXI Chassis
Network
Camera
P P
IX FN
IA
M
IX IA
M
AR FN
AR
EM EM
Camera Camera
Tip Before you begin, locate the following documents to use as references during the
installation process:
• LabVIEW User Manual
• Your National Instruments IMAQ PXI device user manual
• Your National Instruments PXI controller user manual
Table C-2 illustrates the requirements and components of each part of the
NI-IMAQ for LabVIEW RT system—the host machine and the remote PXI
chassis.
Note If you are using a machine running Windows 2000/NT/XP, you must log on as an
administrator or as a user with administrator privileges to install LabVIEW RT.
Note Do not use the same floppy disk that you used for the Configure IMAQ RT utility.
4. Remove the disk from the floppy drive and label it “PXI Boot Disk.”
In the Prepare the PXI Chassis for Image Acquisition section, you will
install the IMAQ device.
You will use Windows on the PXI controller to configure the IMAQ device
and camera. When you are ready to develop and execute your application,
you will boot the controller into LabVIEW RT using the boot disk you
created in the last section.
1. Power on the PXI controller. The system boots into Windows.
Note You must boot the PXI controller into Windows in order to configure the device
and camera. If Windows is not already installed on the PXI controller, refer to the
Troubleshooting NI-IMAQ for LabVIEW RT section for more information.
Note If you purchased your IMAQ PXI image acquisition device and PXI controller at the
same time, your IMAQ image acquisition device and NI-IMAQ software may already be
installed on the PXI controller. If you have MAX installed, use MAX to detect whether you
have the required version of NI-IMAQ installed by clicking the Software folder under My
System. If MAX detects that you have the required version of NI-IMAQ installed, proceed
to the Check the Camera Settings with MAX section.
1
ON
ST
AN
DB
Y
1
2
2 4
Tip For detailed information about installing this device, including unpacking and safety
information, refer to the hardware device-specific documentation.
Note If you are using a digital camera that is not listed in MAX, right-click the channel,
select Camera, and click Search ni.com to download the appropriate camera file.
Note the interface name associated with the camera. You will refer to
the acquisition device later using this interface name. MAX specifies
img0 as the default interface name.
10. When you are satisfied with the property settings, click OK to close
the window.
11. In MAX, right-click the channel associated with the camera and select
Grab.
A live video image opens in the MAX window. Take this opportunity
to focus the camera, adjust its position, and set up the lighting.
Manipulate each of these options until you achieve satisfactory image
conditions.
12. When you are satisfied with the image conditions, click the Grab
button to stop the acquisition and exit MAX.
Note To update the RT configuration with changes, you must run this executable any time
you use MAX to change configuration settings in Windows.
LabVIEW RT lets you provide a unique host name and IP address for the
remote device. To set up the network configuration, the remote device must
be installed on the same network subnet as the host machine.
Note If the remote device is not installed on the same network subnet as the host machine,
use a CAT-5 crossover cable to connect the system.
1. Insert the PXI boot disk into the A:\ drive of the PXI chassis.
2. Shut down Windows and reboot the PXI chassis.
The controller boots up into a text screen displaying the IP address of the
remote device. Notice that the IP address is currently 0.0.0.0.
Note If the controller booted up into Windows, you must edit the BIOS boot settings to
instruct the controller to boot from the floppy drive. Refer to the Troubleshooting NI-IMAQ
for LabVIEW RT section for more information.
Tip Contact the network administrator if you need additional assistance configuring the
remote device on the network.
7. Click Apply to save the network settings for the remote device.
8. Click Yes when MAX prompts you to reboot the remote device.
When the remote system reboots, the designated IP address appears in the
right pane of MAX. The status message Connected – No software
4. Click OK.
Note MAX prompts you that the software updates will overwrite existing software and
requests confirmation before beginning the installation. Click Yes to proceed.
MAX reboots the PXI controller and installs the software that you selected.
You can monitor the progress of the transfer in the dialog box that opens in
the center of the MAX window.
9. Select the name of the device you want to test and click Run Test. You
can view the results of each test in the Test Results dialog box on the
front panel.
10. Click Stop after you have run diagnostics on each of the hardware
devices installed in the PXI chassis.
Remote Display
Remote Display is available in LabVIEW 7.0 or later. Use Remote Display
during development and debugging to view the LabVIEW front panel
Image Display control from the host machine. Use RT Video Out to display
images on a monitor connected to the remote LabVIEW RT system.
When you use Remote Display, the RT target machine must transfer the
image back to host machine across the network. Use the IMAQ Remote
Compression VI, located on the Vision Utilities»IMAQ RT palette, to
minimize network bandwidth consumed for remote display.
RT Video Out
RT Video Out allows you to display images on a monitor that is connected
to the PXI controller. To access this feature, use the IMAQ RT Video Out
VI from the Vision Utilities»IMAQ RT palette.
Note This feature is available only on PXI controllers that feature the i815 chipset, such
as the National Instruments PXI-8175/76 Series controllers.
Tip Try the HL Grab to Real-Time Target with Display example for a demonstration of
interactively setting the RT Video Out display mode.
Why does my PXI controller boot into Windows when I use my PXI
boot disk?
Check the BIOS setting for the Boot Sequence of the PXI controller.
The boot sequence for the PXI controller defined in the BIOS settings must
be set to A,C,... to boot from a floppy disk. If the Boot Sequence setting
is set to boot from the C:\ drive before the A:\ drive, the controller only
boots into Windows. You can find the Boot Sequence setting in the BIOS
Features Setup settings. Refer to the PXI controller user manual for more
information about BIOS settings.
Configuration Errors
Why does ConfigureIMAQRT.exe tell me that it is unable to configure
my interface?
This error occurs when you specify an interface name that contains more
than eight characters.
When you defined the configuration settings in MAX, you saved those
settings in a file that uses the name of the interface plus the.iid extension.
However, because LabVIEW RT supports only files that use the 8.3 naming
convention, any configuration files that have an interface name longer than
eight characters are rejected when you try to copy them to the target device
with ConfigureIMAQRT.exe.
To correct this error, launch MAX from the RT target. Load the original
interface. Right-click that interface and select Save As. Give the interface
a new name that uses eight or fewer characters. When you have saved the
new configuration file, you must remove the old one. Browse to the
<ni-imaq>\data directory and delete the old file. You should now be able
to run ConfigureIMAQRT.exe with no errors.
Note If you are using a monitor that does not support high refresh frequencies, the images
will not display correctly. Refer to the monitor documentation for information about
supported refresh frequencies.
If you searched ni.com and could not find the answers you need, contact
your local office or NI corporate headquarters. Phone numbers for our
worldwide offices are listed at the front of this manual. You also can visit
the Worldwide Offices section of ni.com/niglobal to access the branch
office Web sites, which provide up-to-date contact information, support
phone numbers, email addresses, and current events.
A
A/D Analog-to-digital.
acquisition window The image size specific to a video standard or camera resolution.
active line region The region of lines actively being stored. Defined by a line start [relative to
the vertical synchronization signal (VSYNC)] and a line count.
active pixel region The region of pixels actively being stored. Defined by a pixel start [relative
to the horizontal synchronization signal(HSYNC)] and a pixel count.
address Value that identifies a specific location (or series of locations) in memory.
analog camera A camera that transforms light into pixels and then translates the level of
light for each pixel into an analog video signal.
antichrominance filter Removes the color information from the video signal.
arithmetic operators The multiply, divide, add, subtract, and remainder image operations.
B
b Bit. One binary digit, either 0 or 1.
B Byte. Eight related bits of data, an eight-bit binary number. Also denotes
the amount of memory required to store one byte of data.
back porch The area of the video signal between the rising edge of the horizontal
synchronization signal (HSYNC) and the active video information.
Bayer encoding A method to produce color images with a single imaging sensor, as opposed
to three individual sensors for the red, green, and blue components of light.
binary image An image in which the objects usually have a pixel intensity of 1 (or 255)
and the background has an intensity value of 0.
bit depth The number of bits (n) used to encode the value of a pixel. For a given n,
a pixel can take 2 n different values. For example, if n equals 8 bits, a pixel
can take 256 different values ranging from 0 to 255. If n equals 16 bits, a
pixel can take 65,536 different values, ranging from 0 to 65,535 or –32,768
to 32,767.
black reference level The level that represents the darkest an image can get. See also white
reference level.
blob analysis A series of processing operations and analysis functions that produce some
information about the objects in an image.
C
cache High-speed processor memory that buffers commonly used instructions or
data to increase processing throughput.
D
DAQ Data acquisition. (1) Collecting and measuring electrical signals from
sensors, transducers, and test probes or fixtures and inputting them to a
computer for processing. (2) Collecting and measuring the same kinds of
electrical signals with A/D or DIO boards plugged into a computer, and
possibly generating control signals with D/A and/or DIO boards in the
same computer.
dB Decibel. The unit for expressing a logarithmic measure of the ratio of two
signal levels: dB = 20log10 V1/V2, for signals in volts.
default setting A default parameter value recorded in the driver. In many cases, the default
input of a control is a certain value (often 0).
device Plug-in data or image acquisition board that can contain multiple channels
and conversion devices.
digital camera A camera that transforms light information into pixels and then translates
the level of light for each pixel into a digital number inside the camera.
DMA Direct memory access. A method by which data can be transferred between
computer memory and a device or memory on the bus while the processor
does something else. DMA is the fastest method of transferring data
to/from computer memory.
dynamic range The ratio of the largest signal level a circuit can handle to the smallest
signal level it can handle (usually taken to be the noise level), normally
expressed in decibels.
E
Ethernet A high-speed local area network (LAN) which conforms to the IEEE 802.3
standard.
external trigger A voltage pulse from an external source that triggers an event such as A/D
conversion.
F
field For an interlaced video signal, a field is half the number of horizontal lines
needed to represent a frame of video. The first field of a frame contains all
the odd-numbered lines, the second field contains all of the even-numbered
lines.
FIFO First-in first-out memory buffer. The first data stored is the first data sent
to the acceptor. FIFOs are used on IMAQ devices to temporarily store
incoming data until that data can be retrieved.
front porch The area of a video signal between the start of the horizontal blank and the
start of the horizontal synchronization signal (HSYNC).
ftp File transfer protocol. Protocol based on TCP/IP to exchange files between
computers.
function A set of software instructions executed by a single line of code that may
have input and/or output parameters and returns a value when executed.
G
gamma The nonlinear change in the difference between the video signal brightness
level and the voltage level needed to produce that brightness.
genlock The process of synchronizing a video source to the signal from a separate
video source. The circuitry aligns the video timing signals by locking
together the horizontal, vertical, and color subcarrier frequencies and
phases and generates a pixel clock that clocks pixel data into memory for
display or into another circuit for processing.
grab Performs an acquisition that loops continually on one buffer. You obtain a
copy of the acquisition buffer by grabbing a copy to a separate buffer that
can be used for analysis.
H
hardware The physical components of a computer system, such as the circuit boards,
plug-in boards, chassis, enclosures, peripherals, and cables.
hue Represents the dominant color of a pixel. The hue function is a continuous
function that covers all the possible colors generated using the R, G, and B
primaries. See also RGB.
I
I/O Input/output. The transfer of data to/from a computer system, including
communications channels, operator interface devices, and/or data
acquisition and control interfaces.
image processing Encompasses various processes and analysis functions that you can apply
to an image.
instrument driver A set of high-level software functions, such as NI-IMAQ, that control
specific plug-in computer boards. Instrument drivers are available in
several forms, ranging from a function callable from a programming
language to a virtual instrument (VI) in LabVIEW.
interlaced A video frame composed of two interleaved fields. The number of lines in
a field are half the number of lines in an interlaced frame.
interrupt A computer signal indicating that the CPU should suspend its current task
to service a designated activity.
IRE A relative unit of measure (named for the Institute of Radio Engineers).
0 IRE corresponds to the blanking level of a video signal, 100 IRE to the
white level. Notice that for CCIR/PAL video, the black level is equal to the
blanking level or 0 IRE, while for RS-170/NTSC video, the black level is
at 7.5 IRE.
L
line count The total number of horizontal lines in the picture.
lossy compression Compression in which the decompressed image is visually similar but not
identical to the original image.
luma The brightness information in the video picture. The luma signal amplitude
varies in proportion to the brightness of the video signal and corresponds
exactly to the monochrome picture.
LUT Lookup table. Table containing values used to transform the gray-level
values of an image. For each gray-level value in the image, the
corresponding new value is obtained from the lookup table.
M
MB Megabyte.
memory window Continuous blocks of memory that can be accessed quickly by changing
addresses on the local processor.
N
NI-IMAQ Driver software for National Instruments IMAQ hardware.
noninterlaced A video frame where all the lines are scanned sequentially, instead of
divided into two frames as in an interlaced video frame.
NVRAM Nonvolatile RAM. RAM that is not erased when a device loses power or is
turned off.
O
operating system Base-level software that controls a computer, runs programs, interacts with
users, and communicates with installed hardware or peripheral devices.
P
PAL Phase Alternation Line. One of the European video color standards.
PAL uses 625 lines per frame. See also NTSC.
PCLK Pixel clock signal. Times the sampling of pixels on a video line.
picture aspect ratio The ratio of the active pixel region to the active line region. For standard
video signals like RS-170 or CCIR, the full-size picture aspect ratio
normally is 4/3 (1.33).
pixel Picture element. The smallest division that makes up the video scan line.
For display on a computer monitor, the optimum dimension for each pixel
is square (aspect ratio of 1:1, or the width equal to the height).
pixel aspect ratio The ratio between the physical horizontal size and the vertical size of the
region covered by the pixel. An acquired pixel should optimally be square,
thus the optimal value is 1.0, but typically it falls between 0.95 and 1.05,
depending on camera quality.
pixel clock Divides the incoming horizontal video line into pixels.
pixel count The total number of pixels between two horizontal synchronization signals
(HSYNCs). The pixel count determines the frequency of the pixel clock.
pixel depth The number of bits used to represent the gray level of a pixel.
PLL Phase-locked loop. Circuitry that provides a very stable pixel clock that is
referenced to another signal, such as an incoming horizontal
synchronization signal (HSYNC).
protocol The exact sequence of bits, characters, and control codes used to transfer
data between computers and peripherals through a communications
channel.
R
real time A property of an event or system in which data is processed as it is acquired
instead of being accumulated and processed at a later time.
relative accuracy A measure in LSB of the accuracy of an ADC; it includes all nonlinearity
and quantization errors but does not include offset and gain errors of the
circuitry feeding the ADC.
resolution (1) The number of rows and columns of pixels. An image composed of m
rows and n columns has a resolution of m × n . This image has n pixels
along its horizontal axis and m pixels along its vertical axis.
(2) The smallest signal increment that can be detected by a measurement
system. Resolution can be expressed in bits, proportions, or a percentage
of full scale. For example, a system has 12-bit resolution, one part in
4,096 resolution, and 0.0244 percent of full scale.
RGB Color encoding scheme using red, green, and blue (RGB) color information
where each pixel in the color image is encoded using 32 bits: 8 bits for red,
8 bits for green, 8 bits for blue, and 8 bits for the alpha value (unused).
ROI Region of interest. (1) An area of the image that is graphically selected
from a window displaying the image. This area can be used focus further
processing. (2) A hardware-programmable rectangular portion of the
acquisition window.
RT Series PXI controller National Instruments PXI controller running the RT Engine.
RT Series PXI system National Instruments PXI chassis with an RT Series PXI controller
installed.
RTSI bus Real-Time System Integration Bus. The National Instruments timing bus
that connects IMAQ and DAQ boards directly by means of connectors on
top of the boards for precise synchronization of functions.
S
saturation The amount of white added to a pure color. Saturation relates to the richness
of a color. A saturation of zero corresponds to a pure color with no white
added. Pink is a red with low saturation.
scaling down circuitry Circuitry that scales down the resolution of a video signal.
sync Tells the display where to put a video picture. The horizontal sync indicates
the picture’s left-to-right placement and the vertical sync indicates
top-to-bottom placement.
synchronous Property or operation that begins an operation and returns control to the
program only when the operation is complete.
T
transfer rate The rate, measured in bytes/s, at which data is moved from source to
destination after software initialization and set up operations. The
maximum rate at which the hardware can operate.
time-bounded Characteristic associated with an RT event assuring that the execution time
of the event or task is predictable.
trigger Any event that causes or starts some form of data capture.
trigger control and Circuitry that routes, monitors, and drives external and RTSI bus trigger
mapping circuitry lines. You can configure each of these lines to start or stop acquisition on a
rising or falling edge.
U
UV plane See YUV.
V
VI Virtual Instrument. (1) A combination of hardware and/or software
elements, typically used with a PC, that has the functionality of a classic
stand-alone instrument (2) A LabVIEW software module (VI), which
consists of a front panel user interface and a block diagram program.
video line A video line consists of a horizontal synchronization signal, back porch,
active pixel region, and a front porch.
W
white reference level The level that defines what is white for a particular video system. See also
black reference level.
Y
YUV A representation of a color image used for the coding of NTSC or PAL
video signals. The luma information is called Y, while the chroma
information is represented by two components, U and V representing the
coordinates in a color plane.
L NI-IMAQ VIs
acquisition types
line scan image acquisition, 3-8
grab, 4-7
low-level acquisition VIs, 4-9
ring, 4-9
low-level functions
sequence, 4-8
acquisition functions, 2-5
snap, 4-7
advanced programming examples
acquisition VIs
grab functions, 3-18
high-level, 4-9
ring functions, 3-19
low-level, 4-9
sequence functions, 3-18
buffer management, 4-6
snap functions, 3-17
camera attributes, 4-13
attribute functions, 2-6
common parameters, 4-5
buffer management functions, 2-6
error code format, 4-16
interface functions, 2-7, 3-2
error handling, 4-15
programming considerations, 3-2
image display, 4-12
utility functions, 2-7
location of examples, 4-2
luminance, A-1
location of NI-IMAQ VIs, 4-2
luminance planes, A-2
overview, 4-1
triggering, 4-11
M
miscellaneous high-level functions, 2-5
O
one-shot image acquisition, using IMAQ for
N Visual Basic, 5-5
National Instruments online technical support, D-1
customer education, D-1
professional services, D-1 P
system integration services, D-1
parameters for NI-IMAQ VIs, 4-5
technical support, D-1
phone technical support, D-1
worldwide offices, D-1
professional services, D-1
NI-IMAQ header files, 1-4
programming environments supported by
NI-IMAQ libraries, 1-3
NI-IMAQ software, 1-2
NI-IMAQ software
programming examples, D-1
See also functions
programming with ActiveX controls
application development, 1-2
See also application development
features and overview, 1-1
acquiring images
libraries, 1-3
continuous acquisition, 5-5
sample programs, 1-4
one-shot acquisition, 5-5
support for development
buffer management, 5-4
environments, 1-2
camera attributes, 5-8
sequence functions U
See also ring functions
utility functions, 2-7
list of functions, 2-3
programming example
high-level functions, 3-12 V
low-level functions, 3-18 variable height acquisition
session functions, 3-4 examples, B-2
signal I/O functions setting up
list of functions, 2-4 enabling VHA in your code, B-2
programming example, 3-16 trigger, B-2
Simple Error Handler VI, 4-16 video cameras for color acquisition, A-3
snap acquisition VIs. See NI-IMAQ VIs
high-level functions, 3-1 visible spectrum, A-1
NI-IMAQ VIs, 4-7 Visual Basic. See IMAQ for Visual Basic
snap functions
list of functions, 2-3
programming example W
high-level functions, 3-9 warnings, in IMAQ for Visual Basic, 5-10
low-level functions, 3-17 Web
software drivers, D-1 professional services, D-1
status signals, 3-6 technical support, D-1
Step x parameter, 4-5 white balancing, A-5
Step y parameter, 4-5 worldwide technical support, D-1
StillColor
composite color acquisition, A-4
composite color video signals, A-4
support, technical, D-1
sync window, 3-8
system integration services, D-1
T
technical support, D-1
telephone technical support, D-1
training, customer, D-1
triggering
using IMAQ for Visual Basic, 5-6
using NI-IMAQ VIs, 4-11
troubleshooting resources, D-1