| MIL 10 Reference
| Customize Help
| Save Settings

M3dmapAlign



See also
Availability
Not available in MIL-Lite
Available in MIL

Available on Windows
Available on Linux

Available on Non-Matrox computer
Available on Matrox 4Sight-X
Available on Matrox 4Sight GP
Available on Matrox Supersight
function map Function map
Examples
Synopsis
Compute the transformation that aligns two point clouds.
Syntax
void M3dmapAlign(
MIL_ID Context3dmapId, //in
MIL_ID ModelResult3dmapId, //in
MIL_INT ModelLabelOrIndex, //in
MIL_ID SceneResult3dmapId, //in
MIL_INT SceneLabelOrIndex, //in
MIL_ID PreAlignmentResult3dmapOrArrayBufId, //in
MIL_ID AlignmentResult3dmapOrArrayBufId, //in
MIL_INT64 ControlFlag, //in
MIL_INT64 *StatusPtr //out
)
Description

This function takes two point clouds, a model point cloud and a scene point cloud, and returns the transformation that could move the scene's relative coordinate system such that the two point clouds are expressed using the same coordinates.

The function finds points in one point cloud and pairs them up with points in the other point cloud to minimize the root mean square error (RMS error) of the distance between all the paired points. From this set of point pairs, a new set of point pairs is calculated that minimizes the RMS error even more. The iterations continue, trying to reduce the RMS error in each iteration, until at least one stop condition occurs, such as when the RMS error falls below a specified threshold or the maximum number of iterations has occurred. You can specify the stop conditions using M3dmapControl().

Once a stop condition occurs, M3dmapAlign() returns the transformation that moves the scene's relative coordinate system so that the two point clouds are expressed in the same coordinates. The resulting transformation matrix can be returned in a pairwise 3D alignment result buffer (M3dmapAllocResult() with M_ALIGNMENT_RESULT) or a 4x4 MIL array buffer (MbufAlloc2d() with M_ARRAY and 32 + M_FLOAT).

Typically, you can start the iterative process by specifying a rough estimate of the final transformation as a prealignment. You can prealign the point clouds by overlapping their centroids (center of mass). In this case, you must call M3dmapControl() with M_PREALIGNMENT_MODE set to M_CENTROID. When prealigning the point clouds using their centroids, there is only a translation and no rotation. Alternatively, you can prealign the point clouds by directly passing a transformation matrix. This transformation matrix is typically either the result of a previous call to M3dmapAlign() or the result of some custom processing stored in a 4x4 MIL array buffer. You can also prealign the point clouds by combining the alignment of the centroids, which only results in a translation, with a specified transformation matrix, from which only the rotation is used.

Unlike most other functions that modify a MIL object, you can call this function concurrently from multiple threads on the same M_POINT_CLOUD_CONTAINER result buffer (ModelResult3dmapId) without using a M_MUTEX object. This is valid as long as the ModelLabelOrIndex parameter of the concurrent calls is set to a different index, and is not set to M_ALL.

Note that this function reference has not been updated for a MIL system added during a MIL update. Refer to the MIL system's release note to see if there is complementary information.
Parameters
This function is not supported on the selected boards.
Parameters
Context3dmapId

Specifies the identifier of a pairwise 3D alignment context, allocated using M3dmapAlloc() with M_PAIRWISE_ALIGNMENT_CONTEXT.

ModelResult3dmapId

Specifies the 3D reconstruction result buffer of type M_POINT_CLOUD_CONTAINER that contains the model point cloud(s).

ModelLabelOrIndex

Specifies the point cloud(s) in the specified 3D reconstruction result buffer, or the entire result buffer itself, that represents the model.

function map For specifying a point cloud representing the model
CollapseValue Description
Collapse M_DEFAULT

Same as M_ALL.

Collapse

Specifies the index of a point cloud in the specified 3D reconstruction result buffer.

(summarize)
Parameters

Specifies the index of an existing point cloud.

Collapse

Specifies the label of a point cloud in the specified 3D reconstruction result buffer.

(summarize)
Parameters

Specifies the label of an existing point cloud.

Collapse M_ALL

Specifies all point clouds in the specified 3D reconstruction result buffer.

SceneResult3dmapId

Specifies the 3D reconstruction result buffer of type M_POINT_CLOUD_CONTAINER that contains the scene point cloud(s).

SceneLabelOrIndex

Specifies the point cloud(s) in the specified 3D reconstruction result buffer, or the entire result buffer itself, that represents the scene.

function map For specifying a point cloud representing the scene
CollapseValue Description
Collapse M_DEFAULT

Same as M_ALL.

Collapse

Specifies the index of a point cloud in the specified 3D reconstruction result buffer.

(summarize)
Parameters

Specifies the index of an existing point cloud.

Collapse

Specifies the label for a point cloud in the specified 3D reconstruction result buffer.

(summarize)
Parameters

Specifies the label of an existing point cloud.

Collapse M_ALL

Specifies all point clouds in the specified 3D reconstruction result buffer.

PreAlignmentResult3dmapOrArrayBufId

Specifies a transformation matrix in a pairwise 3D alignment result buffer or 4x4 MIL array buffer, which is used to prealign the model before the pairwise 3D alignment process begins.

If you are specifying to prealign using the point clouds' centroids (M_PREALIGNMENT_MODE set to M_CENTROID), this parameter can be set to M_NULL or take a transformation matrix. In the later case, the translation which aligns the centroids takes precedence and the only the rotation of the specified transformation matrix is used.

The pairwise 3D alignment result buffer must be allocated using M3dmapAllocResult() with M_ALIGNMENT_RESULT and must contain the results of a previous call to M3dmapAlign(). The 4x4 MIL array buffer must be allocated using MbufAlloc2d() with M_ARRAY and 32 + M_FLOAT, and contain a transformation matrix, typically computed from custom processing.

Specifying a transformation matrix for use during the prealignment step is intended for advanced users; set this parameter to M_NULL if not using a transformation matrix.

AlignmentResult3dmapOrArrayBufId

Specifies a pairwise 3D alignment result buffer or 4x4 MIL array buffer used to store the results from the pairwise 3D alignment process. The alignment result buffer must be allocated using M3dmapAllocResult() with M_ALIGNMENT_RESULT. The 4x4 transformation matrix must be allocated using MbufAlloc2d() with M_ARRAY and 32 + M_FLOAT.

ControlFlag

Reserved for future expansion and must be set to M_DEFAULT.

StatusPtr

Specifies the address of the variable in which to write the 3D alignment status of the alignment operation. If you do not require this information, set this parameter to M_NULL.

function map For retrieving the alignment process status
CollapseValue Description
Collapse M_ALIGN_RMS_ERROR_RELATIVE_THRESHOLD_REACHED

Specifies that the change in RMS error calculated from the distance between paired 3D points of the two aligned point clouds of the last iterations is equal to or lower than the specified percentage threshold (M3dmapControl() with M_ALIGN_RMS_ERROR_RELATIVE_THRESHOLD).

For instance, if the previous iteration had an RMS error of 2.0 and the current iteration has an RMS error of 0.8, the relative error of the current iteration is 0.6 ([2.0-0.8]/2.0).

This is typically considered a successful alignment.

(summarize)
Collapse M_ALIGN_RMS_ERROR_THRESHOLD_REACHED

Specifies that the RMS error calculated from the distance between paired 3D points of the two aligned point clouds of the last iteration is equal to or lower than the specified RMS error threshold (M3dmapControl() with M_ALIGN_RMS_ERROR_THRESHOLD).

This is typically considered a successful alignment.

(summarize)
Collapse M_MAX_ITERATIONS_REACHED

Specifies that the maximum number of iterations of the alignment process, set using M3dmapControl() with M_MAX_ITERATIONS, has been reached.

This is typically considered a timeout.

(summarize)
Collapse M_NOT_ENOUGH_POINT_PAIRS

Specifies that the number of points which overlap between the model point cloud and the scene point cloud is below a critical threshold.

This could occur because the point clouds were too different in the first iteration, or that, throughout the iterations of the pairwise 3D alignment process, the point clouds diverged rather than converged.

This status implies that the function did not discover a transformation which overlaps the two point clouds.

(summarize)
Compilation information
Header Include mil.h.
Library Use mil.lib; mil3dmap.lib.
DLL Requires mil.dll; mil3dmap.dll.
DEFAULT ALL DEFAULT ALL FLOAT FLOAT ALIGN RMS ERROR RELATIVE THRESHOLD REACHED ALIGN RMS ERROR THRESHOLD REACHED MAX ITERATIONS REACHED NOT ENOUGH POINT PAIRS