30
LabView Tutorial Image Acquisition Using IMAQdx (examples using a webcam) Graham Gibson [email protected]

LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

LabView Tutorial

Image Acquisition Using IMAQdx(examples using a webcam)

Graham [email protected]

Page 2: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Measurement & Automation Explorer

(MAX)

Expand “Devices and Interfaces”

Check that “NI-IMAQdx” appears

(may take a few seconds to refresh)

Expand “NI-IMAQdx”

Check that camera is listed

Camera needs to work in MAX

before it can work in LabView

Page 3: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Setting the camera exposure

This is the name “cam1”

that LabView uses to

identify the camera

Click “Grab” to

continuously acquire

images

When closing MAX

agree to save the

camera settings

Adjust the exposure

& gain

Page 4: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Using NI-IMAQdx in LabView

Page 5: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Setting up an image acquisition

Require the following sequence:

1. Open camera

2. Configure the acquisition

3. Grab image

4. Close camera

This is the same camera reference used

by Measurement & Automation Explorer

Page 6: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Image management in LabView

Use “IMAQ Create” to reserve

memory for storing the image

Page 7: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

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

Page 8: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Providing an image indicator

1. On front panel right click indicator and select “replace”

2. Select “Vision”

3. Select “Image Display”

Page 9: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Run program – snapshot image

Run program once.

Program initialises the

camera, grabs a single image

then closes the camera.

Page 10: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Continuous image acquisition

Grab images until program

is stopped by pressing the

“Stop” buttonClose camera only when

program is stopped

These only need to

execute once

Page 11: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Creating a sub.vi – first call

Returns a Boolean true

when vi is called for the

first time

Page 12: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Creating a camera sub.vi

This case only executes once

Camera closes when main

program is stoppedFirst call

True cases

Page 13: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Creating a camera sub.vi

Grab images until main

program is stopped

Shift registers act as storage for

image, camera reference etc.

False cases

True constant stops the

program getting stuck in

the while loop

Page 14: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

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

Page 15: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

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

Page 16: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Running sub.vi from main program

CloseSession in

Sub.vi

Page 17: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Adding exposure & gain controls

Use “Enumerate Attributes” to

generate list of control

parameters available for the

camera (can be deleted later).

Page 18: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Adding exposure & gain controls

Index through the attributes to find those

corresponding to exposure & gain. Take

note of the attribute names and data types.

Page 19: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Adding exposure & gain controls

Place 2 numerical sliders

on the front panel. Label

them “Exposure” & “Gain”.

Page 20: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Connecting up the controls

Now need to link the controls

to the LabView program and

set the max & min values.

Enumerate Attributes can now be

deleted once the names and

data types are known

Page 21: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Using IMAQdx property nodes

Use “not equal” comparison & shift

register to test for changes to the

controls (only updates properties

when values are changed).

“bundle” the controls to make

code more manageable

Page 22: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Defining attribute names & types

Setting the attribute data

types

Setting the attribute names

Page 23: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Updating the terminal connections

Add the 2 new controls to the

connector terminals using

the wiring tool

Page 24: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Updating the main.vi front panel

Double click to change

scale limits

Page 25: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Testing the main.vi

Exposure & gain can now be

controlled while vi is running

Page 26: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Working with color

Create new images for the

red, green & blue planes

Each RGB color plane

is 8 bit Grayscale

Select the “Extract

Color Planes” vi

Page 27: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Working with color

Update the image out indicators

to display the images

Red Green Blue

Page 28: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Extracting a row from the image

Controls row position for

extracting X-section from image.

Page 29: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Extracting a row from the image

Red Green Blue

X-section

Page 30: LabView Tutorial - Illinois Wesleyan Universitygspaldin/LabVIEW_Imaging.pdfbefore it can work in LabView. Setting the camera exposure This is the name “cam1” that LabView uses

Further reading

IMAQ™

IMAQ Vision

Concepts Manual

October 2000 Edition

Part Number 322916A-01