IC LabView Extension

Getting Started

Getting Started

This document covers the necessary steps to create a simple LabVIEW application by using the IC LabVIEW extension to grab IMAQ images.

Step 1: Create a VI and drag IC Imaging Control on to the Front Panel

Create a blank VI, select IC Imaging Control from the User Library palette and drag it on to the Front Panel.

image

If the entry "IC.IC Imaging Control Class.ctl" does not appear in the palette, it needs to be created first. Ensure you have IC Imaging Control 1.41 or later installed on your computer. Select Tools -> Advanced -> Import ActiveX Controls... and choose IC.IC Imaging Control Class. After clicking OK, a File Save Dialog appears. Save the LabVIEW Control Container in your user.lib directory.

Step 1: Create a VI and drag IC Imaging Control on to the Front Panel

Create a blank VI, select IC Imaging Control from the User Library palette and drag it on to the Front Panel.

image

If the entry "IC.IC Imaging Control Class.ctl" does not appear in the palette, it needs to be created first. Ensure you have IC Imaging Control 1.41 or later installed on your computer. Select Tools -> Advanced -> Import ActiveX Controls... and choose IC.IC Imaging Control Class. After clicking OK, a File Save Dialog appears. Save the LabVIEW Control Container in your user.lib directory.

Step 2: Create buttons to control the application

Place 2 buttons on the Front Panel, and label them "Grab" and "Stop".

Now your Front Panel should look like this:

image

Step 2: Create buttons to control the application

Place 2 buttons on the Front Panel, and label them "Grab" and "Stop".

Now your Front Panel should look like this:

image

Step 3: Open a device

Select the IC_OpenDevice VI from the User Library palette:

image

Drag it on to the Block Diagram and connect its "IC Imaging Control in" input to IC Imaging Control on the Block Diagram.

In this example, we will grab monochrome (8-bit) images. Therefore, create a Boolean constant, set it to false and connect it to the "Color" input of IC_OpenDevice.

Create another Boolean constant, set it to true and connect it to the "Live" input of IC_OpenDevice. By doing this, we make sure IC Imaging Control is in live mode, thus allowing fast image grabbing.

Create a string constant and connect it to the "Device" input of IC_OpenDevice. Change the constant's value to the name of the device you want to use. The name must be identical to the name that appears in IC Capture or in the device list of IC Imaging Control demo applications. In this example, we use "1394 Camera". Please, make sure you enter the correct name for your device here - otherwise, the VI we are building will not work. If you do not know the name of your device, you can insert IC_GetDevices (from the User Library palette). It returns an array with the names of the devices installed on your system.

Your Block Diagram should now look like this:

image

Step 3: Open a device

Select the IC_OpenDevice VI from the User Library palette:

image

Drag it on to the Block Diagram and connect its "IC Imaging Control in" input to IC Imaging Control on the Block Diagram.

In this example, we will grab monochrome (8-bit) images. Therefore, create a Boolean constant, set it to false and connect it to the "Color" input of IC_OpenDevice.

Create another Boolean constant, set it to true and connect it to the "Live" input of IC_OpenDevice. By doing this, we make sure IC Imaging Control is in live mode, thus allowing fast image grabbing.

Create a string constant and connect it to the "Device" input of IC_OpenDevice. Change the constant's value to the name of the device you want to use. The name must be identical to the name that appears in IC Capture or in the device list of IC Imaging Control demo applications. In this example, we use "1394 Camera". Please, make sure you enter the correct name for your device here - otherwise, the VI we are building will not work. If you do not know the name of your device, you can insert IC_GetDevices (from the User Library palette). It returns an array with the names of the devices installed on your system.

Your Block Diagram should now look like this:

image

Step 4: Select a video format

Now we specify a video format for the device. IC_OpenDevice returns an array of valid video formats for the opened device. For this example, we just select the last entry in the list, assuming the larger formats are towards the end.

Select IC_SetVideoFormat from the User Library palette and place it on the Block Diagram.

image

After adding the necessary wires, the Block Diagram should look like this:

image

Step 4: Select a video format

Now we specify a video format for the device. IC_OpenDevice returns an array of valid video formats for the opened device. For this example, we just select the last entry in the list, assuming the larger formats are towards the end.

Select IC_SetVideoFormat from the User Library palette and place it on the Block Diagram.

image

After adding the necessary wires, the Block Diagram should look like this:

image

Step 5: Insert a While Loop and an Event Structure

IC Imaging Control is now able to display a live image from the device we previously selected. As the VI will not run continually, it is necessary to insert a While Loop into the Block Diagram. In order to be able to handle events, such as the user clicking on the Stop button, we need to insert an Event Structure into the While Loop.

To enable the Stop button, add an Event Case to the Event Structure. In the "Edit Events" dialog, select the Stop button and the event "Value Change". Insert a Boolean constant into the new Event Frame, set it to true and connect it to the While Loop's exit condition.

image

Step 5: Insert a While Loop and an Event Structure

IC Imaging Control is now able to display a live image from the device we previously selected. As the VI will not run continually, it is necessary to insert a While Loop into the Block Diagram. In order to be able to handle events, such as the user clicking on the Stop button, we need to insert an Event Structure into the While Loop.

To enable the Stop button, add an Event Case to the Event Structure. In the "Edit Events" dialog, select the Stop button and the event "Value Change". Insert a Boolean constant into the new Event Frame, set it to true and connect it to the While Loop's exit condition.

image

Step 6: Shutting down

When the application ends, the opened device should be taken out of live mode (using the StopLive method of IC Imaging Control). Failure to do this will result in the device continuing to send images to IC Imaging Control - even in LabVIEW's edit mode.

First, insert an Invoke Node:

image

Connect the Reference input of the Invoke Node with the "IC Imaging Control out" output of the IC_SetVideoFormat VI, ensuring the wire leads through the While Loop. Failure to do so, will stop live mode before the loop is executed.

You will notice that the size of the Invoke Node changes when connecting the wire. Click on "Method" and select "LiveStop".

image

Step 6: Shutting down

When the application ends, the opened device should be taken out of live mode (using the StopLive method of IC Imaging Control). Failure to do this will result in the device continuing to send images to IC Imaging Control - even in LabVIEW's edit mode.

First, insert an Invoke Node:

image

Connect the Reference input of the Invoke Node with the "IC Imaging Control out" output of the IC_SetVideoFormat VI, ensuring the wire leads through the While Loop. Failure to do so, will stop live mode before the loop is executed.

You will notice that the size of the Invoke Node changes when connecting the wire. Click on "Method" and select "LiveStop".

image

Step 7: Testing base functionality

You can now run the first test. Switch to Front Panel view, and click on "Run". If the application is set up properly, you will see a live image from the selected device. Otherwise, an error message such as the following will appear.

image

The message shown above indicates that an incorrect name was used to specify the video capture device. In this case click on "Stop", go back to step 3 and make sure you enter the correct string to specify the device.

Step 7: Testing base functionality

You can now run the first test. Switch to Front Panel view, and click on "Run". If the application is set up properly, you will see a live image from the selected device. Otherwise, an error message such as the following will appear.

image

The message shown above indicates that an incorrect name was used to specify the video capture device. In this case click on "Stop", go back to step 3 and make sure you enter the correct string to specify the device.

Step 8: Grabbing an image

Add the event "Value Change" to the Grab button and insert the IC_Grab_IMAQ VI. You can also use the IC_Grab_Picture VI if you do not have the IMAQ library installed.

image

The IC_Grab_IMAQ VI grabs an image from the device that is currently open in IC Imaging Control and puts the data into an IMAQ image. To display the image, we use the IMAQ WindDraw VI from the IMAQ library:

image

Step 8: Grabbing an image

Add the event "Value Change" to the Grab button and insert the IC_Grab_IMAQ VI. You can also use the IC_Grab_Picture VI if you do not have the IMAQ library installed.

image

The IC_Grab_IMAQ VI grabs an image from the device that is currently open in IC Imaging Control and puts the data into an IMAQ image. To display the image, we use the IMAQ WindDraw VI from the IMAQ library:

image

Step 9: Freeing the IMAQ Image memory

Your Block Diagram should now look like this:

image

You can now run the application and try the grab function. You will, however, notice that the application uses an increasing amount of memory every time an image is grabbed. To solve this problem, you have to delete the IMAQ images, using the IMAQ Dispose VI.

image

Insert the IMAQ Dispose VI into your application:

image

Further issues to consider:

  • Instead of just displaying the image, you can insert image processing VIs from the IMAQ library.
  • You may notice that the image window is not redrawn correctly, because we delete the images right after displaying it. To avoid this problem, you could implement a more sophisticated image management.

Step 9: Freeing the IMAQ Image memory

Your Block Diagram should now look like this:

image

You can now run the application and try the grab function. You will, however, notice that the application uses an increasing amount of memory every time an image is grabbed. To solve this problem, you have to delete the IMAQ images, using the IMAQ Dispose VI.

image

Insert the IMAQ Dispose VI into your application:

image

Further issues to consider:

  • Instead of just displaying the image, you can insert image processing VIs from the IMAQ library.
  • You may notice that the image window is not redrawn correctly, because we delete the images right after displaying it. To avoid this problem, you could implement a more sophisticated image management.
Get in touch with us


About The Imaging Source

Established in 1990, The Imaging Source is one of the leading manufacturers of industrial cameras, frame grabbers and video converters for production automation, quality assurance, logistics, medicine, science and security.

Our comprehensive range of cameras with USB 3.1, USB 3.0, USB 2.0, GigE interfaces and other innovative machine vision products are renowned for their high quality and ability to meet the performance requirements of demanding applications.

Automated Imaging Association ISO 9001:2015 certified

Contact us