Up | ImageResampler - 70 | Blob4 - 87 | TemplateFinder3 - 63 | Blob3 - 60 | MultiBlob - 47 | TemplateFinder2 - 44 | TextureMatcher - 53 | PolyLineGapFinder - 49 | ColorSegmentor - 57 | PolygonMatch - 62 | ColorAnalyzer - 80 | PolyLineEdgeFaults2 - 85 | PolarUnwrap - 113 | SurfaceAnalyzer - 91 | ImageMixer - 147 | AreaFilter - 158

Working with templates | Release Notes
 

  

 
TemplateFinder2 - 44

Template matching is a technique in finding parts of an image which match a template image.

The versatility of TemplateFinder2 makes it suitable for a large number of applications:

  • Robot Vision - pick and place
  • 3D Stereo Vision
  • Object Counting
  • Object Location
  • Identification System

The Scorpion template matchers uses a standard cross-correlation algorithm to match the template with the image.

TemplateFinder2 are based on these features :

  • Image resampling and decimation
  • Multiple Templates
  • Template Masking
  • Template Rotation
  • Template Scaling
  • Template Match Sorting
  • Template Constraints
    • Number of matches
    • Distance between matches
  • Template Visualisation

The TemplateFinder tool is a less sophisticated patterm matcher and in some task faster and more suitable.


Setup

Reference - Reference system selection

Search Area - The search area is a rectangle. The ROI specifies the area to search for the template.

The ROI can be managed by the buttons

  • Paste - paste the ROI from the image to the scorpion clipboard
  • Copy - copy the ROI to the image from the scorpion clipboard

Point & Click Clipboard Support

The rectangular ROI is defined by four points.


 One point will change the center point.

More on Image Operations.

Resampled image size - to improve the speed of the pattern matcher the ROI can be decimated

  • Image Size ( percent of dX and dY) - sets the size as percent of the search area - the actual image size is shown when performing resampling - more information Resampling tab.

Note: Image decimation lead to lower score values - decimation of 2 and 3 will normally speed up the template matcher - higher    value can degrade detection capabilities

Match threshold and algorithm

  • Threshold - default is 100 - can be lowered to increase the pattern matcher sensitivity

  • Raw% - default 80% - defines the threshold when searching with decimated templates

    • a value of 80% gives a threshold search value of 80 when accept threshold is a 100 and 160 when the threshold is 200. Lower values will increase search time and sensitivity of tf2.

     

  • Pre-3.0 masking - default off - will always be off on old profiles to keep backward compatibility

Note: Pre-3.0 masking is only present to keep backward compatibility. Old profiles will normally perform better with this option off, but this has to be verified. A profile will work better after reducing the Match threshold marginally. Not available in new profiles.

  • True masking - when masking templates every masked pixels is counted

    • when off the masks bits are set to the mean value of the template - faster - this works ok on smaller mask areas

Template/Mask

-  Add and remove templates.

Note: Add will automatically perform a paste if a clipboard region is given or an image exist on the clipboard.

- Read bitmap from file

- Paste bitmap from clipboard to current template or from the template given by four clipboard points in the image. The four points must be inside the current ROI.

Note : The template can also be taken from the resampling tab - this ensures that lens calibration, scaling, rotation or perspective will be correctly taken into account.

Template Image

  - Mask tool selector

- Display template size in pixels and number of masked pixels

The image menu has the following functions:

  • Set Center - sets the origo of the template
  • Reset mask - reset mask
  • Invert mask - Inverts mask
  • Set measure origin
  • Measure - activates image measurement
  • Freeze - no active
  • Show Info - activates cursor measurement
  • Copy shown image without graphics - copy bitmap to clipboard
  • Save shown image without graphics - save bitmap to file
  • Paste - paste image from clipboard
  • Load from file... - activates a file browser to select bitmap

Mouse Mask Operations:

  • Ctrl - Right mouse button down - draws mask
  • Shift - Right mouse button down - erases mask

Active - When checked the template is active

Use subimage - Enables a second pattern matcher on a roi inside the template. Use to for instance separate to objects which is nearly the same, but different in a region of the template

Inv - When checked no match in the sub image is required for this template to generate a match

Angle - defines the angle in degrees of the template - used to handle template with different angle in multiple template systems

Name - User given name of template - useful in classification when having multiple templates

Mouse Sub Image operation:

  • Alt - Mouse Movement to find rectangle or corner
  • Alt - Left click to select corner or rectangle


Advanced

 

Decimation - When active the template is decimated before matching. This speeds up the tool when the template gets big. The decimated size of a template should be at least 10 by 10 pixels.

Automatic settings - Calculate the decimation factor automatically

Note: A decimation factor higher than 7 will increase processing time

Enable template rotation - the pattern matcher rotates and resample the templates to handle rotation

  • Min angle - start rotation angle

  • Max angle - stop rotation angle

  • Angle step - rotation step angle

Enable template scaling - the pattern matcher scales and resample the templates to handle difference in size

  • Min size - start scale in percent

  • Max angle - stop scale in percent

  • Size step - size step

Match description - Specified the description visualisation string

  • Include result order - see Sort Results by

  • Include score

  • Include template number

  • Include template name

  • Include position

  • Include angle

Sort Results by

  • Score - default sort results by score

    • Ascending
       

  • Strictly by X position

  • Strictly by Y position

  • Grid X then Y position

  • Grid Y then X position

    • Ascending X

    • Ascending Y
       

    • Distance Treshold for grid - used to cluster positions into row and columns


Constraints

Max no of matches - Use to limit the number of matches. Useful when only one object is searched or when the you know how many matches there are.

  • Keep best matches for sorting - use the template with best score - when unchecked all accepted templates are used and the sort by results order is used before limiting the number of matches

Minimum distance between matches - This parameters is used to remove matches of the same object. The value is normally defined by the object itself - it is impossible to get two matches closer than this value. The distance is given in reference values

Note : based on template size an implicit value is set by default - this value overrides this value

Intensity - Can be used to remove matches which has non typical intensity values

Standard Deviation - Can be used to remove matches with non-typical standard deviation values

Match center position - useful to remove matches at the boundary of the roi

X position

  • Active Min  - minium x-coordinate of match

  • Active Max - maximum y-coordinate of match

Y position

  • Active Min - minimum x-coordinate of match

  • Active Max - maximum y-coordinate of match


 

Resampling

  • Paste last resampled picture - copies the last inspected image into image window
  • Copy selection to clipboard - copies the selected and resampled image to the clipboard

Note: The selected image are added to the template on the Setup tab.

Note: The template must be produced on the resampling tab - this is due to the fact that template finder2 resamples the image to handle scaling, rotation and perspective.


Visualisation

Best match center

 

Best match rectangle

 

Error

Shows a red X when no match is found

Low match centers

 

Low match rectangles

 

Match centers

 

Match rectangles

 

ROI

 

 

Results

 

 

Number of matches

 

No of matches below accept limit

Minimum score below accept limit

Maximum score below accept limit

Mean score below accept limit

 

No of matches raw

 

Best score

 

Match center [n] x,y

Is used as reference

Angle[n] The angle of the template
Name[n] Template name
Score [n]   Score

Subimage score [n]

 

Template number [n]

 

Intensity [n]

 

Standard deviation [n]

 


ExecuteCmd support
(see also executeCmd)

Command

Parameters

Return values

Comments

Set Object=ROI;Value=<polygon/point> ok,None Sets the tool's ROI. See Copy/paste ROIs for details.
Get Object=ROI ok,<polygon> Current ROI as tool's baseline
Set Object=Template;Name=<name>;
Value=<polygon>
ok,None Creates or replaces named template. The polygon defines the template's position in the image -- must be within the ROI. See also example 1.
Get Object=Templatenames ok,<names> All template names as a Python tuple
Get Object=Templatecount ok,<count> Number of defined templates
Delete Object=template;name=<name> ok,None Deletes named template
DeleteAll - ok,None Deletes all templates

 

Example 1: Add/replace a template by marking an area in main picture

tool = GetTool('TF2')
tool.executeCmd('Set','Object=Template;Name=A;source=clipboard')                                                 #from clipboard
tool.executeCmd('Set','Object=Template;Name=A;value={(190;360)(190;420)(230;420)(230;360)}')   #absolute values


This will extract an area (rectangle) surrounding the marked points in the main image and use the subimage within this area as a new template. If the named template already exists it is replaced, keeping current settings as far as possible; otherwise a new template is added with default settings. The selected area is highlighted in the main image.

The marked area must be within the tool's ROI.

 

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