EChecker with a Single Image¶
This code snippet shows how to train an EChecker with a single image and then inspect an image.
C++¶
#include <eVision/EasyObject/EChecker/EChecker.h>
using namespace eVision;
EImageBW8 referenceImage;
EImageBW8 imageToCheck;
EChecker checker;
ECodedImage2 codedImage;
EObjectSelection objectSelection;
checker.SetNormalizationMode(ENormalizationMode_NoNormalization);
checker.TrainOnSingleImage(referenceImage, 2, 10);
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;
EImageBW8 referenceImage = new EImageBW8();
EImageBW8 imageToCheck = new EImageBW8();
EChecker checker = new EChecker();
ECodedImage2 codedImage = new ECodedImage2();
EObjectSelection objectSelection = new EObjectSelection();
checker.NormalizationMode = ENormalizationMode.NoNormalization;
checker.TrainOnSingleImage(referenceImage, 2, 10);
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
referenceImage = eVision.EImageBW8()
imageToChecker = eVision.EImageBW8()
checker = eVision.EChecker()
codedImage = eVision.ECodedImage2()
objectSelection = eVision.EObjectSelection()
checker.NormalizationMode = eVision.ENormalizationMode.NoNormalization
checker.TrainOnSingleImage(referenceImage, 2, 10)
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)