EChecker with Multiple Images Code Snippet¶
This code snippet shows how to train an EChecker with multiple images and then inspect an image.
C++¶
#include <eVision/EasyObject/EChecker/EChecker.h>
using namespace eVision;
// Array of reference images used for training
std::vector<EImageBW8> referenceImages;
EImageBW8 imageToCheck;
EChecker checker;
ECodedImage2 codedImage;
EObjectSelection objectSelection;
checker.SetNormalizationMode(ENormalizationMode_NoNormalization);
checker.Train(referenceImages);
checker.Inspect(imageToCheck, codedImage);
objectSelection.AddObjects(codedImage);
objectSelection.SetAttachedImage(&imageToCheck);
// Optional pass to remove small detections that might be noise
objectSelection.RemoveUsingUnsignedIntegerFeature(EFeature_Area, 30, ESingleThresholdMode_Less);
C#¶
using eVision;
// Example with 7 images
// Can be another number
// Must be loaded before submitted to Train()
EImageBW8[] referenceImages = new EImageBW8[7] { new EImageBW8(), new EImageBW8(), new EImageBW8(), new EImageBW8(), new EImageBW8(), new EImageBW8(), new EImageBW8() };
EImageBW8 imageToCheck = new EImageBW8();
EChecker checker = new EChecker();
ECodedImage2 codedImage = new ECodedImage2();
EObjectSelection objectSelection = new EObjectSelection();
checker.NormalizationMode = ENormalizationMode.NoNormalization;
checker.Train(referenceImages);
checker.Inspect(imageToCheck, codedImage);
objectSelection.AddObjects(codedImage);
objectSelection.AttachedImage = imageToCheck;
// Optional pass to remove small detections that might be noise
objectSelection.RemoveUsingUnsignedIntegerFeature(EFeature.Area, 30, ESingleThresholdMode.Less);
Python¶
import eVision
# Array of reference images used for training
referenceImages = []
imageToChecker = eVision.EImageBW8()
checker = eVision.EChecker()
codedImage = eVision.ECodedImage2()
objectSelection = eVision.EObjectSelection()
checker.NormalizationMode = eVision.ENormalizationMode.NoNormalization
checker.Train(referenceImages)
checker.Inspect(imageToChecker, codedImage)
objectSelection.AddObjects(codedImage)
objectSelection.AttachedImage = imageToChecker
# Optional pass to remove small detections that might be noise
objectSelection.RemoveUsingUnsignedIntegerFeature(eVision.EFeature.Area, 30, eVision.ESingleThresholdMode.Less)