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, the CoordinateSystem2D connected with a object location must be prepared. Use badge's bounding rectangle to create the reference CoordinateSystem2D.

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

Labeling connections is explained in this article.

Solution (AVS)

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

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

    • To select only darker object set the inMaxValue to 140.0.
    • Set the 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 the RegionBoundingRectangle_OrNil filter.

  4. The badge bounding rectangle can have a horizontal or vertical orientation. The orientation must be still 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 the two FitCircleToEdges filters. Connect to them the input image and the previously created CoordinateSystem2D from the CreateCoordinateSystemFromRectangle.

  7. Set the inFittingFields to find mounting holes.

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

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

Macrofilter Main performs measurements.

Used Filters

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

Further Readings