You are here: Start » Tutorial Exercises » Edge-based Template Matching: Gasket (ebtm_gasket)
Edge-based Template Matching: Gasket (ebtm_gasket)
Aim
Your task is to create a program which will be able to detect the position of a gasket.
Input
Images of a gasket with variable location and rotation.
The input images are stored in
gasket_inspection
directory.
Output
The location of the object.
Hints
This exercise shows a way to find an object in an image using Edge-based Template Matching. To use EbTM please use LocateSingleObject_Edges filter.
Solution (FIS)
-
Add EnumerateImages filter to load consecutive images from a disk directory.
-
Add LocateSingleObject_Edges filter and connect it with the input image.
-
Open a template matching editor on inEdgeModel and select the template region as shown in the picture below.
-
Set the Rotation Tolerance to 20.
-
Add the outImage and outObject.Match outputs to a data preview.
-
Perform several iterations of the program and verify if the results are correct.
-
Set inSearchRegion as shown in the picture below to further improve the filter's performance.
-
Add the inSearchRegion and outObject.Point outputs to the data preview to verify the search region.
-
Add AlignRectangle filter and connect outObject.Alignment of LocateSingleObject_Edges filter with inAlignment of AlignRectangle filter.
-
Open a rectangle drawing editor on inRectangle and select a rectangle around the gasket as shown in the picture below.
-
Add the outAlignedRectangle output to a data preview.
Solution - Expert (FIS)
-
Add EnumerateImages filter to load consecutive images from a disk directory.
-
Add LocateSingleObject_Edges filter and connect it with the input image.
-
Open a template matching editor on inEdgeModel and select the template region as shown in the picture below. Please note that you can select multiple smaller, separate regions for better rotation detection.
-
Set the range of possible rotations from -20 to +20.
-
In the next tab mark a reference rectangle as shown in the image below.
-
Add the outImage and outObject.Match outputs to a data preview.
-
Perform several iterations of the program and verify if the results are correct.
-
Set inSearchRegion as shown in the picture below to further improve the filter's performance. Please note that the selected region must cover all possible locations of a point which falls between the template regions selected in step 3.
-
Add inSearchRegion and outObject.Point outputs to the data preview to verify the search region.