Programmatically Set a Region of Interest (ROI) with NI IMAQdx

Updated Sep 15, 2023

Environment

Software

  • LabVIEW Full
  • LabVIEW Base
  • LabVIEW Professional

Driver

  • Vision Acquisition Software
  • NI-IMAQdx

I have a camera that uses NI IMAQdx (USB 3.0 Vision, GigE Vision, Camera Link, IEEE-1394 FireWire, USB 2.0 with DirectShow, Ethernet IP) and want to programmatically set a region of interest (ROI) so that I am not grabbing all pixels from the image sensor.

Some cameras support user-configurable regions of interest (ROIs), which allow you to define the size of the acquired image. If you use this format, you must input the image size using the region of interest attributes, such as offset x, offset y, width, and height. The size and position of the sub-image you are acquiring must be a multiple of the increment attribute, as shown in the following figure, or the driver acquires the smallest sub-image that contains the ROI you defined.

The increment values are camera-specific. Refer to the camera documentation or query the increment attributes for width and height to obtain the actual values.

NI-MAX shows the available increments. Select the camera from the devices tree on the left panel and on the Camera Attributes tab look for Image Size Controls.
  • Width
  • Height
  • Offset X
  • OffsetY
The description panel shows the configuration options; you will need to select the values in multiples of the detailed increment otherwise, you will get an error.

INcrement.png

Since the Width has an increase of one, you can select any number that is in range.

increment2.png
In this second case, the Offset X must be a multiple of 8.

To set the region of interest attributes in LabVIEW, you can use an IMAQdx property node like in the screenshot below:

Note that the ROI has to be set before starting the acquisition; you cannot change the ROI while the acquisition is in progress. If you change the ROI, you will have to reconfigure and restart the acquisition.

Additional Information

Extracted from the NI-IMAQdx Concepts Help (<National Instruments>\NI-IMAQdx\Help\niimaqdx_concepts.chm):
The region of interest (ROI) specifies a rectangular portion of the image to be captured. If the camera supports scalable video modes, the ROI defines the portion of the image to transfer from the camera to system memory. If the camera does not support scalable video modes, the entire image is transferred from the camera to system memory. In all video modes, the ROI specifies the amount of data decoded by the driver while acquiring into a user buffer.

By default, the driver transfers the entire image. Specify a smaller ROI for the following reasons:
  • To acquire only the necessary subset of data
  • To increase the acquisition speed by reducing the amount of data transferred and/or decoded
  • To allow for multiple simultaneous acquisitions by reducing bandwidth usage