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

This interface provide basic functionalities of the calibration object. More...

Inheritance diagram for ILCalib:
ILObject ILCalibCustom ILCalibFFD ILCalibNPoints ILCalibPinHole LCalibCustom LCalibFFD LCalibNPoints LCalibPinHole

Public Member Functions

LPVErrorCode AddPoint (double imagePointX, double imagePointY, double worldPointX, double worldPointY)
 
LPVErrorCode AddPoints (ILCalibPointPairs *pointPairs)
 
LPVErrorCode Calibrate ()
 
LPVErrorCode FixImage (ILImage *image, ILImage *fixedImage)
 
LPVErrorCode GenPostTransformMatrix (ILCalibPointPairs *pointPairs)
 
void ImageToWorld (double imagePointX, double imagePointY, double *worldPointX, double *worldPointY)
 
BOOL IsCalibrated ()
 
void SetImageSize (int w, int h)
 
void SetPostTransform (double offsetX, double offsetY, double deltaAngle)
 
void SetPostTransformMatrix (ILTransform *tf)
 
void SetPostTransformMatrix23 (LMatrix23 *data)
 
void SetPostTransformMatrix33 (LMatrix33 *data)
 
void WorldToImage (double worldPointX, double worldPointY, double *imagePointX, double *imagePointY)
 
- Public Member Functions inherited from ILObject
ILObjectCopy ()
 
LPVErrorCode Load (LString filename)
 
void Reset ()
 
LPVErrorCode Save (LString filename)
 
BOOL Valid ()
 

Properties

double CalibError [get]
 The overall RMS re-projection error for the calibration, calculated based on the distances between the image points and the projected (using the optimized calibration matrices) world points. It's defined as:
\( \sqrt{ \frac{1}{n} \sum_{i=0}^{n} distance(p^{image}_i, p^{proj}_i)^2 } \).
 
LPVFixImageMode FixImageMode [get, set]
 The mode to fix image used in FixImage(). More...
 
double FixImageOffsetX [get, set]
 The x-coordinate offset (in pixel unit) of the fixed image used in FixImage(), used together with FixImageOffsetY.
By default, it's 0, means no offset in x-coordinate. You may change the offset to translate the fixed image, for example move the inspect region to the center of the fixed image.
 
double FixImageOffsetY [get, set]
 The y-coordinate offset (in pixel unit) of the fixed image used in FixImage(), used together with FixImageOffsetX.
By default, it's 0, means no offset in y-coordinate. You may change the offset to translate the fixed image, for example move the inspect region to the center of the fixed image.
 
double FixImageScale [get, set]
 The scale of the fixed image used in FixImage().
By default, it's 1, means no scale. You may change the scale factor to zoom in/out the fixed image.
 
LPVInterpolationMethod InterpolationMethod [get, set]
 The interpolation method used in fix the image for undistortion (and untilt). By default, it's LPVInterCubic.
 
LPVCalibModel Model [get]
 The calibration model.
 
BOOL UseCache [get, set]
 Whether to make use of cache which is used to speed-up the process of the image undistortion (and untilt), but consume more memory. By default, it's off.
 

Detailed Description

This interface provide basic functionalities of the calibration object.

This is a base interface for all kinds of calibrations. For different chosen calibration model, the implementation varies.

To use this interface, you should create a calibration object, such as:

ILCalibNPoints, ILCalibPinHole, ILCalibFFD, ILCalibCustom...

Member Function Documentation

◆ AddPoint()

LPVErrorCode AddPoint ( double  imagePointX,
double  imagePointY,
double  worldPointX,
double  worldPointY 
)

Add a new point pair for calibration.

Parameters
[in]imagePointXThe x-coordinate of the image point.
[in]imagePointYThe y-coordinate of the image point.
[in]worldPointXThe x-coordinate of the world point.
[in]worldPointYThe y-coordinate of the world point.
Return values
errorReturn error code if anything is wrong.

◆ AddPoints()

LPVErrorCode AddPoints ( ILCalibPointPairs pointPairs)

Add a collection of point pairs for calibration, usually you get these point pairs from a calibration board.

Parameters
[in]pointPairsThe collection of point pairs.
Return values
errorReturn error code if anything is wrong.
See also
ILCalibBoard

◆ Calibrate()

LPVErrorCode Calibrate ( )

Do calibration with current configuration and point pairs added.

Return values
errorReturn error code if anything is wrong.

◆ FixImage()

LPVErrorCode FixImage ( ILImage image,
ILImage fixedImage 
)

Fix the image for undistortion (and untilt).
The rectification works with a calibrated system, if not it returns the LPVErrCalibNotCalib error.

Parameters
[in]imageThe input image.
[out]fixedImageOutput the fixed result image.
Return values
errorReturn error code if anything is wrong.
See also
FixImageMode, FixImageScale, FixImageOffsetX, FixImageOffsetY, InterpolationMethod

◆ GenPostTransformMatrix()

LPVErrorCode GenPostTransformMatrix ( ILCalibPointPairs pointPairs)

Generate and set the post-transform matrix, according to the pairs of some pixel positions in the output fixed image and their expected world positions.

Parameters
[in]pointPairsThe collection of point pairs.
Return values
errorReturn error code if anything is wrong.

◆ ImageToWorld()

void ImageToWorld ( double  imagePointX,
double  imagePointY,
double *  worldPointX,
double *  worldPointY 
)

Map a point from the image coordinates to the world coordinates.
The mapping works with a calibrated system, if not the output world point is the same point as the input image point.

Parameters
[in]imagePointXThe x-coordinate of the image point.
[in]imagePointYThe y-coordinate of the image point.
[out]worldPointXReturn the x-coordinate of the world point.
[out]worldPointYReturn the y-coordinate of the world point.

◆ IsCalibrated()

BOOL IsCalibrated ( )

Check whether the calibration object is well-calibrated.

Return values
valReturn True if it's calibrated, otherwise, return False.

◆ SetImageSize()

void SetImageSize ( int  w,
int  h 
)

Set the image size from camera, use for calibration process without image, such as 9 points calibration.

Parameters
[in]wThe width of the image.
[in]hThe height of the image.

◆ SetPostTransform()

void SetPostTransform ( double  offsetX,
double  offsetY,
double  deltaAngle 
)

Set customized post-transform to the world coordinates, based on the transformation of origin point.
It is applied at the end of the image-to-world mapping, and inverted applied at the beginning of the world-to-image mapping.
If both post-transform origin and matrix is configured, the first one is applied firstly then the later one. In the inverted transform, it's done in the reversed order.

Parameters
[in]offsetXThe x-coordinate of offset to origin point.
[in]offsetYThe y-coordinate of offset to origin point.
[in]deltaAngleThe clockwise delta rotation angle of the coordinates.
See also
SetPostTransformMatrix(), SetPostTransformMatrix23(), SetPostTransformMatrix33().

◆ SetPostTransformMatrix()

void SetPostTransformMatrix ( ILTransform tf)

Set customized post-transform to the world coordinates, using transformation matrix.
It is applied at the end of the image-to-world mapping, and inverted applied at the beginning of the world-to-image mapping.
If both post-transform origin and matrix is configured, the first one is applied firstly then the later one. In the inverted transform, it's done in the reversed order.

Parameters
[in]tfThe transformation.
See also
SetPostTransform(), SetPostTransformMatrix23(), SetPostTransformMatrix33().

◆ SetPostTransformMatrix23()

void SetPostTransformMatrix23 ( LMatrix23 data)

Set customized post-transform to the world coordinates, using \( 2 \times 3 \) transformation matrix, which has rotation, translation and scale DOF.

See also
SetPostTransform(), SetPostTransformMatrix(), SetPostTransformMatrix33().

◆ SetPostTransformMatrix33()

void SetPostTransformMatrix33 ( LMatrix33 data)

Set customized post-transform to the world coordinates, using \( 3 \times 3 \) transformation matrix, which has rotation, translation, scale and perspective projection DOF.

See also
SetPostTransform(), SetPostTransformMatrix(), SetPostTransformMatrix23().

◆ WorldToImage()

void WorldToImage ( double  worldPointX,
double  worldPointY,
double *  imagePointX,
double *  imagePointY 
)

Map a point from the world coordinates to the image coordinates.
The mapping works with a calibrated system, if not the output world point is the same point as the input image point.

Parameters
[in]worldPointXThe x-coordinate of the world point.
[in]worldPointYThe y-coordinate of the world point.
[out]imagePointXReturn the x-coordinate of the image point.
[out]imagePointYReturn the y-coordinate of the image point.

Property Documentation

◆ FixImageMode

LPVFixImageMode FixImageMode
getset

The mode to fix image used in FixImage().

Change the mode will also affect the image-world mapping logic.
LPVFixImageNone (Default) indicate user is using the original image captured by the camera for the subsequent detection or inspection tasks, so the image point in the image-world mapping logic is in the coordinates of the original image. Correspondingly, for LPVFixImageUndistort mode, the image point is in the coordinates of the undistorted image. For LPVFixImageUndistortAndUntilt mode, it's in the coordinates of the undistorted and untilt image. If you want to use different mapping logic at the same time, you may have to duplicate the calibration object via Copy() and set different FixImageMode for them.

Different calibration model support different fix mode, as the table below.

Calibration modelOriginalUndistortUndistort and Untilt
N-PointsSupport-Only untilt
PinholeSupportSupportSupport
FFDSupportSupportSupport
CustomSupport--