Setting Search Parameters¶
This code snippet shows how to tune pattern matching search parameters and save them into a file.
C++¶
#include <eVision/EasyMatch/EMatcher.h>
using namespace eVision;
// Image constructor
EImageBW8 pattern;
// EMatcher constructor
EMatcher matcher;
// ...
// Learn the pattern
matcher.LearnPattern(&pattern);
// Set the maximum number of occurrences
matcher.SetMaxPositions(5);
// Set the rotation tolerances
matcher.SetMinAngle(-20.f);
matcher.SetMaxScale(20.f);
// Enable sub-pixel accuracy
matcher.SetInterpolate(true);
// Set the minimum score
matcher.SetMinScore(0.70f);
// Save the matching context into a model file
matcher.Save("myModel.mch");
C#¶
using eVision;
// Image constructor
EImageBW8 pattern = new EImageBW8();
// EMatcher constructor
EMatcher matcher = new EMatcher();
// ...
// Learn the pattern
matcher.LearnPattern(pattern);
// Set the maximum number of occurrences
matcher.MaxPositions = 5;
// Set the rotation tolerances
matcher.MinAngle = -20.0f;
matcher.MaxAngle = 20.0f;
// Enable sub-pixel accuracy
matcher.Interpolate = true;
// Set the minimum score
matcher.MinScore = 0.70f;
// Save the matching context into a model file
matcher.Save("myModel.mch");
Python¶
import eVision
# Image constructor
pattern = eVision.EImageBW8()
# EMatcher constructor
matcher = eVision.EMatcher()
# ...
# Learn the pattern
matcher.LearnPattern(pattern)
# Set the maximum number of occurrences
matcher.MaxPositions = 5
# Set the rotation tolerances
matcher.MinAngle = -20.
matcher.MaxAngle = 20.
# Enable sub-pixel accuracy
matcher.Interpolate = True
# Set the minimum score
matcher.MinScore = 0.7
# Save the matching context into a model file
matcher.Save("myModel.mch")