LabView Tutorial
Image Acquisition Using IMAQdx
(examples using a webcam)
Graham Gibson
[email protected]Measurement & Automation Explorer
(MAX)
Camera needs to work in MAX
before it can work in LabView
Expand “Devices and Interfaces”
Check that “NI-IMAQdx” appears
(may take a few seconds to refresh)
Expand “NI-IMAQdx”
Check that camera is listed
Setting the camera exposure
Click “Grab” to
continuously acquire
images
This is the name “cam1”
that LabView uses to
identify the camera
When closing MAX
agree to save the
camera settings
Adjust the exposure
& gain
Using NI-IMAQdx in LabView
Setting up an image acquisition
This is the same camera reference used
by Measurement & Automation Explorer
Require the following sequence:
1. Open camera
2. Configure the acquisition
3. Grab image
4. Close camera
Image management in LabView
Use “IMAQ Create” to reserve
memory for storing the image
Basic camera software
Need to provide a name for the image and
specify its type (e.g. RGB, Greyscale etc.)
Need to provide an indicator for the image
Providing an image indicator
1. On front panel right click indicator and select “replace”
3. Select “Image Display”
2. Select “Vision”
Run program – snapshot image
Run program once.
Program initialises the
camera, grabs a single image
then closes the camera.
Continuous image acquisition
These only need to
execute once
Grab images until program
is stopped by pressing the
“Stop” button
Close camera only when
program is stopped
Creating a sub.vi – first call
Returns a Boolean true
when vi is called for the
first time
Creating a camera sub.vi
True cases
This case only executes once
First call Camera closes when main
program is stopped
Creating a camera sub.vi
False cases Shift registers act as storage for
image, camera reference etc.
Grab images until main True constant stops the
program is stopped program getting stuck in
the while loop
Setting up the connections
On the front panel right click on the vi
icon and select “Show Connector”
Use wiring tool to link up front
panel indicators and controls to
the connector
Adding a sub.vi to main program
Select sub.vi to include in
main program.
Any *.vi program can be
inserted as a sub.vi
Running sub.vi from main program
Session in Close
Sub.vi
Adding exposure & gain controls
Use “Enumerate Attributes” to
generate list of control
parameters available for the
camera (can be deleted later).
Adding exposure & gain controls
Index through the attributes to find those
corresponding to exposure & gain. Take
note of the attribute names and data types.
Adding exposure & gain controls
Place 2 numerical sliders
on the front panel. Label
them “Exposure” & “Gain”.
Connecting up the controls
Enumerate Attributes can now be Now need to link the controls
deleted once the names and to the LabView program and
data types are known set the max & min values.
Using IMAQdx property nodes
“bundle” the controls to make Use “not equal” comparison & shift
code more manageable register to test for changes to the
controls (only updates properties
when values are changed).
Defining attribute names & types
Setting the attribute names
Setting the attribute data
types
Updating the terminal connections
Add the 2 new controls to the
connector terminals using
the wiring tool
Updating the main.vi front panel
Double click to change
scale limits
Testing the main.vi
Exposure & gain can now be
controlled while vi is running
Working with color
Each RGB color plane Create new images for the
is 8 bit Grayscale red, green & blue planes
Select the “Extract
Color Planes” vi
Working with color
Red Green Blue
Update the image out indicators
to display the images
Extracting a row from the image
Controls row position for
extracting X-section from image.
Extracting a row from the image
X-section
Red Green Blue
Further reading
IMAQ™
IMAQ Vision
Concepts Manual
October 2000 Edition
Part Number 322916A-01