| Developers' Corner


“For most applications, the standard parameter values are sufficient.” This sentence is often read in the HALCON Solution Guide. But what to do if the results do not meet your expectation?

The metrology model, a lightning-fast measuring method, which leaves no whishes unfulfilled concerning cycle time requirements. The fit of the returned geometric shape on the other hand might leave some room for improvement on your specific application. In this article we want to highlight two important parameters concerning fitting the geometric shapes: distance_threshold and min_score. 

Quick metrology refresher:

Measuring linear, circular, rectangular or elliptical structures (Figure 1) is done in two main steps: 

1) Offline step: Create a metrology model and add metrology objects. Metrology objects are defined by measure rectangles along the chosen geometric primitives. The measure rectangles should always enclose the edge of the image structure to be measured. 

2) Online step: Apply the metrology model. For every metrology object and for every measure rectangle a set of edges is extracted (see Figure 2). For every metrology object, the chosen geometric shape is initially defined by selecting a small set of support-points at random. Other edges are called inliers, if they are close to this geometric shape. If not enough inliers can be found, another set of support-points is chosen. The search is finished when a candidate is found that satisfies metrology model parameters. This is a RANdom SAmpling Consensus approach (RANSAC).  

distance_threshold has a direct influence on the quality of fit of a returned geometric shape. distance_threshold is used to decide whether a detected edge is called an inlier of its measure rectangle. For every edge its distance to the geometric shape is determined. If its distance is smaller than the distance_threshold, the edge is called an inlier. By reducing distance_threshold the position and size of the returned geometric shape will be improved. See how the outer circle improves from Figure 3 to Figure 4. 

min_score on the other hand specifies the number of measure rectangles that include a support-point or inlier divided by the total number of measure rectangles. min_score does not represent a quality value with respect to the fitting of the geometric shape. However, in images with a high degree of clutter or strong background texture, it is recommended to increase the value of min_score, since otherwise false instances of a metrology object could be found. 

Finally, what is the reason for the fast runtime?

The above described RANSAC approach does not return the optimal but the first geometric shape that satisfies the given model parameters. As always, more information can be found in the documentation (Solutions Guide III b 2D Measuring).