# EasyFindLearn

| Support            | ![](assets/images/sample_programs/applies_to/cpp.svg) ![](assets/images/sample_programs/applies_to/cs.svg) ![](assets/images/sample_programs/applies_to/qt.svg) ![](assets/images/sample_programs/applies_to/vb.svg) ![](assets/images/sample_programs/applies_to/python.svg)   |
|--------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Required licenses  | **EasyFind**                                                                                                                                                                                                                                                                    |
| Recommended images | Any gray level image from the folder `Sample Images/EasyFind`                                                                                                                                                                                                                   |
| Location           | `Matching and Measurement/EasyFindLearn` and `Console samples/Matching and Measurement` *in Python*                                                                                                                                                                             |

## Purpose

**EasyFind** learns then finds patterns inside images.

This sample program demonstrates how to:

- Load an image.
- Move and size the region of interest to define the pattern.
- Learn the pattern in the region of interest.
- Change the tolerances using the Tolerances menu.
- Find the pattern using the Find menu.

![](assets/images/sample_programs/matching-easyfindlearn.webp)

## Code highlights

1. Define a pattern finder object that will serve as a vehicle for the search parameters and to learn the search pattern.
   ```c++
   EPatternFinder patternfinder;
   ```
2. Modify the parameters of the pattern finder (in this example, an angular tolerance).
   ```c++
   patternfinder.SetAngleTolerance(tol);
   ```
3. Learn a pattern.
   ```c++
   patternfinder.Learn(pattern);
   ```
4. Find the pattern that you previously learned inside the image. Retrieve the results as a vector of `EFoundPatterns`.
   ```c++
   std::vector<EFoundPattern> foundPatterns = patternfinder.Find(image);
   ```
5. Retrieve the attributes of the found pattern (in this example, the angle inside the image).
   ```c++
   foundPatterns[n].GetAngle();
   ```
6. Draw a found pattern in the same reference frame as the search image.

```c
foundPatterns[n].Draw();
```
