LabVIEW Machine Vision -- Day 1

116
ni.com/ training National Instruments 11500 North Mopac Expressway Austin, Texas 78759 ni.com/training LabVIEW Machine Vision and Image Processing

description

labview

Transcript of LabVIEW Machine Vision -- Day 1

Page 1: LabVIEW Machine Vision -- Day 1

ni.com/training

National Instruments11500 North Mopac Expressway

Austin, Texas 78759ni.com/training

LabVIEW Machine Vision and Image Processing

Page 2: LabVIEW Machine Vision -- Day 1

ni.com/training

What You Need To Get Started

Computer running LabVIEW 8.5 or later

and Windows 2000 or later

• LabVIEW Machine Vision Course Manual

• LabVIEW Machine Vision Course CD

• PCI-8254R

• IIDC-compliant IEEE 1394 Camera

• FireWire cable

• Lens

Page 3: LabVIEW Machine Vision -- Day 1

ni.com/training

File Locations

The course installer places the course files in the following location:•Ro

ot Directory

•Exercise

s<or>Solution

s

•LabVIEW

Machine Vision

Page 4: LabVIEW Machine Vision -- Day 1

ni.com/training

Instructional Methods

• Lecture gives a foundation in the topic

• Instructor reinforces foundation through demonstrations and quizzes

• Use concept exercises to further explore a topic− Watch a simulation, experiment with example VIs

• Use development exercises to gain hands-on experience− Demonstration of a finished development exercise further

reinforces the learning process

• Topic

• Lecture

• Quizzes

• Demonstrations• Concept

Exercise• Development

Exercise

Page 5: LabVIEW Machine Vision -- Day 1

ni.com/training

Getting The Most Out Of This Course

• Experiment with hands-on exercises to understand the methods used

• Implementations explore a possible solution—you may find a better one

• Do not come to class prepared to develop an outside application; concentrate on the exercises given to build a good foundation

Page 6: LabVIEW Machine Vision -- Day 1

ni.com/training

Courses

New User

LabVIEW Basics I

LabVIEW Basics II

Experienced User

LabVIEW Intermediate I

LabVIEW Intermediate II

Advanced User

LabVIEW Advanced I

Certifications

Certified LV Associate Developer Exam

Skills tested:• LabVIEW environment

knowledge

Certified LabVIEW Developer Exam

Skills tested:• LabVIEW application

development expertise

Certified LabVIEW Architect Exam

Skills tested:• LabVIEW application

development mastery

Skills learned:• LabVIEW environment

navigation• Basics application creation

using LabVIEW• Basics of data acquisition and

instrument control

Skills learned:• Modular application

development• Structured design and

development practices• Inter-application

communication and connectivity techniques

Skills learned:• Large application design• Advanced development

techniques• Implementing multideveloper

projects

Page 7: LabVIEW Machine Vision -- Day 1

ni.com/training

Course Learning Map

Page 8: LabVIEW Machine Vision -- Day 1

ni.com/training

Course Goals

• Teach the fundamentals of building a complete machine vision system

• Introduce the basics of National Instruments image acquisition hardware and NI Vision software

• Accelerate the machine vision learning curve

Page 9: LabVIEW Machine Vision -- Day 1

ni.com/training

LabVIEW Platform

English | French | German | Japanese | Korean | Chinese WindowsMacintosh Linux

Page 10: LabVIEW Machine Vision -- Day 1

ni.com/training

National Instruments Machine Vision

Solutions for• Every industry• Every budget• Every level of experience

Page 11: LabVIEW Machine Vision -- Day 1

ni.com/training

Image Processing and Analysis

High-speed, precise analysis for every scientific industry

Page 12: LabVIEW Machine Vision -- Day 1

TOPICS

ni.com/training

Lesson 1Introduction to NI Vision

A. Image acquisition (IMAQ) productsB. Vision software productsC. Camera configuration using MAX

Page 13: LabVIEW Machine Vision -- Day 1

ni.com/training

NI Image Acquisition (IMAQ) Hardware

IMAQ devices feature:• Connectivity with parallel digital, analog and Camera Link

devices• Advanced triggering and I/O capabilities• Up to 80 MB of onboard memory• Compatibility with motion control and data acquisition systems

using the National Instruments RTSI bus• Preprocessing, which allows pixel and line scaling and region-

of-interest acquisition• Real-time acquisition

Page 14: LabVIEW Machine Vision -- Day 1

ni.com/training

The NI Vision Product Family

Vision Builder for Automated Inspection

Configure, benchmark, and deploy without programming

Vision DevelopmentModule

Programming tools for LabVIEW, C/C++, Visual Basic, and .NET

Vision Acquisition Software

Acquire, save, and display images from 1000s of cameras

Vision AssistantPrototype and generate scripts

Page 15: LabVIEW Machine Vision -- Day 1

ni.com/training

The NI Vision Product Family

Vision Development Module features:− Hundreds of image processing functions

including pattern and geometric matching, OCR, barcode readers, object classification, and particle analysis

− Tools to enhance images, check for presence, locate features, identify objects, and gauge parts

− Fast application prototyping and code generation with express VIs and Vision Assistant

Page 16: LabVIEW Machine Vision -- Day 1

ni.com/training

The NI Vision Product Family

With Vision Assistant, you can:− Create complex custom algorithms− Generate a LabVIEW VI or C/VB program from

your image processing script− Prototype vision systems and experiment with

different image processing functions− Maintain your original image in the reference

window while storing several images for processing in the image browser

Page 17: LabVIEW Machine Vision -- Day 1

ni.com/training

The NI Vision Product Family

Vision Acquisition Software hardware drivers:• Compatible with LabVIEW, C/C++,

Visual Basic, and .NET• Acquire, save, and display images

from thousands of different cameras• Included with all NI Vision frame

grabbers and IEEE 1394

• Included with the Vision Development Module and Vision Builder AI

• Work with any NI frame grabber, IIDC-compliant FireWire camera, and GigE Vision Camera

Page 18: LabVIEW Machine Vision -- Day 1

ni.com/training

The NI Vision Product Family

Vision Builder for Automated Inspection:

− Acquire and process images with any NI frame grabber, more than 100 IEEE 1394 cameras, or the NI Compact Vision System

− Build, benchmark, and deploy complete applications without programming

− Configure more than 100 powerful machine vision tools including geometric matching, OCR, and particle analysis

− Communicate triggering and inspection results directly to industrial devices over digital I/O, serial and Ethernet protocols

Page 19: LabVIEW Machine Vision -- Day 1

ni.com/training

Measurement and Automation Explorer

• One-stop configuration of all your NI hardware

• Set camera attributes• Configure frame grabber

features• Test your acquisition• Access remote devices on your

network

Page 20: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Exercise 1-1: Image Acquisition with MAX

Configure a camera and acquire an image using MAX.

Page 21: LabVIEW Machine Vision -- Day 1

TOPICS

ni.com/training

Lesson 2Preparing Your Imaging Environment

How to choose a cameraLighting considerationsHow to choose an image acquisition device

Page 22: LabVIEW Machine Vision -- Day 1

ni.com/training

How to Choose a Camera

Deciding factors in camera choice:• Physical dimensions of your imaging system

− Maximize detail of features and size of projected image• Scan type

− Line/Area• Format and standard of data

− Analog/Digital, standard or nonstandard, needed bandwidth• Budget

Page 23: LabVIEW Machine Vision -- Day 1

ni.com/training

Imaging System Parameters

1. Sensor resolution: Camera sensor pixel size by number of columns and rows

2. Sensor size: Physical area of sensor array

3. Working distance: The distance from the front of the lens to the object under inspection

4. Feature Resolution: Smallest feature size on object that can be distinguished

5. Field of view: Area under inspection that the camera can acquire

1, 2

3

5

4

Page 24: LabVIEW Machine Vision -- Day 1

ni.com/training

Sensor Resolution

Camera sensors contain an array of pixels• Sense incident light intensity• Output video data through registers

Output Registers

Y pixel resolution

X pixel resolution

Page 25: LabVIEW Machine Vision -- Day 1

ni.com/training

Determining Necessary Sensor Resolution

To be properly recognized by inspection algorithms, the smallest feature in the image must be represented by at least two pixels

minimum sensor resolution = (FOV / feature resolution) x 2

Page 26: LabVIEW Machine Vision -- Day 1

ni.com/training

Common Sensors

Cameras are manufactured with a limited number of standard sensors

Number of CCD Pixels FOV Sensor Resolution

640 x 480 60 mm 0.185 mm768 x 572 60 mm 0.156 mm

1281 x 1072 60 mm 0.093 mm2048 x 2048 60 mm 0.058 mm4000 x 2624 60 mm 0.030 mm

Page 27: LabVIEW Machine Vision -- Day 1

ni.com/training

Determining Focal Length and Sensor Size

focal length = sensor size × working distance/FOV

Lens SensorScene

SizeFOV

Working Distance Focal length

Page 28: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Exercise 2-1: Camera Attributes

Determine the focal length and camera resolution for a barcode application.

Page 29: LabVIEW Machine Vision -- Day 1

ni.com/training

Scan Type

Area Scan

Scans an area of pixels and acquires the entire rectangular image at once.

Advantages:• Less processing needed• Inexpensive

Disadvantage:• Slower acquisition• 2

Line Scan

Scans one line of pixels at a time, and image is pieced together afterward.

Advantages:• Faster acquisition• Accommodate moving objects

Disadvantages:• Processing required to build image• Expensive

Page 30: LabVIEW Machine Vision -- Day 1

ni.com/training

Camera Formats: Analog

• Output video signals as variable voltage level• Established technology• Most common type of camera

Each Line of Video

Video Data

Hsync Hsync

Single Line Scan

Black Level

Output Registers

Page 31: LabVIEW Machine Vision -- Day 1

ni.com/training

Analog Cameras: Interlaced Video

• One frame is made from two interlaced fields− Fields are acquired in

succession• VSYNC identifies start of

each field• HSYNC identifies start of

each lineFrame

Even Field

Odd Field

+

Page 32: LabVIEW Machine Vision -- Day 1

ni.com/training

Analog Cameras: Standard Formats

Standard Location Frames per second Color Image size

RS-170 USA, Japan 30 No 640 x 480

NTSC USA, Japan 30 Yes 640 x 480

CCIR Europe 25 No 768 x 576

PAL Europe 25 Yes 768 x 576

Page 33: LabVIEW Machine Vision -- Day 1

ni.com/training

Analog Cameras: Progressive Scan (Nonstandard)

• Non-interlaced, no separate fields• All lines in a frame are exposed at same time• Eliminates any “ghosting” resulting from object motion

Page 34: LabVIEW Machine Vision -- Day 1

ni.com/training

Camera Formats: Digital

• Digitizer housed inside the camera• High image quality and pixel depth• Large image sizes and high frame rates

Video Signal

Output Registers

Valid DataData

H Enable

V Enable

P CLK

Page 35: LabVIEW Machine Vision -- Day 1

ni.com/training

Digital Cameras: Standard and NonstandardInterface Advantages Disadvantages

Parallel High speedEasy to configure

Complex cablingNo interface standards

IEEE 1394(FireWire)

Simple cablingLow cost Slower data transfer rate

High speedUniform cablesStandard interface

10m cable length limit

High speedStandard interface

Non-determinism Limited bandwidth

Page 36: LabVIEW Machine Vision -- Day 1

ni.com/training

Digital Cameras: Taps

A tap, or channel, is a group of data lines that carry one pixel• Single-tap cameras latch only one pixel during the active

edge of the pixel clock• Multi-tap cameras can access multiple pixels during one

active edge

1 tap 2 taps interlaced vertically

4 taps split and interlaced vertically

4 taps in quadrants

Page 37: LabVIEW Machine Vision -- Day 1

ni.com/training

Camera Formats• Camera Formats

• Analog

• RS-170

• CCIR

• PAL

• NTSC

• Nonstandard

• Digital

• Frame Grabber

• Parallel Digital

• Camera Link

• Direct Connectivity

• IEEE 1394

• GigE Vision

• USB

• Other

• CVS

• Smart Camera

Page 38: LabVIEW Machine Vision -- Day 1

ni.com/training

Camera Formats: Summary

Analog

Advantages• Established technology• Simple cabling• Low cost

Disadvantages• Little market variation• Potentially poor image quality

Digital

Advantages• High speed, high pixel depth, and large

image sizes• Programmable controls• Less image noise

Disadvantages• Expensive• May require custom cables• May require camera files for custom

configuration

Page 39: LabVIEW Machine Vision -- Day 1

ni.com/training

Camera Files (.icd)

• Define camera specifications such as speed, image size, pixel depth, number of taps, and modes

• Tell your IMAQ device how to interact with your cameras

B.icd

1426, 1427, 1430

A

B

A.icd

1426, 1427, 1430

PCI-1430

Page 40: LabVIEW Machine Vision -- Day 1

ni.com/training

NI Camera File Generator

Free utility for creating your own digital camera files

Provides control over:• Tap configuration• Pulse generation• Triggering• Acquisition size and offset• Serial Communication

Page 41: LabVIEW Machine Vision -- Day 1

ni.com/training

Selecting a Camera

Selecting a camera is an important step in preparing your imaging environment. You should use the parameters of your application to decide whether you need an analog or digital imaging system.

National Instruments offers Camera Advisor, a one-stop Web resource for selecting an imaging camera featuring features and specifications for more than 100 cameras, at (www.ni.com/cameras).

Page 42: LabVIEW Machine Vision -- Day 1

ni.com/training

Camera Advisor

• Helps you select the right camera

• Contains full camera specifications

ni.com/cameras

Page 43: LabVIEW Machine Vision -- Day 1

ni.com/training

Lighting: A Critical Consideration

Lighting is one of the most important aspects in setting up your imaging environment.

• Separates the feature you want to inspect from the background of the image

• Makes your image processing easier and faster• Reduces glare, shadows, and effects caused by changes in

weather or time of day

Page 44: LabVIEW Machine Vision -- Day 1

ni.com/training

Ring Lighting

Light encircles the camera lens

Advantage: Even illumination without shadows along lens axis

Disadvantage: Can produce a circular glare

Page 45: LabVIEW Machine Vision -- Day 1

ni.com/training

Strobe Lighting

Light pulses as frame is acquired

Advantage: Reduces motion blur

Disadvantages: May have to apply artificial gain to avoid dark images

Page 46: LabVIEW Machine Vision -- Day 1

ni.com/training

Backlighting

Object placed between camera and light source

Advantage: Creates a sharp contrast that makes finding edges and measuring distances easy

Disadvantage: Curved objects can diffract light.

Page 47: LabVIEW Machine Vision -- Day 1

ni.com/training

Diffused Lighting

• Some objects reflect light due to their surface texture or curvature

• You can use diffused lighting to eliminate glare

Page 48: LabVIEW Machine Vision -- Day 1

ni.com/training

Optics Resources

National Instruments recommends the following partner companies for your lighting and lens needs:

• Graftek Imaging www.graftek.com• Edmund Industrial

Optics www.edmundoptics.com• Fostec www.fostec.com• Stocker & Yale www.stkr.com

Page 49: LabVIEW Machine Vision -- Day 1

ni.com/training

Analog IMAQ Hardware

• Support for color and monochrome cameras− Up to four monochrome channels

• Standard and nonstandard formats− All worldwide standards (RS-170, CCIR, NTSC, PAL)− S-video and progressive scan connections

• Plug into PCI and PXI form factors

Page 50: LabVIEW Machine Vision -- Day 1

ni.com/training

Digital IMAQ Hardware

• Support for 32-bit color and 16-bit monochrome cameras− Multiple taps− Multiple cameras− Pixel clock up to 85 MHz

• Standard and nonstandard interfaces− IEEE-1394, CameraLink, parallel digital, Gigabit Ethernet

• Plug into PCI, PXI, PCIe form factors

Page 51: LabVIEW Machine Vision -- Day 1

ni.com/training

Compact Vision System

• Embedded high-performance processor for increased inspection speed

• 3 FireWire camera inputs • Integrate with other devices through Ethernet, serial, and

digital I/O • Configure with NI Vision Builder for Automated Inspection, or

program with NI LabVIEW and Vision Development Module

Page 52: LabVIEW Machine Vision -- Day 1

ni.com/training

NI Smart Camera

•Embedded high-performance processor 400/533 MHz•Integrate with other devices through Ethernet, serial, and digital I/O •Multiple sensors starting with monochrome VGA CCD, 60 fps

Page 53: LabVIEW Machine Vision -- Day 1

TOPICS

ni.com/training

Lesson 3Acquiring and Displaying Images

A. NI-IMAQ utility functionsB. Single and multiple buffer acquisitionsC. Displaying imagesD. Triggering features of NI-IMAQ

Page 54: LabVIEW Machine Vision -- Day 1

ni.com/training

Images in Memory

• Images are not displayed directly when acquired.• Stored in a memory buffer so they can be accessed and

manipulated

Memory Buffer

21 22 17 20 16

23 21 18 19 145

25 24 20 140 143

23 22 137 141 139

24 137 135 138 142

Page 55: LabVIEW Machine Vision -- Day 1

ni.com/training

Vision Acquisition Software

•NI-IMAQdx driver for IEEE 1394 and GigE Vision Cameras•NI-IMAQ driver for NI frame grabber devices and NI Smart Cameras•NI-IMAQ I/O personality for reconfigurable devices (FPGA)

Page 56: LabVIEW Machine Vision -- Day 1

ni.com/training

Image Acquisition Functions

Acquisition management• Configure sessions and memory

allocationSingle buffer acquisition• Acquire images to one memory

bufferMultiple buffer acquisition• Acquire images to multiple

memory buffers

Trigger• Synchronize acquisition with real-

world eventsDisplay• Customize image display and user

interface

Page 57: LabVIEW Machine Vision -- Day 1

ni.com/training

Acquisition Management Functions

Interface Management Memory ManagementIMAQdx Open Camera• Opens a session with the camera

or device

IMAQ Create• Creates an image buffer in

memory

IMAQdx Close Camera• Ends a session

IMAQ Dispose• Removes an image from memory

Page 58: LabVIEW Machine Vision -- Day 1

ni.com/training

Single Buffer Acquisition - Snap and Grab

• A snap is a one-shot acquisition• A grab is continuous

• Both use a single buffer• Grab overwrites the same buffer

Acquisition Buffer

Processing Buffer

Snap

Grab

Processing Buffer

Page 59: LabVIEW Machine Vision -- Day 1

ni.com/training

Single Buffer Acquisition Functions

Snap GrabIMAQdx Snap• Acquires an image from the

device and writes it to a buffer

IMAQdx Configure Grab• Prepares device to continuously

acquire images

IMAQdx Grab• Retrieves an image from device

and writes it to a buffer

Page 60: LabVIEW Machine Vision -- Day 1

ni.com/training

Vision Acquisition Express VI

•Configure your Snap or Grab•Simulate acquisition without any hardware•Test your camera and acquisition attributes

Page 61: LabVIEW Machine Vision -- Day 1

ni.com/training

Image Display

• Most common method of viewing images

• Display is not necessary for acquiring images

• Displayed image is not necessarily the acquired image− Color palette may change or

be limited− Viewed image may not

represent all data acquired

Page 62: LabVIEW Machine Vision -- Day 1

ni.com/training

WindDraw VIs

• Alternate display method based on floating (dialog) windows

• Separate palette and functions

• Provide up to 16 different display windows that are not connected to main program window

Page 63: LabVIEW Machine Vision -- Day 1

ni.com/training

Images in LabVIEW

• The Image type is a pointer to a memory location (buffer) that holds image data.

• Does not follow usual dataflow• Data can change without notice• Functions read data from this location without consideration

for what that data is

Page 64: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Demonstration: Images in LabVIEW

Understand the memory-pointer behavior of the LabVIEW Image datatype.

Page 65: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Exercise 3-1: Snap and Display.vi

Acquire and display images using LabVIEW.

Page 66: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Exercise 3-2: Snapping Continuously

Observe the effect of snapping images continuously.

Page 67: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Exercise 3-3: Grab and Display.vi

Acquire live images using a Grab and compare the acquisition rates of Grab and Snap.

Page 68: LabVIEW Machine Vision -- Day 1

ni.com/training

File I/O

• Not necessary for acquiring images• Supports common image file types• Read and Write capability• Also supports AVI file operations for writing multiple images

to one file

Page 69: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Exercise 3-4: Snap and Save to File

Acquire an images using a Snap and then save that image as a BMP file.

Page 70: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Exercise 3-5: Grab and Save to AVI

Acquire live images using a Grab and then save the images to an AVI file.

Page 71: LabVIEW Machine Vision -- Day 1

ni.com/training

Multiple Buffer Acquisition - Sequence

A sequence is a one-shot acquisition of multiple frames into multiple buffers.

Processing Buffer [n-1]

SequenceProcessing

Buffer 1

Processing Buffer 0

...

Page 72: LabVIEW Machine Vision -- Day 1

ni.com/training

Multiple Buffer Acquisition - Ring

A ring is a continuous acquisition into multiple buffers.

Acquisition Buffer [n-1]

Ring Processing Buffer

Acquisition Buffer 1

Acquisition Buffer 0

...

The processing buffer holds one of the acquired buffers at a time

Page 73: LabVIEW Machine Vision -- Day 1

ni.com/training

Multiple Buffer Acquisition Functions

Sequence RingIMAQdx Sequence• Acquires a number of images

from the device and writes them to memory buffers

IMAQdx Configure Acquisition• Allocates a memory to a list of

acquisition buffers

IMAQdx Start Acquisition • Adds a buffer to the list

IMAQ Extract Buffer• Extracts a buffer from the

acquisition list into the processing buffer

Page 74: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Exercise 3-6: Sequence Acquisition

Learn how to acquire a single sequence of images.

Page 75: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Exercise 3-7: Ring Acquisition

Learn how to perform a continuous multi-buffer acquisition.

Page 76: LabVIEW Machine Vision -- Day 1

ni.com/training

IMAQdx Property Node

• Sets and gets properties of acquisition attributes, camera attributes, camera information, and status information

• Properties are carried through the Session wires

Page 77: LabVIEW Machine Vision -- Day 1

ni.com/training

IMAQ Property Node

• Sets and gets properties of board information, acquisition parameters, image parameters, and status information

• Properties are carried through the Session wires

Page 78: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Exercise 3-8: Changing Acquisition Parameters

Adjust the parameters of an acquisition programmatically.

Page 79: LabVIEW Machine Vision -- Day 1

ni.com/training

Image Display Property Node

Sets and gets properties of Image Display control on front panel and currently displayed image• Tools available to user• Region currently selected• Palette used for display• Read or set Zoom level• many, many more…

Page 80: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Exercise 3-9: Changing the Palette During a Grab

View an acquisition under various color palettes to accentuate different features.

Page 81: LabVIEW Machine Vision -- Day 1

ni.com/training

Using Triggers

May need to coordinate an image acquisition with motion control, data acquisition, or real-world events• Can drive or receive trigger signals

− RTSI bus for NI device synchronization− External lines for real-world coordination

Examples:• Start image acquisition with external trigger received as the

unit under test passes in front of the camera• Send trigger to DAQ card to acquire data as each frame is

read from camera

Page 82: LabVIEW Machine Vision -- Day 1

ni.com/training

Driving Trigger Lines – Frame Grabbers

Internal signals that can drive triggers:− Acquisition Done− Acquisition in Progress− Pixel Clock (PCLK)− Unasserted (logical “0”)− Asserted (logical “1”)− Horizontal Synchronization Signal

(HSYNC)− Vertical Synchronization Signal (VSYNC)

− Frame Start− Frame Done− Scaled Encoder

IMAQ Trigger Drive

Trigger VI

Page 83: LabVIEW Machine Vision -- Day 1

ni.com/training

Receiving Trigger Signals – Frame Grabbers

• Read trigger signals on any external or RTSI line• Configure a triggered acquisition with any of the following

actions:− Trigger start of acquisition− Trigger start of each buffer list− Trigger each buffer− Trigger each line (linescan)− Trigger end of acquisition

IMAQ Trigger Read

IMAQ Configure Trigger

Trigger VIs

Page 84: LabVIEW Machine Vision -- Day 1

ni.com/training

Receiving Trigger Signals – IMAQdx Cameras

• Wire the trigger signal directly to the IEEE 1394 or GigE Vision camera

• Configure the camera triggering settings with an IMAQ Property Node

NI-IMAQdx Property Node

Trigger

Computer

Trigger Source

Page 85: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Demonstration: Triggered Snap

Trigger an image acquisition.

Page 86: LabVIEW Machine Vision -- Day 1

TOPICS

ni.com/training

Lesson 4Processing Images

A. Selecting NI Vision functions to suit your applicationB. Using Vision Assistant to prototype your application

Page 87: LabVIEW Machine Vision -- Day 1

ni.com/training

NI Vision

NI Vision functions are divided into three categories:• Vision Utility VIs allow you to create and manipulate images

to fit your application• Image Processing VIs analyze, filter, and process images• Machine Vision VIs perform common machine vision

inspection tasks

Page 88: LabVIEW Machine Vision -- Day 1

ni.com/training

NI Vision

Most of the VIs you will use in this course fall into these function categories:• Statistics• Particle analysis• Pattern matching• Edge detection• Gauging

Page 89: LabVIEW Machine Vision -- Day 1

ni.com/training

Statistics

• Detect objects in an image with histograms• Evaluate lighting and focus using standard deviation

Page 90: LabVIEW Machine Vision -- Day 1

ni.com/training

Particle Analysis

• Calculate particle area, perimeter, location, and more than 50 other parameters

• Count, label, and filter particles

Page 91: LabVIEW Machine Vision -- Day 1

ni.com/training

Pattern Matching

• Locates patterns very quickly• Resistant to changes in

− Lighting− Rotation− Focus− Shape

• Supports partial occlusion

Page 92: LabVIEW Machine Vision -- Day 1

ni.com/training

Edge Detection

• Find the edges of objects along any line in an image• Test for sharpness• Use edge positions for

alignment and gauging• Sub-pixel accuracy

Page 93: LabVIEW Machine Vision -- Day 1

ni.com/training

Gauging

• Measure angles and distances• Identify linear midpoints• Locate centers of mass

Page 94: LabVIEW Machine Vision -- Day 1

ni.com/training

Many More NI Vision Functions

• Calibration• Color matching• Color pattern matching• Line profiles • FFTs and correlation• Geometric transformations• Resampling and equalization• Arithmetic and logic operators

Page 95: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Demonstration: Vision Assistant

Introduce the Vision Assistant scripting program and the Vision Assistant Express VI in LabVIEW.

Page 96: LabVIEW Machine Vision -- Day 1

ni.com/training

Vision Assistant

• Test different processing strategies on a variety of images• Quickly and easily explore “what-if” conditions• Immediately visualize the result of changing an image

processing control parameter• Test an image processing function or a series of functions• See the result of each step without programming• Benchmark the speed of each vision function

Page 97: LabVIEW Machine Vision -- Day 1

ni.com/training

Vision Assistant Express VI

• Access to most functions from the Vision Assistant• Quickly and easily viewing of results of different

processing functions• Easily-configurable Express VI interface

Page 98: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Exercise 4-1: Measure a Bracket

Familiarize yourself with Vision Assistant and create a LabVIEW VI from a script.

Page 99: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Exercise 4-2: Metal Particle Analysis

Use the Vision Assistant Express VI to perform processing on multiple images.

Page 100: LabVIEW Machine Vision -- Day 1

TOPICS

ni.com/training

Lesson 5Enhancing Acquired Images

A. Spatial Calibration and Perspective CorrectionB. Spatial Filtering

Page 101: LabVIEW Machine Vision -- Day 1

ni.com/training

Spatial Calibration

Allows the designer to take real-world measurements from image based on pixel locations.

Page 102: LabVIEW Machine Vision -- Day 1

ni.com/training

Intelligent Calibration

Also accounts for errors due to:

known orientation offset

lens distortion

perspective

Page 103: LabVIEW Machine Vision -- Day 1

ni.com/training

Calibration Grid

• Snap a calibration template with known real-world distances between the dots

• Learn the calibration (mapping information) from its perspective and distortion

Original Template Image of the Template

Page 104: LabVIEW Machine Vision -- Day 1

ni.com/training

Calibrating Your Image Setup with NI Vision

1. Create a calibration template grid. 2. Acquire an image of the calibration template.3. Use IMAQ Learn Calibration Template to create a

calibrated image in LabVIEW.4. To calibrate real images, apply the calibration from this

image to them using NI Vision functions.

Page 105: LabVIEW Machine Vision -- Day 1

ni.com/training

NI Vision Calibration Functions

Calibrate Images Correct Image FeaturesIMAQ Learn Calibration Template• Learns a calibration from a grid of

dots or a set of coordinates

IMAQ Correct Calibrated Image• Corrects the features of a

calibrated image to account for distortion and offset

IMAQ Set Simple Calibration• Sets a calibration without using a

template image

IMAQ Set Calibration Info• Passes a calibration from one

image to another

Page 106: LabVIEW Machine Vision -- Day 1

ni.com/training

Perspective Correction

NI Vision can use a calibration to adjust image geometry so the features are represented properly.

Page 107: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Exercise 5-1: Calibration and Perspective Correction

Use NI Vision calibration and correction tools to solve a perspective or lens distortion problem.

Page 108: LabVIEW Machine Vision -- Day 1

ni.com/training

Calibration and Correction Misconceptions

• Calibration “fixes” any measurement to arbitrary accuracy• Calibrated images always need to be corrected• Calibration can compensate for poor lighting or unstable

conditions

Page 109: LabVIEW Machine Vision -- Day 1

ni.com/training

Spatial Filtering

Filtering adjusts pixel values based on the values of their neighbors. It is useful for highlighting features of an image, removing noise, and locating transitions in an image.

Page 110: LabVIEW Machine Vision -- Day 1

ni.com/training

Types of Spatial Filters

• Linear – use a convolution kernel to operate quickly

• Nonlinear – apply a complex function that takes more processing power

• Highpass – highlight large intensity transitions

• Lowpass – attenuate intensity transitions

Lowpass Highpass

Linear GaussianSmoothing

GradientLaplacian

NonlinearLowpassMedianNth Order

DifferentiationGradientPrewittRobertsSigmaSobel

Page 111: LabVIEW Machine Vision -- Day 1

ni.com/training

Smoothing Filters

• Used to reduce noise and large intensity transitions

• Types:− Low Pass− Local Average− Gaussian− Median

Page 112: LabVIEW Machine Vision -- Day 1

ni.com/training

Edge Detection Filters

• Used to find large intensity transitions (edges)

• Types:− Laplacian− Differentiation− Prewitt− Sobel− Roberts

Page 113: LabVIEW Machine Vision -- Day 1

ni.com/training

Detail Highlighting Filters

•Used to display texture and accentuate intensity transitions

Page 114: LabVIEW Machine Vision -- Day 1

ni.com/training

Define Your Own Filter

• You can define any linear filter using NI Vision• Kernel can be adjusted to

yield different results-1 -1 -1

-1 8 -1

-1 -1 -1

-1 -1 -1

-1 9 -1

-1 -1 -1

Page 115: LabVIEW Machine Vision -- Day 1

ni.com/training

GO

AL

Exercise 5-2: Using Filters

Use filters to manipulate an image.

Page 116: LabVIEW Machine Vision -- Day 1

ni.com/training

End of Day OneLABVIEW MACHINE VISION AND IMAGE PROCESSING