Up | CircleFinder2D - 165 | EasyOCR - 78 | PolygonMatch2 - 84 | GCPS -110 | HeightMap3D - 111 | ImageExtrema - 129 | PCA3D - 140 | CameraPose3D - 148 | MonoPose3D - 149 | ImagePicker3D - 145 | ExternalCoordinates3D - 157 | MaMa3D - 152 | CircleSegmentor - 153 | PolygonMatch3 - 160

Release Notes
 

  

 
PolygonMatch3 - 160

PolygonMatch3 is an improved PolygonMatch - it is the best PolygonMatch tool i Scorpion Vision Software.

PolygonMatch3 adds a search option, making it possible to make the tool more robust or to iterate over a larger area.

The Search in PolygonMatch3 is a complete PolygonMatch step making it a superior better than the search step in PolygonMatch2.

The search parameters are: scale, independent x and y scale, rotation and multiple positions.

PolygonMatch is an optimal way to locate ONE objects with subpixel accuracy. Multiple polygons define the shape or model of the object. Using the model the same shapes are extracted from the images and fitted to the original model with the highest possible accuracy.  With the Autofit capability the user can generate or train the model by clicking on edges in the image. The edge points are the then fitted to the edge while creating the model.

Below a valve which located using two polygons - a circle and a straight line. A model can consist of any number of polygons. The circle holds the valve and the line fits to the correct angle. In this model a custom match for each polygon ensures that only fits where both polygons are active are accepted.

        

The tool is very powerful tool and can be used to locate an object of any size or shape with sub-pixel resolution.

The next example corrects the location of a printed circuits by 0.05 mm with accuracy better than 1/10 a pixel.

        

Other important application areas are shape verification.


General

Setup.General

Reference - Reference system selection

Tracelines

  • Use Traceline Count - selects to specify the traceline count
    • Count - number of trace lines
    • Step length - distance between traceline
      • Ref coord
      • Pixels
  • Start point - position of starting point on trace line given in reference coordinates
  • End point - position of end point on trace line given in reference coordinates
    • Inverted the sign of start and stop point will change the direction of the trace comb
  • Trace step (pixels) - normally 1 - given in pixels
    • high values than 1 is nomally not recommended
    • value from 0.25 to 0.5 can be used to increase the accuracy of the traceline
  • Line width (pixels) - 0 - trace line is not averaged - a higher value will average N pixels perpendicular to the trace comb

Edge detection

  • Smooth base - 3 is normally a good value
  • Smooth counter - 1 default - given i pixels
    • The smoothing increasing with higher values
  • Differentiation
    • 0 - give threshold
    • 1 - 1. order differentiation - the derivative - default normally used
    • 2 - 2. order differentiation
  • Threshold - the threshold or sensitivity of the edge detector - a lower value increases the sensitivity
    • Percent threshold activates adaptive - threshold is set to N % of maximum values of edges
    • Minimum treshold define minimum value of threshold to accept when adaptive treshold is active
    • Max threshold (peak only) - when active, peaks above this value are ignored. The high peaks are also ignored when the percent threshold is calculated.
  • Polarity - All transitions | Light to dark | Dark to light
  • Mode - Peak | Threshold
  • Edge choice - First | Largest | Last | Nearest - Largest is default and normally the best choice

Setup.Polygons

Line definition file - The paths to be searched are initially read from a text file (see the StrVec format). The name of that file is also stored, for possible future reload. The path information, however, is stored directly in the system, without need for the external file.
You can browse for or manually edit the filename; by clicking "Load", the file is read and its contents stored internally. 

  • Always read file at startup (overwrite SPB) - With this selection, the file is always loaded at startup.

Polygon properties

  • Closed polygons - Select this box if the polygons are closed by default. Individual polygons can be customised separately.

Polygon Editor

  • Numbered list - ordered list of polygons. Each polygon can be made active/inactive by clicking the checkbox in front of the number
  • Contents - the points of the selected polygon
  • New - add polygon
  • Delete - remove selected polygon
  • Up - moves polygon up in list
  • Down - moved polygon down in list
  • Paste new - creates a new polygon, pastes the polygon from the clipboard and presses apply  - this is the quickest way to create many polygons
  • Highlight selection - highlights the selected polygon in the image
    • used to identify a polygon in the image
  • Copy - copies the selected polygon to the clipboard
  • Paste - pastes the clipboard to the selected polygon - will overwrite an existing polygon
  • Copy can be used to transfer polygon to the image for editing and modification. The edited polygon is pasted back to the tool using Paste. More on Point and Click Operations
  • Vector mouse menu - activate by right mouse clicking in the Vector list

    • New - creates a new vector
    • Delete - deletes the selected vector
    • Custom trace... - open dialog to define traceline settings for a single polygon
    • Custom match... - open dialog to define polygon match settings for a single polygon
    • Default trace - remove custom traceline settings for a polygon
    • Default match - remove custom polygon match settings for a polygon
    • Paste new - paste clipboard as new polygon
    • Up - moves polygon up in list
    • Down - moved polygon down in list
    • Grid... - activate dialog for defining polygon grid
    • Delete all - removes all polygons from list
    • Delete empty vectors - remove all empty polygons


    Autofit - Polygon Model Wizard

    Using the Polygon Model Wizard Scorpion helps you create optimal edge polygons for Polygonmatch.

    • Autofit polygons
      • When active Ctrl LMouse will make a edge contour along a path or an object

    The traceline settings are defined under the Setup tab except:

    • Step length
    • Start and End of trace lines

    Visualize will display the trace line - see image to the right

    Note: If Edge trace is difficult - verify wizard settings - long trace lines may cause problems around edge or in corners.

    Polygon properties dialog - vector list custom trace choice:

    Each polygon can have its own settings, overriding the default values. The custom settings include open/closed, tracelines and edge detection.

    Hint: Use individual polygon traceline setting to improve the model

            

    Polygon

    • Closed polygon - polygon is closed

    Trace lines

    • Use Traceline Count - selects to specify the traceline count
      • Count - number of trace lines
      • Step length - distance between traceline
        • Ref coord
        • Pixels
    • Start point - position of starting point on trace line given in reference coordinates
    • End point - position of end point on trace line given in reference coordinates
      • Inverted the sign of start and stop point will change the direction of the trace comb
    • Trace step (pixels) - normally 1 - given in pixels
    • Line width (pixels) - 0 - trace line is not averaged - a higher value will average N pixels perpendicular to the trace comb

    Edge detection

    • Smooth base - 3 is normally a good value
    • Smooth counter - 1 default - given i pixels
      • The smoothing increasing with higher values
    • Differentiation
      • 0 - give threshold
      • 1 - 1. order differentiation - the derivative - default normally used
      • 2 - 2. order differentiation
    • Threshold - the threshold or sensitivity of the edge detector - a lower value increases the sensitivity
      • Percent threshold activates adaptive - threshold is set to N % of maximum values of edges
      • Minimum treshold define minimum value of threshold to accept when adaptive treshold is active
      • Max threshold (peak only) - when active, peaks above this value are ignored. The high peaks are also ignored when the percent threshold is calculated.
    • Polarity - All transitions | Light to dark | Dark to light
    • Mode - Peak | Threshold
    • Edge choice - First | Largest | Last | Nearest - Largest is default and normally the best choice
    • Set default - reset all custom values

    Polygon properties dialog - vector list custom polygon match choice:

    Each polygon can have its own settings, overriding the default values. This can be very useful to e.g. verify very small details in an image.

    • Min match percent - match will succeed only if this particular polygon has this match percent. This can be a small detail that must be present in the image
    • Exclude from total match - use this polygon in the fit process, but ignore its results
    • Set default - reset all custom values


    Add polygon

    Rectangle and Circle can be added as polygon using this tab. This is valuable when working with these shapes.

    Point & Click Support

    Two points will define a circle - first point is circle center and the seconds defines the radius. Four points will define a rectangle. Ctrl-Z will paste the clipboard to the tool. Ctrl-A will add the object to the polygon vector list

Setup.Match

Polygon match

  • Parameters to adjust

    • Translation, rotation - default

    • Translation, scale

    • Translation, rotation, scale, skew

      • Note: good image quality and an increased Repeat Count is needed to get a good fit

      • Note: the shape of the polygon must contain information to be able to calculate all degrees of freedom

    • Translation, rotation, perspective

      • Note: good image quality and an increased Repeat Count is needed to get a good fit

      • Note: the shape of the polygon must contain information to be able to calculate all degrees of freedom

    • Translation, rotation, scale

      • Note: this is done by iterating translation/rotation and translation/scale. The first iteration is always run with translation/rotation; if final fit is selected, it is always run using translation/scale.

  • Max repeat count - the number of iteration to fitting the polygons

    • 2 is default but higher values will normally increase the accuracy

    • Lower values will save image processing time

  • Stop if result detteriorates - if the match results get worse, the search is stopped. The quality measure of the match can be the match percent, the RMS value or a combination of the two.

    • Hysteresis (%) - allow a small dip in quality before stopping the match

    • RMS factor - weight factor of RMS vs. match count if the combination is selected

  • Abort if fit % is less than - stops matching process if less than % edge points is located - used to save time

  • Keep best points - the percentage of edge points used in iteration

    • 95 percentage is default

    • A lower value will normally be more robust

  • Perform final fit with distance constraints - default on - added to be able to investigate polygon matching in detail

  • Final fit max distance - can be given in pixels or reference coordinates

Individual polygons

  • Min per polygon match % - when set, every polygon must have at least this match. Normally this default is left off, and each polygon gets an individual value (see the Polygons tab).

Child reference base

This sets the origin for the outgoing reference from the tool. The reference is adjusted by the polygon fit results.

  • Active - activate child reference base
  • Polygon center - use the centerof gravity of the selected model polygon
  • Explicit center - set values
    • Origin.X - X value
    • Origin.Y - Y value
  • Rotation - the base reference angle

Note : Child reference base is used to fix the model to the object when needed


Setup.Search

On this page you can create a set of polygon sets from the original - scaled, rotated and moved. During processing, each set is scanned, and the best fit is taken used as the final result.

Enable search - you can disable the whole search process by unchecking this.

Scale

Set a range of scales to test, making your polygons smaller or larger. You can optionally scale the polygons separately in the X and Y directions.

  • Separate scale factors, X and Y - check to enable separate scaling in the two directions

    • Enable (-/X/Y) - enable scaling in the given direction

    • Minimum scale (-/X/Y) - step from this value

    • Maximum scale (-/X/Y) - step to this value (included)

    • Scale step (-/X/Y) - scale step size

    • Rotation

      Set a range of angles to test, rotating your polygons

      • Enable - enable/disable rotation

      • Minimum angle - step from this value

      • Maximum angle - step to this value (included)

      • Angle step - angle step size

      Positions

      Set a range of positions to test, moving your polygons across the image to find a match

      • Enable - enable/disable positions

      • You can ctrl-click several positions in the image and press Paste

      • Regular grid - helps create a regular grid of positions

      Rotation /scale center

      • To rotate or scale a polygon, a center is needed. You most likely want to do this automatically by using the center of gravity (default).

      Search result strings

    • Gives insight in the search process by returning Python dictionaries with search results


     

    Setup.Advanced

    Result acceptance ( constraints )

    • Min match percentage - any of these constraints may make a match invalid

    • Max RMS value

    • Max angle (abs)

    • Max distance

    • Max offsetX (abs)

    • Max offsetY (abs)

    • Hide polygon match items if not accepted - only show polygons if a match is found

    The result acceptance is reflected in the OK result - can be use to easily validate the found polygon.

    Trace line samples dialog - a helper window to set trace line filter parameters and thresholds

    • Middle - show the middle traceline
    • Middle+edges - shows the first, middle and last traceline
    • Selection - show the selected tracelines
    • Line indices - traceline selection
      • example: 2,3,12-15
      • example: 1 3 5 7
    • Show trace line popup - activates a modeless traceline window
  •         
             Example tracelines - Middle+edges is selected

    Include in description

    Include in the onscreen description of valid/invalid match

    • Percent
    • Offset
    • Angle
    • Scale

    String results

    Create Python tuples describing the fitted model:

    • Fitted points - the edge points
    • Fitted model - the changed model
    • Simplify - attempt to simplify the string.
      • Tol (pix) - allow up to this deviation in the simplified polygon

     


    Visualisation

    MatchCenter

    The match center

    MatchAngle The match angle

    CenterAxes

    The match reference axes

    Shape Normalised shape measure [0..1> - 0 is best match

    Description

    Description of accepted polygon (see Advanced2 page)

    Description (invalid)

    Description of non-accepted polygon (see Advanced2 page)

    EdgePoints

    Edge points, final iteration

    EdgePointsOrig

    Edge points, first iteration

    FittedPoints

    Fitted points final iteration

    FittedPointsOrig

    Fitted points first iteration

    MatchedPolygon The best fitted polygon

    MissingPoints

    Tracelines without edgepoints, final iteration

    MissingPointsOrig

    Tracelines without edgepoints, first iteration

    NonAcceptedPolygon The original model is visualised when no match
    OriginalPolygon The original model

    OutlierPoints

    Points too far from polygon, final iteration

    OutlierPointsOrig

    Points too far from polygon, first iteration

    SearchEdgePoints Edge points from the search step
    SearchPolygon All polygons from the search step
    SearchTraceLines Trace lines from the search step
    TraceLines Tracelines, final iteration
    TraceLinesOrig Tracelines, first iteration


    Results
     

    Iterations

    Number of performed iterations (less than specified if no match)

    Fit percent

    Percent of tracelines that has a point that is accepted

    RMS RMS value of the fitted polygons
    OK 1 if fit OK, 0 otherwise

    Offset X

    Movement of fitted polygon, x

    Offset Y

    Movement of fitted polygon, y

    Distance Total movement of fitted polygon

    Angle

    Rotation of fitted polygon

    Scale X

    Scaling of fitted polygon, x

    Scale Y

    Scaling of fitted polygon, y

    Skew

    Axis skew

    Saerch scales Python dictionary: all scales used
    Search rotations Python dictionary: all angles used
    Search positions Python dictionary: all positions used
    Search results Python dictionary: match result for all search combinations
    Best scale.x Best scale used, x
    Best scale.y Best scale used, y
    Best rotation Best angle used
    Best position.x Best position used, x
    Best position.y Best position used, y
    Origin.x Position of base, x
    Origin.y Position of base, y
    Fitted points The final fitted edge points
    Fitted model The original model, moved to best position

     


    ExecuteCmd support
    (see also executeCmd)

    Command

    Parameters

    Return values

    Comments

    Set Object=ROI;Value=<polygon> ok,None Sets the first ROI polygon. See Copy/paste ROIs for details. (*)
    Set Object=ROI;Number=<number>;
    Value=<polygon>
    ok,None Sets the numbered ROI polygon. See Copy/paste ROIs for details. (*)
    Add Object=ROI;Value=<polygon> ok,None Adds ROI polygon to the end of the list. See Copy/paste ROIs for details.
    Get Object=ROI;Number=<number> ok,<polygon> Gets numbered polygon, as Scorpion polygon (StrArr format).
    Get Object=Tuple;Number=<number> ok,<tuple> Gets numbered polygon, as Python tuple
    Clear Object=ROI;Number=<number> ok,None Clears numbered polygon (makes empty)
    DeleteAll - ok,None Deletes all polygons

    (*) Note: Polygon properties are not supported by these methods, although existing properties will be kept when the SET command is used.


    Example 1: Copy a polygon from the clipboard

    tool =  GetTool('PM')
    tool.executeCmd('Set','Object=ROI;Number=1;source=clipboard')


    Example 2: Copy a polygon to the clipboard

    tool =  GetTool('PM')
    tool.executeCmd('Get','Object=ROI;Number=1;destination=clipboard')

    Keyboard shortcuts - More information

    Shortcut

    Command

    Comments

    Ctrl-Z Set ROI Sets the selected polygon to points marked in the image. If only a single point is marked, the polygon is moved, centered around the point.
    If the tool dialog is not open, the first polygon is set.
    Ctrl-1 - Ctrl-0 Set polygon 0-10 Sets the numbered polygon to points marked in the image. If only a single point is marked, the polygon is moved, centered around the point. If a new polygon is defined this way, any missing polygons in between are set as empty.
    Ctrl-Shift-1 - Ctrl-Shift-0 Clear polygon 0-10 Clears the numbered polygon (sets empty).

     


Scorpion Vision Version XII : Build 646 - Date: 20170225
Scorpion Vision Software® is a registered trademark of Tordivel AS.
Copyright © 2000 - 2017 Tordivel AS.