Point Location (Legacy)¶
This code snippet shows how to create a point location tool, adjust the transition parameters, set the nominal gauge position, perform the measurement and retrieve the result using the legacy EasyGauge API.
C++¶
#include <eVision/EasyGauge/Legacy/EPointGauge.h>
using namespace eVision;
using namespace eVision::Legacy;
// Image constructor
EImageBW8 srcImage;
// EPointGauge constructor
Legacy::EPointGauge pointGauge;
// Adjust the transition parameters
pointGauge.SetTransitionType(ETransitionType_Wb);
pointGauge.SetTransitionChoice(ETransitionChoice_Closest);
// Set the gauge nominal position
pointGauge.SetCenterXY(256.f, 256.f);
// Set the gauge length to 100 units and the angle to 45°
pointGauge.SetTolerances(100.f, Easy::FromDegrees(45.f));
// Measure
pointGauge.Measure(&srcImage);
// Get the measured point coordinates
float measuredX = pointGauge.GetMeasuredPoint().GetX();
float measuredY = pointGauge.GetMeasuredPoint().GetY();
// alternatively, retrieve all points at once
std::vector<EPoint> points = pointGauge.GetMeasuredPoints();
// Save the point gauge measurement context
pointGauge.Save("myPointGauge.gge");
C#¶
using eVision;
using Legacy = eVision.Legacy;
// Image constructor
EImageBW8 srcImage = new EImageBW8();
// EPointGauge constructor
Legacy.EPointGauge pointGauge = new Legacy.EPointGauge();
// Adjust the transition parameters
pointGauge.TransitionType = ETransitionType.Wb;
pointGauge.TransitionChoice = ETransitionChoice.Closest;
// Set the gauge nominal position
pointGauge.SetCenterXY(256.0f, 256.0f);
// Set the gauge length to 10 units and the angle to 45°
pointGauge.SetTolerances(10.0f, Easy.FromDegrees(45.0f));
// Measure
pointGauge.Measure(srcImage);
// Get the measured point coordinates
float measuredX = pointGauge.GetMeasuredPoint().X;
float measuredY = pointGauge.GetMeasuredPoint().Y;
// alternatively, retrieve all points at once
EPoint[] points = pointGauge.MeasuredPoints;
// Save the point gauge measurement context
pointGauge.Save("myPointGauge.gge");
Python¶
import eVision
import eVision.Legacy as Legacy
# Image constructor
src_image = eVision.EImageBW8()
# EPointGauge constructor
pointGauge = Legacy.EPointGauge()
# Adjust the transition parameters
pointGauge.TransitionType = eVision.ETransitionType.Wb
pointGauge.TransitionChoice = eVision.ETransitionChoice.Closest
# Set the gauge nominal position
pointGauge.SetCenterXY(256.0, 256.0)
# Set the gauge length to 10 units and the angle to 45°
pointGauge.SetTolerances(10.0, eVision.Easy.FromDegrees(45.0))
# Measure
pointGauge.Measure(src_image)
# Get the measured point coordinates
measuredX = pointGauge.GetMeasuredPoint().X
measuredY = pointGauge.GetMeasuredPoint().Y
# alternatively, retrieve all points at once
points = pointGauge.MeasuredPoints
# Save the point gauge measurement context
pointGauge.Save("myPointGauge.gge")