You are here: Start » Tutorial Exercises » Edge-based Template Matching: Gasket

Edge-based Template Matching: Gasket

Aim:

Your task is to create a program which will be able to detect the position of a gasket.

Input:

The images of a gasket with variable location and rotation.

The input images are stored in the gasket_inspection directory.

Output:

The location of the object.

Hints:

This exercise demonstrates a method to find an object in an image using Edge-based Template Matching. To use EbTM, please use the LocateSingleObject_Edges1 filter.

Labeling connections is explained in this article.

Solution (FIS):

  1. Add the EnumerateImages filter to the ACQUIRE section to load consecutive images from a disk directory.

  2. Add the LocateSingleObject_Edges1 filter to the PROCESS section and connect it with the output image.

  3. Open a template matching editor on inEdgeModel and make sure to select Expert complexity mode in the top right corner. Select the template region as shown in the picture below:

  4. Set the Rotation Tolerance to 20 because the angle varies slightly.

  5. Display the outImage and outObject.Match outputs in a data preview.

  6. Perform several iterations of the program and verify if the results are correct.

  7. Set inSearchRegion as shown in the picture below to improve the filter's performance.

  8. Add the inSearchRegion and outObject.Point outputs to the data preview to verify the search region.

  9. Add the AlignRectangle filter and connect outObject.Alignment of the LocateSingleObject_Edges1 filter with inAlignment of the AlignRectangle filter.

  10. Open a rectangle drawing editor on inRectangle and select a rectangle around the gasket as shown in the picture below:

  11. Add the outAlignedRectangle output to a data preview.

Further Readings