ROI Main Properties
ROIs are defined by a width, a height, and origin x and y coordinates.
The origins are specified with respect to the top left corner in the parent image or ROI.
The ROI must be wholly contained in its parent image.
The processing/analysis time of a BW1 ROI is faster if OrgX and Width are multiples of 8.
You can save or load an ROI as a separate image, to be used as if it was a full image. The ROIs perform no memory allocation at all and never duplicate parts of their parent image, the parent image provides them with access to its image data.
The image size of the new file must match the size of the ROI being loaded into it. The image around the ROI remains unchanged.
An ROI must be attached to a parent (image/ROI) with parameters that set the parent, position and size, and these links are updated transparently, avoiding dangling pointers.
A normal image cannot be attached to another image or ROI.
Set and Get functions change or query the width, height and position of the origin of an ROI, with respect to its immediate or topmost parent image.
An image may accommodate an arbitrary number of ROIs, which can be nested in a hierarchical way. Moving the ROI also moves the embedded ROIs accordingly. The image/ROI classes provide several methods to traverse the hierarchy of ROIs associated with an image.
Nested ROIs: Two sub-ROIs attached to an ROI, itself attached to the parent image
CropToImage crops an ROI which is partially out of its image. The resized ROI never grows.
An exception is thrown if a function attempts to use an ROI that has limits that extend outside of the parents.
(In Open eVision 1.0.1 and earlier, an ROI was silently resized or repositioned when placed out of its image and sometimes grew. If ROI limits extended outside parents, they were silently resized to remain within parent limits.)
ROIs can easily be resized and positioned by two functions and dragging handles:
● | EBaseROI::.Drag adjusts the ROI coordinates while the cursor moves. |
● | EBaseROI::.HitTest informs if the cursor is placed over a dragging handle. |
□ | Once the handle is known, the cursor shape can be changed by an OnSetCursor MFC event handler. HitTest is unpredictable if called while dragging is in progress. |
□ | HitTest can be used in an OnSetCursor MFC event handler to change the cursor shape, or before a dragging operation like OnLButtonDown, (or EvSetCursor and EvLButtonDown in Borland/CodeGear's OWL) (or FormMouseMove and FormMouseDown in Borland/CodeGear's VCL). |