Leaper Vision Toolkit
中文 / English 2.x
Public Member Functions | Properties
ILRegion Interface Reference

This interface expose APIs to create/modify/manipulate/draw a LPV region object (LRectRegion , LRotRectRegion , LCircleRegion , etc.). More...

Inheritance diagram for ILRegion:
ILObject ILAnnulusRegion ILAnnulusSectorRegion ILCircleRegion ILCompoundRegion ILEllipseRegion ILMaskRegion ILPolyRegion ILRectRegion ILRotRectRegion

Public Member Functions

ILCompoundRegionAdd (ILRegion *other)
 
void Drag (LPVRoiHandle roiHandle, int x, int y, double zoomX, double zoomY, double panX, double panY)
 
void Draw (HDC hdc, BOOL drawHandles, double zoomX, double zoomY, double panX, double panY)
 
void EnableHandle (LPVRoiHandle roiHandle, BOOL enabled)
 
LPVRoiHandle HitTest (int x, int y, double zoomX, double zoomY, double panX, double panY)
 
ILCompoundRegionIntersect (ILRegion *other)
 
ILCompoundRegionInvert ()
 
void MapFromImage (double imagePointX, double imagePointY, double *regionPointX, double *regionPointY)
 
ILObjectMapObjectFromImage (ILObject *imageObject)
 
ILObjectMapObjectToImage (ILObject *regionObject)
 
void MapToImage (double regionPointX, double regionPointY, double *imagePointX, double *imagePointY)
 
void ReduceImage (ILImage *image, ILImage **newImage, ILImage **newMask)
 
ILRegionRotate (double da)
 
ILRegionRotateAndTranslate (double x, double y, double newX, double newY, double da)
 
ILRegionScale (double factorX, double factorY)
 
ILCompoundRegionSubtract (ILRegion *other)
 
ILImageToMask (int w, int h)
 
ILRegionTranslate (double offsetX, double offsetY)
 
ILCompoundRegionUnion (ILRegion *other)
 
ILCompoundRegionXOR (ILRegion *other)
 
- Public Member Functions inherited from ILObject
ILObjectCopy ()
 
LPVErrorCode Load (LString filename)
 
void Reset ()
 
LPVErrorCode Save (LString filename)
 
BOOL Valid ()
 

Properties

LPVInterpolationMethod InterpolationMethod [get, set]
 The interpolation method used in image reduction.
 
double ReduceAngle [get, set]
 The angle of the reduced result.
By default, it's 0. A non-zero value means we'll rotated the reduced result image by the angle clockwise. More...
 
double ReduceScale [get, set]
 The scale of the reduced result.
By default, it's 1. Change this value to scale the reduced result image. More...
 

Detailed Description

This interface expose APIs to create/modify/manipulate/draw a LPV region object (LRectRegion , LRotRectRegion , LCircleRegion , etc.).

Region object is useful to restrict the detection and inspection to required region.
To use this interface, you should create a region object.

There are several ways to modify a region's placement. The most popular options are listed below:

  1. For simple geometric region, do it programmatically.
  2. Interactive with the region by dragging the handles.
  3. Create a new region via logical operators on multiple existing regions.

Example Code

Member Function Documentation

◆ Add()

ILCompoundRegion* Add ( ILRegion other)

Add the current and provided region, output a new one, P' = P + other. Same as Union(), parts in either regions are all included.

Parameters
[in]otherThe region to be union-ed.
Return values
newRegionReturn a new result compound region.
See also
Subtract(), Union(), Intersect(), XOR().

◆ Drag()

void Drag ( LPVRoiHandle  roiHandle,
int  x,
int  y,
double  zoomX,
double  zoomY,
double  panX,
double  panY 
)

Move the specified handle to a new position and update placement of the region.

Parameters
[in]roiHandleHandle identifier, usually it's returned by HitTest().
[in]xThe x-coordinate of the cursor position.
[in]yThe y-coordinate of the cursor position.
See also
Draw(), HitTest().
Use Draw Functions
Remarks
This function is currently not available on Linux / MacOS platform.

◆ Draw()

void Draw ( HDC  hdc,
BOOL  drawHandles,
double  zoomX,
double  zoomY,
double  panX,
double  panY 
)

Draw the region onto the provided device context.

Parameters
[in]drawHandlesWhether to draw the handles
Remarks
If zooming and/or panning were used when drawing the region, the same values must be used with HitTest() and Drag().
See also
HitTest(), Drag().
Use Draw Functions
Remarks
This function is currently not available on Linux / MacOS platform.

◆ EnableHandle()

void EnableHandle ( LPVRoiHandle  roiHandle,
BOOL  enabled 
)

Enable or disable the input handle. The disabled wouldn't be drawn and dragged. Not-supported handles are ignored.
By default, all handles are enabled.

Parameters
[in]roiHandleHandle identifier
[in]enabledEnable or not.

◆ HitTest()

LPVRoiHandle HitTest ( int  x,
int  y,
double  zoomX,
double  zoomY,
double  panX,
double  panY 
)

Detect if the cursor is placed over one of the dragging handles.

Parameters
[in]xThe x-coordinate of the cursor position.
[in]yThe y-coordinate of the cursor position.
Return values
roiHandleReturn a handle identifier.
See also
Draw(), Drag().
Use Draw Functions
Remarks
This function is currently not available on Linux / MacOS platform.

◆ Intersect()

ILCompoundRegion* Intersect ( ILRegion other)

Intersect the current and provided region, output a new one, P' = P ∩ other. Parts in both regions are included.

Parameters
[in]otherThe region to be intersected.
Return values
newRegionReturn a new result compound region.
See also
Add(), Subtract(), Union(), XOR().

◆ Invert()

ILCompoundRegion* Invert ( )

Create a copy of the region that is inverted.

Return values
newRegionReturn a new result compound region.

◆ MapFromImage()

void MapFromImage ( double  imagePointX,
double  imagePointY,
double *  regionPointX,
double *  regionPointY 
)

Map the pixel position from the image to the region's local coordinates.

Parameters
[in]imagePointXThe x-coordinate of the pixel position in image coordinates.
[in]imagePointYThe y-coordinate of the pixel position in image coordinates.
[out]regionPointXReturn the x-coordinate of the pixel position in the region's local coordinates.
[out]regionPointYReturn the y-coordinate of the pixel position in the region's local coordinates.
See also
MapToImage(), MapObjectFromImage().

◆ MapObjectFromImage()

ILObject* MapObjectFromImage ( ILObject imageObject)

Map the given object's position from image to the region's local coordinates.

Parameters
[in]imageObjectThe positional LPV object in the image coordinates. It's usually some geometric shape, or detection result which implemented the ISortable or ISortables interface.
Return values
regionObjectReturn the transformed LPV object of the same type as the input, in the region's local coordinates.
See also
MapObjectToImage(), MapFromImage().

◆ MapObjectToImage()

ILObject* MapObjectToImage ( ILObject regionObject)

Map the given object's position from the region's local coordinates to the image.

Parameters
[in]regionObjectThe positional LPV object in the region's local coordinates. It's usually some geometric shape, or detection result which implemented the ISortable or ISortables interface.
Return values
imageObjectReturn the transformed LPV object of the same type as the input, in the image coordinates.
See also
MapObjectFromImage(), MapToImage().

◆ MapToImage()

void MapToImage ( double  regionPointX,
double  regionPointY,
double *  imagePointX,
double *  imagePointY 
)

Map the pixel position from the region's local coordinates to the image.

Parameters
[in]regionPointXThe x-coordinate of the pixel position in the region's local coordinates.
[in]regionPointYThe y-coordinate of the pixel position in the region's local coordinates.
[out]imagePointXReturn the x-coordinate of the pixel position in image coordinates.
[out]imagePointYReturn the y-coordinate of the pixel position in image coordinates.
See also
MapFromImage(), MapObjectToImage().

◆ ReduceImage()

void ReduceImage ( ILImage image,
ILImage **  newImage,
ILImage **  newMask 
)

Reduce the provided image to current region. All pixels outside the bounding rectangle of the region is excluded, if the region is not a rectangle, a region mask image is generated, with pixels inside the region as white, others as black.

Parameters
[in]imageThe input image to be reduced.
[out]newImageOutput the result image.
[out]newMask Output the result mask. Could be null if you don't want it.
See also
ToMask(), InterpolationMethod.

◆ Rotate()

ILRegion* Rotate ( double  da)

Create a copy of the region that is rotated by provided delta angle, around the center of the region.
Notes: The rotated LRectRegion or LMaskRegion may looks bigger than the original, as we use the bounding rect of the rotated vertexes as region.

Parameters
[in]daThe rotated delta angle.
Return values
newRegionReturn the transformed new region of the same type as the input.
See also
Translate(), RotateAndTranslate(), Scale().

◆ RotateAndTranslate()

ILRegion* RotateAndTranslate ( double  x,
double  y,
double  newX,
double  newY,
double  da 
)

Create a copy of the region that is the transformation based on the translation and rotation of the specified anchor point. The relative position of the region and the anchor point is not changed.

Parameters
[in]xThe x-coordinate of the anchor point's current position.
[in]yThe y-coordinate of the anchor point's current position.
[in]newXThe x-coordinate of the anchor point's new position.
[in]newYThe y-coordinate of the anchor point's new position.
[in]daThe rotated delta angle of the anchor point.
Return values
newRegionReturn the rotated and translated new region of the same type as the input.
See also
Translate(), Rotate().

◆ Scale()

ILRegion* Scale ( double  factorX,
double  factorY 
)

Create a copy of the region that is scale by provided zoom factor, the region's center is not changed.
Notes: Anisotropic scaling is not supported for a LCircleRegion or a LAnnulusRegion object.

Parameters
[in]factorXFactor for zooming in or out in the x-coordinate direction.
[in]factorYFactor for zooming in or out in the x-coordinate direction.
Return values
newRegionReturn the transformed new region of the same type as the input.
See also
Translate(), Rotate().

◆ Subtract()

ILCompoundRegion* Subtract ( ILRegion other)

Subtract the provided region from the current region, output a new one, P' = P - other.

Parameters
[in]otherThe region to be subtracted.
Return values
newRegionReturn a new result compound region.
See also
Add(), Union(), Intersect(), XOR().

◆ ToMask()

ILImage* ToMask ( int  w,
int  h 
)

Create a mask image out of the region, the mask is of w * h size. Pixels inside the region as white, others as black.

Parameters
[in]wThe width of the mask image.
[in]hThe height of the mask image.
Return values
newRegionReturn the generated mask image .
See also
ReduceImage().

◆ Translate()

ILRegion* Translate ( double  offsetX,
double  offsetY 
)

Create a copy of the region that is moved by offset, relative to current position, P' = P + offset.

Parameters
[in]offsetXOffset in the x-coordinate direction.
[in]offsetYOffset in the y-coordinate direction.
Return values
newRegionReturn the transformed new region of the same type as the input.
See also
Scale(), Rotate(), RotateAndTranslate().

◆ Union()

ILCompoundRegion* Union ( ILRegion other)

Union the current and provided region, output a new one, P' = P U other. Same as Add(), parts in either regions are all included.

Parameters
[in]otherThe region to be union-ed
Return values
newRegionReturn a new result compound region.
See also
Add(), Subtract(), Intersect(), XOR().

◆ XOR()

ILCompoundRegion* XOR ( ILRegion other)

Calculate the symmetric difference of the current and provided region, output a new one, P' = P XOR other. The parts in and only in one of regions are included.

Parameters
[in]otherThe region to perform the operation.
Return values
newRegionReturn a new result compound region.
See also
Add(), Subtract(), Union(), Intersect().

Property Documentation

◆ ReduceAngle

double ReduceAngle
getset

The angle of the reduced result.
By default, it's 0. A non-zero value means we'll rotated the reduced result image by the angle clockwise.

See also
ReduceScale, ReduceImage().

◆ ReduceScale

double ReduceScale
getset

The scale of the reduced result.
By default, it's 1. Change this value to scale the reduced result image.

See also
ReduceAngle, ReduceImage().