You are here: Start » Program Examples » Seat Mount

Seat Mount


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


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


Calculated distance between mounting holes.


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, the CoordinateSystem2D connected with a object location must be prepared. Use the LocateSingleObject_Edges1 to create the reference CoordinateSystem2D and then use Region Analysis technique on the selected ROI.

Labeling connections is explained in this article.

Solution (AVS)

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

  2. In section PROCESS add the 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 the inMaxPyramidLevel to 2.
    • To specify the minimum strength of edges used for matching, set the inEdgeThreshold to 120.
    • Set the 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 the CreateRectangleRegion filter to create a rectangular region for the next steps of the algorithm. Connect its inputs:

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

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

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

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

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

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

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

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

Macrofilter Main

Macrofilter DetectHole

Used Filters

Icon Name Description
PointToPointDistance Measures the distance between two points.
CreateRectangleRegion Creates a region corresponding to a given rectangle.
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.
LocateSingleObject_Edges1 Detection of an object whose outlines are sharp and rigid. Often one of the first filters in a program.

Further Readings

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