This interface provide basic functionalities of the calibration object. More...
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 | |
ILObject * | Copy () |
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. | |
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...
LPVErrorCode AddPoint | ( | double | imagePointX, |
double | imagePointY, | ||
double | worldPointX, | ||
double | worldPointY | ||
) |
Add a new point pair for calibration.
[in] | imagePointX | The x-coordinate of the image point. |
[in] | imagePointY | The y-coordinate of the image point. |
[in] | worldPointX | The x-coordinate of the world point. |
[in] | worldPointY | The y-coordinate of the world point. |
error | Return error code if anything is wrong. |
LPVErrorCode AddPoints | ( | ILCalibPointPairs * | pointPairs | ) |
Add a collection of point pairs for calibration, usually you get these point pairs from a calibration board.
[in] | pointPairs | The collection of point pairs. |
error | Return error code if anything is wrong. |
LPVErrorCode Calibrate | ( | ) |
Do calibration with current configuration and point pairs added.
error | Return error code if anything is wrong. |
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.
[in] | image | The input image. |
[out] | fixedImage | Output the fixed result image. |
error | Return error code if anything is wrong. |
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.
[in] | pointPairs | The collection of point pairs. |
error | Return error code if anything is wrong. |
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.
[in] | imagePointX | The x-coordinate of the image point. |
[in] | imagePointY | The y-coordinate of the image point. |
[out] | worldPointX | Return the x-coordinate of the world point. |
[out] | worldPointY | Return the y-coordinate of the world point. |
BOOL IsCalibrated | ( | ) |
Check whether the calibration object is well-calibrated.
val | Return True if it's calibrated, otherwise, return False. |
void SetImageSize | ( | int | w, |
int | h | ||
) |
Set the image size from camera, use for calibration process without image, such as 9 points calibration.
[in] | w | The width of the image. |
[in] | h | The height of the image. |
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.
[in] | offsetX | The x-coordinate of offset to origin point. |
[in] | offsetY | The y-coordinate of offset to origin point. |
[in] | deltaAngle | The clockwise delta rotation angle of the coordinates. |
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.
[in] | tf | The transformation. |
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.
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.
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.
[in] | worldPointX | The x-coordinate of the world point. |
[in] | worldPointY | The y-coordinate of the world point. |
[out] | imagePointX | Return the x-coordinate of the image point. |
[out] | imagePointY | Return the y-coordinate of the image point. |
|
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 model | Original | Undistort | Undistort and Untilt |
---|---|---|---|
N-Points | Support | - | Only untilt |
Pinhole | Support | Support | Support |
FFD | Support | Support | Support |
Custom | Support | - | - |