Support Support Home » Knowledge Base » Multiple ROI

Multiple ROI

Some of the XIMEA cameras are able to deliver multiple regions of interest (ROI) from a captured image.
By skipping the rest of the pixels the frame-rate of a camera can be increased.

Feature parameters

xiApi parameters

Feature related parameters
XI_PRM_WIDTH
XI_PRM_HEIGHT
XI_PRM_OFFSET_X
XI_PRM_OFFSET_Y
XI_PRM_REGION_SELECTOR
XI_PRM_REGION_MODE

Supported Cameras

Models
MQ042xG-CM
MQ022xG-CM
MQ003xG-CM

Setting the Multiple ROI

The process:

  1. Select region 0 (XI_PRM_REGION_SELECTOR) - this is selected by default.
  2. Decrease the height of region 0 - which covers the whole image (by default). This creates space for other regions. This can be done by setting the height parameter (XI_PRM_HEIGHT).
  3. Set the width of region 0. This Width is global and will be used for all other regions (XI_PRM_WIDTH).
  4. Set the X-offset of the region 0. This offset is global and will be used for all other regions (XI_PRM_OFFSET_X).
  5. Set the Y-offset of region 0. This offset is only local (XI_PRM_OFFSET_Y).
  6. Select region 1 (XI_PRM_REGION_SELECTOR).
  7. Set the Height and Y-offset of region 1. Notice that the Width and X-offset cannot be set for this region as they have already been set globally in region 0.
  8. Enable the display of region 1 by setting the XI_PRM_REGION_MODE.

Important:

  • XI_PRM_WIDTH” and XI_PRM_OFFSET_X” could be changed only for Region 0.
  • Regions have to be in order from top to bottom. Region N has to start after Region N-1 ends.
  • Changing the XI_PRM_HEIGHT parameter results in removing all images from the buffer queue.

Selecting a region:

The Multiple ROI visualized:

Sample code

xiAPI Example

    // 1. Resize the main region - region 0.
    xiSetParamInt(xiH, XI_PRM_REGION_SELECTOR,0);  // default is 0
    xiSetParamInt(xiH,XI_PRM_WIDTH, 200); // This is the width for all regions
    xiSetParamInt(xiH,XI_PRM_HEIGHT, 100); // Decrease height (to enable other regions)
    xiSetParamInt(xiH,XI_PRM_OFFSET_X, 100);  // This is the x_offset for all regions
    // 2. Configure another region.
    xiSetParamInt(xiH,XI_PRM_REGION_SELECTOR, 1);  // Selects region 1.
    xiSetParamInt(xiH,XI_PRM_HEIGHT, 200); // This is the new height of region 1
    xiSetParamInt(xiH,XI_PRM_OFFSET_Y, 200);  // This is th Y-offset of region 1
    xiSetParamInt(xiH,XI_PRM_REGION_MODE, 1);  // Atcivate (1), or deactivate (0) selected region.
    // 3. Start acquisition
    xiStartAcquisition(xiH);
    xiGetImage(xiH, 5000, &image);

.NET example in Matlab


%Multiple ROI
myCam.SetParam(xiApi.NET.PRM.REGION_SELECTOR, 0) %Select region 0 (has to be resized first)
myCam.SetParam(xiApi.NET.PRM.WIDTH, 200)
myCam.SetParam(xiApi.NET.PRM.HEIGHT, 100) % Decrease height of the the region 0
myCam.SetParam(xiApi.NET.PRM.REGION_SELECTOR, 1) % Select region 1 
myCam.SetParam(xiApi.NET.PRM.HEIGHT, 200) % Resize this region 1
myCam.SetParam(xiApi.NET.PRM.OFFSET_Y, 200) % Set the offset of region 1
myCam.SetParam(xiApi.NET.PRM.REGION_MODE, 1) % Enable region in multiple ROI

% Acquisition 
StartAcquisition(myCam); 
bmap=GetImage(myCam,1000);

xiAPI+ with OpenCV example

Example for our OpenCV xiAPI+ library:

    // 1. Resize the main region - region 0.
    cam.SetRegion_selector(0); // default is 0
    cam.SetWidth(200); // This is the width for all regions
    cam.SetHeight(100);
    cam.SetOffsetX(100); // This is the x_offset for all regions
    // 2. Configure another region.
    cam.SetRegion_selector(1);  // Selects region 1.
    cam.SetHeight(200); // This is the new height of region 1
    cam.SetOffsetY(200); // This is th Y-offset of region 1
    cam.SetRegion_mode(1); // Atcivate (1), or deactivate (0) the selected re gion.
    // 3. Start acquisition.
    cam.StartAcquisition();
    Mat cv_mat_image = cam.GetNextImageOcvMat();
    cv::imshow("Image from the camera",cv_mat_image);

Documentation

You may find more information on multiple ROI support in our API manuals:

  • C/C++ interface here
  • xiAPI.NET interface here