In a typical machine vision application, you extract measurements from ROIs rather than the entire image. To use this technique, the parts of the object you are interested in must always appear inside the ROIs you define.
If the object under inspection is always at the same location and orientation in the images you need to process, defining ROIs is straightforward.
Often, the object under inspection appears shifted or rotated in the image you need to process, relative to the reference image in which you located the object. When this occurs, the ROIs need to shift and rotate with the parts of the object in which you are interested. For the ROIs to move with the object, you need to define a reference coordinate system relative to the object in the reference image. During the measurement process, the coordinate system moves with the object when the object appears shifted and rotated in the image you need to process. This coordinate system is referred to as the measurement coordinate system. The measurement VIs automatically move the ROIs to the correct position using the position of the measurement coordinate system relative to the reference coordinate system. Refer to the Dimensional Measurements section of the NI Vision Concepts Help for information about coordinate systems.
You can build a coordinate transformation using edge detection or pattern matching. The output of the edge detection and pattern matching VIs that build a coordinate transformation are the origin, angle, and axes direction of the coordinate system. Some machine vision VIs take this output and adjust the regions of inspection automatically. You also can use these outputs to move the regions of inspection relative to the object programmatically.
You can build a coordinate transformation using two edge detection techniques. Use the IMAQ Find CoordSys (Rect) 2 VI to define a reference coordinate system using one rectangular region. Use the IMAQ Find CoordSys (2 Rects) 2 VI to define a reference coordinate system using two independent rectangular regions. Complete the following steps to build a coordinate transformation using edge detection.
![]() |
|
| 1 Search Area for the Coordinate System | 3 Origin of the Coordinate System |
| 2 Object Edges | 4 Measurement Area |
![]() |
|
| 1 Primary Search Area | 3 Origin of the Coordinate System |
| 2 Secondary Search Area | 4 Measurement Area |
You can build a coordinate transformation using pattern matching. Use the IMAQ Find CoordSys (Pattern) 2 VI to define a reference coordinate system based on the location of a reference feature. Use this technique when the object under inspection does not have straight, distinct edges. Complete the following steps to build a coordinate transformation using pattern matching:
![]() |
Note The object can rotate 360° in the image using this technique if you use rotation-invariant pattern matching. |
The flowchart in the following figure guides you through choosing the best method for building a coordinate transformation for your application.
