From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Using ROI Tools to Update the ROI During Run-Time

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • Vision Development Module

    Driver

  • NI Vision Acquisition Software

Code and Documents

Attachment

Overview

The example demonstrates how to apply a ROI and mask an image at run-time.

 

Description

Using a Region of Interest (ROI) can significantly reduce computation time and allow for better image processing performance.  There may be times when the ROI needs to be changed during a continuous image grab.  A user can update an ROI on a front panel using the ROI tools.  This example shows how to continuously update the ROI based on a user's input on the front panel, then mask the image and find the centroid of the area inside the ROI.

 

Requirements

 Software

  • LabVIEW 2012 Base Development System (or compatible)
  • NI Vision Development Module 2012 (or compatible)
  • NI-IMAQdx 4.0 (or compatible)

 Hardware

  • NI-IMAQdx driver supports the following buses and standards:
    Gigabit Ethernet Cameras Supporting GigE Vision, FireWire IEEE 1394 Cameras, USB 2.0 Cameras Supporting Microsoft DirectShow (often called 'webcam'), USB 3.0 Cameras Supporting USB3 Vision

 

Steps to Implement or Execute Code

  1. Open the attached file
  2. Select the camera name
  3. Run the VI
  4. Select a ROI tool and draw a new Region of Interest (ROI)

 

Additional Information or References

Apply ROI and Mask Image at Run-Time - Front Panel.png

 

Apply ROI and Mask Image at Run-Time - Block Diagram.png

 

KnowledgeBase: What Is the Difference Between NI-IMAQ, NI-IMAQdx, and NI-IMAQ I/O?
http://digital.ni.com/public.nsf/allkb/0564022DAFF513D2862579490057D42E

 

**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text 'NIVerified'. Read here for more information about the new Example Guidelines and Community Platform.**

Zach C.
Field Engineer
Greater Los Angeles

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.