7.4.5.3   Alignment

If the object in your image appears shifted or rotated, an alignment, which can be chosen on the Code Generation tab under Alignment Method Affine Transformation, is necessary. An alignment allows you to automatically relocate your ROI in an image where the object occurs in a different position. Note, however, that the Measure Assistant does not perform the alignment by itself, but only generates code to align the measurements if a transformation matrix is available from other methods such as Template Matching. For general information, please read the following paragraph about alignment with the Measure Assistant. For more detailed information, please refer to the documentation on matching in the Solution Guide on Matching, Chapter 2.4 “Use the Results of Matching”.

To perform an alignment with the Measure Assistant, please follow the steps that are described in this paragraph. When generating code with an activated Affine Transformation option, the assistant produces code that requires a transformation matrix. To find the object within the image, you can perform a matching as explained in the Solution Guide on Matching or use the Matching Assistant to guide you through the matching task. By teaching a template, the object can be found in any position and orientation. After this successful matching, the affine transformation can be constructed with the operator vector_angle_to_rigid using the difference between the original and new model positions. This operator produces the homogeneous transformation matrix that describes the transformation from the old to the new position.

If the object in your image is only shifted but not rotated, the suitable Alignment Method would be Translation Only which also needs less processing time than Affine Transformation.

No Alignment is needed if the object always appears in the same position, or the intent is to find the object location by measuring.

You can now continue to change variable names if necessary, or preview the generated code before inserting it into your HDevelop program.