# Pattern Matching and Retrieving Results

This code snippet shows how to perform pattern matching operations and retrieve the results.

## C++

```cpp
#include <eVision/EasyMatch/EMatcher.h>
```

```cpp
using namespace eVision;
// Image constructor
EImageBW8 srcImage;
// EMatcher constructor
EMatcher matcher;
// ...
// Load a model file
matcher.Load("myModel.mch");
// Perform the matching
std::vector<EFoundPattern> matches = matcher.Match(&srcImage);
// Retrieve the number of occurrences
size_t numOccurrences = matches.size();
// Retrieve the first occurrence
EFoundPattern myOccurrence = matches[0];
// Retrieve its score and position
float score = myOccurrence.GetScore();
float centerX = myOccurrence.GetCenter().GetX();
```

#### SEE ALSO
[`EMatcher::Load`](../../../../doxygen_cpp/classeVision_1_1EMatcher.html#a04f7679f86dce3315196b1c2b07b0072) [<sub>.NET</sub>](../../../../doxygen_cs/classeVision_1_1EMatcher.html#a1077bcbc05d13f727f4e829c8feab6b5) [<sub>Python</sub>](../../../../doxygen_python/classeVision_1_1EMatcher.html#a0dd9801680b75c3019db72fe15fdcadb), [`EMatcher::Match`](../../../../doxygen_cpp/classeVision_1_1EMatcher.html#ac4c97be7341241ee12a14b705fb1d150) [<sub>.NET</sub>](../../../../doxygen_cs/classeVision_1_1EMatcher.html#a753e5bd7a5a267f3119986f1b5c6235b) [<sub>Python</sub>](../../../../doxygen_python/classeVision_1_1EMatcher.html#aa146cdcdcfdb2d330ca60014db506cc1)

## C#

```cs
using eVision;
```

```cs
// Image constructor
EImageBW8 srcImage = new EImageBW8();
// EMatcher constructor
EMatcher matcher = new EMatcher();
// EFoundPattern constructor
EFoundPattern[] matches = null;
// ...
// Load a model file
matcher.Load("myModel.mch");
// Perform the matching
matches = matcher.Match(srcImage);
// Retrieve the number of occurrences
int numOccurrences = matches.Length;
// Retrieve the first occurrence
EFoundPattern myOccurrence = matches[0];
// Retrieve its score and position
float score = myOccurrence.Score;
float centerX = myOccurrence.Center.X;
float centerY = myOccurrence.Center.Y;
```

#### SEE ALSO
[`EMatcher.Load`](../../../../doxygen_cs/classeVision_1_1EMatcher.html#a1077bcbc05d13f727f4e829c8feab6b5) [<sub>C++</sub>](../../../../doxygen_cpp/classeVision_1_1EMatcher.html#a04f7679f86dce3315196b1c2b07b0072) [<sub>Python</sub>](../../../../doxygen_python/classeVision_1_1EMatcher.html#a0dd9801680b75c3019db72fe15fdcadb), [`EMatcher.Match`](../../../../doxygen_cs/classeVision_1_1EMatcher.html#a753e5bd7a5a267f3119986f1b5c6235b) [<sub>C++</sub>](../../../../doxygen_cpp/classeVision_1_1EMatcher.html#ac4c97be7341241ee12a14b705fb1d150) [<sub>Python</sub>](../../../../doxygen_python/classeVision_1_1EMatcher.html#aa146cdcdcfdb2d330ca60014db506cc1)

## Python

```py
import eVision
# Image constructor
src_image = eVision.EImageBW8()
# EMatcher constructor
matcher = eVision.EMatcher()
# ...
# Load a model file
matcher.Load("myModel.mch")
# Perform the matching
matches = matcher.Match(src_image)
# Retrieve the number of occurrences
numOccurrences = len(matches)
# Retrieve the first occurrence
myOccurrence = matches[0]
# Retrieve its score and position
score = myOccurrence.Score
centerX = myOccurrence.Center.X
centerY = myOccurrence.Center.Y
```

#### SEE ALSO
[`EMatcher.Load`](../../../../doxygen_python/classeVision_1_1EMatcher.html#a0dd9801680b75c3019db72fe15fdcadb) [<sub>C++</sub>](../../../../doxygen_cpp/classeVision_1_1EMatcher.html#a04f7679f86dce3315196b1c2b07b0072) [<sub>.NET</sub>](../../../../doxygen_cs/classeVision_1_1EMatcher.html#a1077bcbc05d13f727f4e829c8feab6b5), [`EMatcher.Match`](../../../../doxygen_python/classeVision_1_1EMatcher.html#aa146cdcdcfdb2d330ca60014db506cc1) [<sub>C++</sub>](../../../../doxygen_cpp/classeVision_1_1EMatcher.html#ac4c97be7341241ee12a14b705fb1d150) [<sub>.NET</sub>](../../../../doxygen_cs/classeVision_1_1EMatcher.html#a753e5bd7a5a267f3119986f1b5c6235b)
