You are here: Start » Tutorial Exercises » Shape Fitting: Gasket
Shape Fitting: Gasket
Aim:
Your task is to create a program that can measure the distance between two holes in a gasket.
Input:
Images of a gasket with variable location and rotation.

The input images are stored in the gasket_inspection directory.
Output:
The distance between the centers of two holes.

Hints:
Start the program as in the "Edge-based Template Matching: Gasket" tutorial. Then use the FitCircleToEdges filters to precisely detect the holes and PointToPointDistance to measure the distance between their centers.
Labeling connections is explained in this article.
Solution (AVS):
- 
Start with the program created in the "Edge-based Template Matching: Gasket" tutorial.
 - 
Add the FitCircleToEdges filter and define its inFittingField input as shown in the picture below.

 - 
Add a second FitCircleToEdges filter and configure it for the second hole.
 - 
Add the output circles to a data preview.
 - 
Expose the outCircle.Center output on both of the shape fitting filters by using the "Show/Hide Ports" command.
 - 
Add the PointToPointDistance filter and connect the two circle centers to its inputs.
 - 
Create a second data preview for the outDistance output.
 

Further Readings
- Shape Fitting - This article presents usage of the Shape Fitting technique.
 - Template Matching - Most detailed description of the Template Matching technique.
 
