You are here: Start » Program Examples » Badge Measurement

Badge Measurement

Aim:

The task is to measure a distance between centers of two badge mounting holes.

Input:

An image of a badge. The location and orientation of the object are variable.

Output:

The calculated distance between the mounting holes.

Hints:

The location of the object is variable. To find the object, Blob Analysis technique can be used. In this case, this way can be faster than performing Template Matching.

To do measurements that are independent of object orientation, the CoordinateSystem2D connected with the object location must be prepared. Use the badge's bounding rectangle to create the reference CoordinateSystem2D.

Use the shape fitting technique to find the exact position of the mounting holes.

Labeling connections is explained in this article.

Solution (FIS):

  1. In the Workspace Explorer open the workspace Examples and in the Filmstrip window select the Badge dataset. Drag the Image channel to the ACQUIRE section.

  2. Add the ThresholdToRegion filter to the PROCESS section in order to extract the badge from the background.

    • To select only darker object, set the inMaxValue to 140.0.
    • Set the inMinValue to Auto. This step the removes lower limit of color.
  3. There is a single object selected so no additional filtering steps are required. Add the RegionBoundingRectangle_OrNil filter.

  4. The badge bounding rectangle can have a horizontal or vertical orientation. The orientation must be fixed to perform further measurements. Add the NormalizeRectangleOrientation filter and set the inRectangleOrientation to Horizontal.

  5. Add the CreateCoordinateSystemFromRectangle filter and use the normalized rectangle to create a new reference system.

  6. Add 2 FitCircleToEdges filters. Connect the input image and the previously created CoordinateSystem2D from the CreateCoordinateSystemFromRectangle to them.

  7. Set the inFittingFields to find the mounting holes.

  8. Calculate the distance between the found circles using the PointToPointDistance filter.

  9. Show the found distance on a new preview window.

Macrofilter Main performs the measurements.

Used Filters

Icon Name Description
CreateCoordinateSystemFromRectangle Most often used to define an object alignment from a filter like RegionBoundingRectangle.
FitCircleToEdges Precise detection of a circular object or hole, whose rough location is known beforehand.
PointToPointDistance Measures the distance between two points.
RegionBoundingRectangle_OrNil Computes the smallest rectangle containing a region; returns NIL if the region is empty.
ThresholdToRegion Extraction of a region of objects that can be defined by a salient brightness.

Further Readings