You are here: Start » Program Examples » Seat Mount

Seat Mount

Aim

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

Input

An image of a seat mount. The location and orientation of the object is variable.

Output

Calculated distance between mounting holes.

Hints

Location of object is variable. To find object's holes combination of Region Analysis and Template Matching techniques can be used. To do measurements, which are independent of object orientation, CoordinateSystem2D connected with a object location must be prepared. Use LocateSingleObject_Edges1 to create reference CoordinateSystem2D and then use Region Analysis technique on the selected ROI.

Labeling connections is explained in this article.

Solution (AVS)

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

  2. In section PROCESS add LocateSingleObject_Edges1 filter to find a location of the object.

    • Click the "..." button at the inEdgeModel input to open the GUI for creating template matching models.
    • Select the template region which should contain characteristic edges of the object, but should be not too big.
    • The rotation of the object is in specified range, therefore you can narrow the expected rotation by setting:
      • in Expert Complexity Level: inMinAngle to -30 and inMaxAngle to 30,
      • in Basic Complexity Level: Rotation Tolerance to 60.
    • To speed up locating an object, click the "..." button at the inSearchRegion and select a region of possible object centers.
    • Set inMaxPyramidLevel to 2.
    • To specify the minimum strength of edges used for matching, set inEdgeThreshold to 120.
    • Set inMinScore to 0.850.
  3. Create Step macrofilter DetectHole by right-clicking on empty space in Program Editor and selecting "Add New Step Here...". This macrofilter will detect center of the hole within input region of interest.
    Create three inputs: one of type Image called Image, second of type Rectangle2D called Roi and third of type CoordinateSystem2D called RoiAlignment.

  4. Click the "..." button at the inRoi input in the Properties window, to open the GUI for selecting a ROI. Select the rectangular region containing the first required hole.
    .

  5. Inside this macrofilter:

    1. Right-click on the inImage input, select "Property Outputs" and choose Width and Height from the list. Two additional inputs will be available on the top bar.
    2. Add CreateRectangleRegion filter to create a rectangular region for the next steps of the algorithm. Connect its inputs:

    3. Add ThresholdToRegion filter to create a region containing pixels of the hole. Connect its inputs inRoi with CreateRectangleRegion output outRegion.

    4. Add RegionMassCenter filter to compute a center of the hole.

    5. Create the macrofilter's output outHoleCenter and connect it with outMassCenter.

    6. Create the macrofilter's output outAlignedRoi and connect it with outAlignedRectangle.

    7. Create the macrofilter's output outHoleRegion and connect it with ThresholdToRegion's output outRegion.

  6. Add another DetectHole macrofilter and set its inputs inImage, inRoiAlignment, inFrameWidth and inFrameHeight as in previous steps.

  7. Select the rectangular region containing the second required hole. .

  8. Add PointToPointDistance filter and connect its inputs with outputs of both instances of the DetectHole macrofilter. The output outDistance is desired result of this program.

Macrofilter Main

Macrofilter DetectHole

Used Filters

Icon Name Description
CreateRectangleRegion Creates a region corresponding to a given rectangle.
PointToPointDistance Measures the distance between two points.
LocateSingleObject_Edges1 Detection of an object whose outlines are sharp and rigid. Often one of the first filters in a program.
EnumerateImages Emulates image acquisition with images stored on disk.
ThresholdToRegion Extraction of a region of objects that can be defined by a salient brightness.
LoadObject Loads an object from a file.
RegionMassCenter_OrNil Computes a point with coordinates equal to the average coordinates of the region's pixels; returns NIL if the region is empty.

Further Readings

  • Blob Analysis - Article presents detailed information about the Blob Analysis technique.
  • Template Matching - Most detailed description of the Template Matching technique.