Learning Using a DXF File

This code snippet shows how to perform pattern learning and finding operations using a DXF file.

C++

#include <eVision/EasyFind/EPatternFinder.h>
using namespace eVision;

// 1. Create an EPatternFinder instance for the model.
EPatternFinder finder;

// 2. Create your vector model.
EVectorModel myModel;

// 3. Load the model from the dxf file.
myModel.LoadDXF("myModel.dxf");

// 4. The scale and polarity attributes are not part of the dxf file. If necessary, add them to the EVectorModel.

// 5. Learn the model.
finder.Learn(myModel);

// 6. If you want to reuse it later, save the new model (.fnd file).
// finder.Save("myModel.fnd");

// 7. Find the pattern in an image
EImageBW8 srcImage;
std::vector<EFoundPattern> foundPattern;
foundPattern = finder.Find(&srcImage);

C#

using eVision;
// 1. Create an EPatternFinder instance for the model.
EPatternFinder finder = new EPatternFinder();

// 2. Create your vector model.
EVectorModel myModel = new EVectorModel();

// 3. Load the model from the dxf file.
myModel.LoadDXF("myModel.dxf");

// 4. The scale and polarity attributes are not part of the dxf file. If necessary, add them to the EVectorModel.

// 5. Learn the model.
finder.Learn(myModel);

// 6. If you want to reuse it later, save the new model (.fnd file).
// finder.Save("myModel.fnd");

// 7. Find the pattern in an image
EImageBW8 srcImage = new EImageBW8();
EFoundPattern[] foundPattern = null;
foundPattern = finder.Find(srcImage);

Python

import eVision

# 1. Create an EPatternFinder instance for the model.
finder = eVision.EPatternFinder()

# 2. Create your vector model.
my_model = eVision.EVectorModel()

# 3. Load the model from the dxf file.
my_model.LoadDXF("myModel.dxf")

# 4. The scale and polarity attributes are not part of the dxf file. If necessary, add them to the EVectorModel.

# 5. Learn the model.
finder.Learn(my_model)

# 6. If you want to reuse it later, save the new model (.fnd file).
# finder.Save("myModel.fnd")

# 7. Find the pattern in an image
src_image = eVision.EImageBW8()
found_pattern = finder.Find(src_image)