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 is variable.

Output

Calculated distance between mounting holes.

Hints

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

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

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

Solution (AVS)

  1. Add EnumerateImages filter to get load consecutive images of some disk directory.

  2. Add ThresholdToRegion filter to extract a badge from the background.

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

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

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

  6. Add two FitCircleToEdges filters. Connect to it an input image and previously created CoordinateSystem2D from CreateCoordinateSystemFromRectangle.

  7. Set inFittingFields to find mounting holes.

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

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

Macrofilter Main performs measurements.

Used Filters

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

Further Readings