You are here: Start » Tutorial Exercises » Finding Razor Head Defects

Finding Razor Head Defects

Aim:

Develop an application that finds two types of product defects:

  • Check if both razor arms are not broken,
  • Check if smaller arms are not connected.

Show the inspection results on the HMI.

Input:

Images of razor heads with defects. Objects are lit using a backlight. Example defects are marked in red.

Images are stored in the razor directory.

Output:

The application should show appropriate information if any of the defects are identified. Design a simple HMI that shows the result of each inspection.

Hints:

This exercise presents one of the typical vision problems. This task uses a common algorithm schema:

  • Find the element using the Template Matching technique,
  • Check for defects presence using high-level tools.

You can label outputs by clicking on them twice.

Solution (FIS):

  1. Load images from the directory using the EnumerateImages filter. Place it in the ACQUIRE section.

  2. Add the LocateSingleObject_Edges1 filter to the PROCESS section and connect to it an output of the EnumerateImages filter.

  3. Create a template model using the Model Definition Window. To access it, go to the Properties window and click the "..." button next to inEdgeModel. Create the model as shown in the image below:

NOTE: To get more information on how to create Template Matching models, please refer to the Creating Models for Template Matching article.

  1. Add the CheckPresence_PixelAmount filter to check if the distance between inner arms is filled with white pixels.

    This filter checks if a white color covers more than 40% of the selected ROI.

  2. Add two other CheckPresence_PixelAmount filters to check the presence of arms.

  3. Connect outObject.Alignment with the input inRoiAlignment of each CheckPresence_PixelAmount filter. Thanks to this, even if the object moves or rotates, the alignment will automatically set the correct ROIs in the right places.

  4. Open the HMI Designer by clicking its icon in the Application Toolbar. Add a View2DBox and connect it with the output of EnumerateImages.

  5. Add three PassFailIndicator HMI controls and connect them with outIsPresent outputs of the CheckPresence_PixelAmount filter.

  6. Add a Label with "Razor inspection" text.

Macrofilter Main

Further Readings