Vision Builder for Automated Inspection 2010 (Vision Builder AI) introduces image variables, which can be used in many different ways. The following sections describe how to create image variables, considerations for using image variables, and how to use image variables in specific use cases. Some use case demonstrations require additional files, which are attached at the end of the document.
Vision Builder AI includes a Variable Manager, which you can use to easily create or edit variables. The Variable Manager interface includes the following tabs:
Inspection Variables—Lists variables that only the current inspection can access.
System Variables— Lists variables that all inspections can access.
Note If you enable the Network Shared checkbox for a variable, the variable is available to other devices on the same network.
Network Variables—Lists variables shared by another device on the same network that all inspections can access.
Note External applications can update shared system or network variables. Steps that read a shared system or network variable always get the current value of the variable.
Complete the following steps to create an image variable in Vision Builder AI:
In the Vision Builder AI Configuration Interface, select Tools»Variable Manager.
Select the Inspection Variable, System Variable, or Network Variable tab. Refer to Working with Variables in Vision Builder AI for more information about each tab.
Select Add to open the Add Variable dialog box.
Select Image in the Type list.
Configure the remaining variable settings and click OK.
Note Unlike other variable types, image variables do not have initial values.
Verify that the new variable appears in the list of variables and click OK to close the Variable Manager.
The image variable is created and available to steps that interact with image variables.
Use the following Vision Builder AI steps to interact with image variables:
Select Image—Selects an image variable for subsequent steps to process.
Set Variable—Sets the value of an image variable.
Vision Assistant—Creates a Vision Assistant sequence, which can retrieve, operate on, and set image variables.
Run LabVIEW VI—Can use image variables as VI inputs. The Run LabVIEW VI outputs the same image that is passed to the step.
Image Logging—Saves image variable content to the specified location.
Update Inspection UI—Updates image display controls in a custom inspection interface with image variable content.
There are important differences between image variables that are network shared and image variables that are not network shared. Network shared image variables include Network Variables and System Variables with the Network Shared checkbox enabled.
Shared image variables require Vision Builder AI to access a variable library on disk. Image variables that are not shared are stored in memory. Accessing a variable library requires more time than accessing a variable in memory.
To improve performance, shared image variables are not updated when processing steps modify the image. Instead a local copy is updated in memory. If you want to update the shared image variable with the modified image, you must use a Set Variable step to update a shared image variable in the variable library with the current image.
You cannot directly update shared image variables in a Run LabVIEW VI step because the step operates on the local copy of the variable in memory. To update a shared image variable using a Run LabVIEW step, you must update an inspection image variable in the Run LabVIEW step and then use a Set Variable step to update the network shared image variable with the value from the inspection image variable.
The following sections describe specific applications that use image variables.
This use case uses a dynamic file path to read a file from disk. For example, imagine that a PLC controls another part of the inspection system and communicates a file path when an image is available for processing.
Complete the following steps to configure an inspection in Vision Builder AI to handle this use case:
Download and decompress the attached Examples.zip file at the end of this document and copy the User Images folder to your C:\ drive.
On the Vision Builder AI Welcome screen, select New Inspection to launch the Vision Builder AI Configuration Interface.
Create an image Inspection variable.
Select Tools»Variable Manager.
In the Inspection Variables tab, add a new image variable with the name Local Image. Refer to Creating Image Variables for more information about how to add a new image variable.
In the VI Path control, select Browse.
Navigate to the Read Image VI and click OK.
Select the VI Controls tab and click Configure to open the Select VI Value dialog box.
In the VI Controls list, select Image.
Enable the Use Measurement option and select Inspection Variable - Local Image from the list.
In the VI Controls list, select Path. In the described use case, the path value requires a previous measurement generated by a PLC. For this example, select Use Constant and specify the filepath of an image on your computer. Click OK to close the Select VI Value dialog box.
Click OK to add the step to the inspection.
The Read Image VI reads the file at the specified path and updates the image variable with the read image. No image appears in the main window because the Run LabVIEW step always passes out the image that is passed into it.
Complete the following steps to access and display the updated image variable:
1. Select the Acquire Images palette.
2. Click the Image Select step.
3. In the Image Selection tree, select Local Image. The main window displays the content of the Local Image variable.
4. Click OK to add the step to the inspection.
The inspection is configured to select the image variable. You can add additional steps to process the selected image.
This use case illustrates how to use an image variable to process an image from a previous iteration of the inspection. This use case also illustrates how to store an intermediate image result using a temporary image variable.
Complete the steps in the following sections to configure an inspection in Vision Builder AI to handle this use case.
Download and decompress the attached Examples.zip file at the end of this document and copy the User VIs folder to your C:\ drive.
In the Inspection Variables tab, add two new image variables with the names Previous Image and Temp Image. Refer to Creating Image Variables for more information about how to add a new image variable.
Add a point variable with the name Previous Point.
Verify that the new variables appear in the list of variables and close the Variable Manager.
Use the Setup state to initialize the inspection variables with valid values the first time the inspection runs.
1. Select View»View Complete Inspection Setup to display the Setup and Cleanup states of the inspection.
2. Click Setup.
3. Select the Acquire Images palette.
4. Click the Simulate Acquisition step. Complete the following steps to configure the step:
a. In the Path control specify the path to Object14.jpg in the sample images folder that you downloaded in step 1.
b. Disable the Cycle Through Folder Images checkbox.
c. Click OK to add the step to the inspection.
Select the Locate Features palette.
Click the Detect Objects step. Complete the following steps to configure the step:
a. Select Full Image in the Region of Interest list.
b. Select the Threshold tab.
c. Select Dark Objects in the Look For list.
d. Select Local Threshold: BG Correction in the Method list.
e. Click OK to add the step to the inspection.
Select the Use Additional Tools palette.
Click the Set Variable step. Complete the following steps to configure the step:
Select the Previous Image variable.
Enable the Set to Measurement option and select Current Image.
Select the Previous Point.X variable.
Enable the Set to Measurement option and select theX position measurement returned by the Detect Objects step
Select the Previous Point.Y variable.
Enable the Set to Measurement option and select theY position measurement returned by the Detect Objects step.
Configure the inspection state diagram to perform an inspection that measures the movement of parts between one inspection iteration and the next.
Click Toggle Main Window View.
Click State Diagram. Use the Setup state to initialize the inspection variables with valid values the first time the inspection runs.
Select the Acquire Images palette.
Click the Simulate Acquisition step. Complete the following steps to configure the step:
In the Path control specify the path to Object01.jpg in the sample images folder that you downloaded in step 1.
Select Full Image in the Region of Interest list.
Select the Threshold tab.
Select Dark Objects in the Look For list.
Select Local Threshold: BG Correction in the Method list.
The inspection is configured to detect objects in the inspection image.
Complete the following steps to store the current image to a temporary image variable and retrieve the image from the previous inspection iteration.
Select the Enhance Images palette.
Click the Vision Assistant step.
Click Edit to open Vision Assistant.
In Vision Assistant, select the Image palette.
Click the Image Buffer step.
Enable the Store option.
Select Inspection Variable – Temp Image in the Image Variables list.
Click OK to add the step to the algorithm.
Click a second Image Buffer step.
Enable the Retrieve option.
Select Inspection Variable – Previous Image in the Image Variables list.
Click OK to add the step to the algorithm.
By copying the current image to the Temp Image variable, we can process the image without modifying the original acquired image. In subsequent steps you will configure the inspection to copy the original acquired image to the Previous Image variable so that it is available in the next inspection iteration.
Complete the following steps to complete the Vision Assistant algorithm:
Select the Grayscale palette.
Click the Threshold step.
Select Threshold: Background Correction in the Threshold Type list.
Select the Operators step.
Enable the Image option and select the Temp Image variable.
Click a second Operators step.
Enable the Image option and select the Simulate Acquisition step for the Inspect state.
Close Vision Assistant.
The Vision Assistant step passes out an image that displays the position of the object in the previous inspection iteration, as well as the position of the object in the current inspection iteration. The object in the image from the previous iteration appears as a light object, and the current object appears as a dark object.
Complete the following steps to copy the original acquired image for the current inspection iteration available to a variable:
Enable the Set to Measurement option and select the Simulate Acquisition step.
Note: Do not select the Simulate Acquisition step in the Inspection Setup state.
The sample images archive includes an example inspection that illustrates how to create an overlay that indicates the motion of the object between one inspection iteration and the next.
This use case demonstrates how to add and interact with a Vision Builder AI target in a LabVIEW project. Adding a target in Vision Builder AI mode allows other VIs in the LabVIEW project to access the variables shared by the target. You can drag shared variables from a remote target to a VI and display the images processed by Vision Builder AI as it runs on the remote target.
The procedure for this use case requires the following:
A development computer with LabVIEW 2010 or higher and Vision Builder AI 2010 or higher installed.
One of the following NI Vision real time targets running Vision Builder AI 2010 or higher.
NI 17xx Smart Camera
NI CVS-1450 Series Compact Vision System
NI EVS-1463RT Embedded Vision System
NI EVS-1464RT Embedded Vision System
Complete the steps in the following sections add a target to a LabVIEW project in Vision Builder AI mode:
Select Start»All Programs»National Instruments»LabVIEW to launch LabVIEW 2010 or higher.
On the LabVIEW Welcome screen, select Empty Project.
In the Project Explorer window, right-click Project: Untitled Project and select New»Targets and Devices.
Select a remote target running Vision Builder AI 2010 or higher in the Targets and Devices list.
In the Target Mode Selection dialog box, select Vision Builder AI Mode and click Continue.
The remote target appears in the Project Explorer window.
Complete the following steps to create and access a variable for a remote target in Vision Builder AI mode:
In the Project Explorer window, right-click the remote target and select Connect. The status indicator in the target icon changes to green if Vision Builder AI is running on the target.
Right-click the target and select Configure Vision Builder AI Inspection to launch Vision Builder AI.
On the Vision Builder AI Welcome screen, click Browse under Configure Inspection and select the inspection that you want to run.
Create an image System variable that is network shared.
Select the System Variables tab.
In the System Variables tab, add a new image variable with the name My Image and the Publish on Network checkbox enabled. Refer to Creating Image Variables for more information about how to add a new image variable.
Verify that the new variables appear in the list of variables and that the Network Shared checkbox is enabled, then close the Variable Manager.
Click the last step in the inspection.
a. Select the My Image variable.
b. Enable the Set to Measurement option and select Current Image.
c. Click OK to add the step at the end of the inspection.
Select Files»Save to save the inspection.
Click Run Inspection in Loop and verify that the inspection runs correctly.
Stop the inspection and select File»Switch to Inspection Interface.
Click Run Inspection.
Return to the LabVIEW Project Explorer window and note that the shared variable is listed beneath the remote target.
Select My Computer.
Right-click My Computer and select New» VI.
Drag the My Image variable from the Project Explorer window to the VI block diagram.
Note: The new VI will run on the development computer.
Build the following block diagram:
Switch to the VI Front Panel and run the inspection.
The Image Display control displays the image acquired from the target running in Vision Builder AI mode.
A LabVIEW project can include multiple targets, including targets that are not running Vision Builder AI. The project illustrated in the following image includes different types of targets that use shared variables to expose results and images. Results from various types of hardware monitoring an entire assembly line can be combined in a single VI on the host computer, which can function as an HMI to the entire manufacturing floor.
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.