Pattern Finding and Retrieving Results¶
This code snippet shows how to perform pattern finding operations and retrieve the results.
C++¶
#include <eVision/EasyFind/EPatternFinder.h>
using namespace eVision;
// Image constructor
EImageBW8 srcImage;
// EPatternFinder constructor
EPatternFinder finder;
// EFoundPattern constructor
std::vector<EFoundPattern> foundPattern;
// ...
// Load a model file
finder.Load("myModel.fnd");
// Perform the pattern finding
foundPattern = finder.Find(&srcImage);
// Retrieve the number of instances
int numInstances = (int)foundPattern.size();
// Retrieve the score and the
// position of the first instance
float score = foundPattern[0].GetScore();
float centerX = foundPattern[0].GetCenter().GetX();
float centerY = foundPattern[0].GetCenter().GetY();
C#¶
using eVision;
// Image constructor
EImageBW8 srcImage = new EImageBW8();
// EPatternFinder constructor
EPatternFinder finder = new EPatternFinder();
// EFoundPattern constructor
EFoundPattern[] foundPattern = null;
// ...
// Load a model file
finder.Load("myModel.fnd");
// Perform the pattern finding
foundPattern = finder.Find(srcImage);
// Retrieve the number of instances
int numInstances = foundPattern.Length;
// Retrieve the score and the
// position of the first instance
float score = foundPattern[0].Score;
float centerX = foundPattern[0].Center.X;
float centerY = foundPattern[0].Center.Y;
Python¶
import eVision
# Image constructor
src_image = eVision.EImageBW8()
# EPatternFinder constructor
finder = eVision.EPatternFinder()
# ...
# Load a model file
finder.Load("myModel.fnd")
# Perform the pattern finding
found_pattern = finder.Find(src_image)
# Retrieve the number of instances
num_instances = len(found_pattern)
# Retrieve the score and the
# position of the first instance
score = found_pattern[0].Score
centerX = found_pattern[0].Center.X
centerY = found_pattern[0].Center.Y