Point Location

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.

C++

#include <eVision/EasyGauge/EPointGauge.h>
using namespace eVision;
// Image constructor
EImageBW8 srcImage;
// EPointGauge constructor
EPointGauge pointGauge;
// Adjust the transition parameters
pointGauge.SetTransitionType(ETransitionType_Wb);
pointGauge.SetTransitionChoice(ETransitionChoice_Closest);
// Set the gauge nominal position
pointGauge.SetCenter(EPoint(256.f, 256.f));
// Set the gauge length to 100 units and the angle to 45°
pointGauge.SetNominalLineLength(100.f);
pointGauge.SetNominalLineAngle(Easy::FromDegrees(45.f));
try
{
  // Measure
  EPointSet measured = pointGauge.Measure(srcImage);
  // Get the first measured point coordinates
  float measuredX = measured.GetPoint(0).GetX();
  float measuredY = measured.GetPoint(0).GetY();
  // alternatively, retrieve all points at once
  std::vector<EPoint> points = measured.GetPoints();
}
catch (const EException& e)
{
  // The points were not found.
}
// Save the point gauge measurement context
pointGauge.Save("myPointGauge.gge");

C#

using eVision;
// Image constructor
EImageBW8 srcImage = new EImageBW8();
// EPointGauge constructor
EPointGauge pointGauge = new EPointGauge();
// Adjust the transition parameters
pointGauge.TransitionType = ETransitionType.Wb;
pointGauge.TransitionChoice = ETransitionChoice.Closest;
// Set the gauge nominal position
pointGauge.Center = new EPoint(256.0f, 256.0f);
// Set the gauge length to 10 units and the angle to 45°
pointGauge.NominalLineLength = 100.0f;
pointGauge.NominalLineAngle = Easy.FromDegrees(45.0f);
try
{
  // Measure
  EPointSet measured = pointGauge.Measure(srcImage);
  // Get the first measured point coordinates
  float measuredX = measured.GetPoint(0).X;
  float measuredY = measured.GetPoint(0).Y;
  // alternatively, retrieve all points at once
  EPoint[] points = measured.Points;
}
catch (EException e)
{
  // The points were not found
}
// Save the point gauge measurement context
pointGauge.Save("myPointGauge.gge");

Python

import eVision
# Image constructor
src_image = eVision.EImageBW8()
# EPointGauge constructor
pointGauge = eVision.EPointGauge()
# Adjust the transition parameters
pointGauge.TransitionType = eVision.ETransitionType.Wb
pointGauge.TransitionChoice = eVision.ETransitionChoice.Closest
# Set the gauge nominal position
pointGauge.Center = eVision.EPoint(256.0, 256.0)
# Set the gauge length to 10 units and the angle to 45°
pointGauge.NominalLineLength = 10.0
pointGauge.NominalLineAngle = eVision.Easy.FromDegrees(45.0)
try:
    # Measure
    measured = pointGauge.Measure(src_image)
    # Get the measured point coordinates
    measuredX = measured.GetPoint(0).X
    measuredY = measured.GetPoint(0).Y
    # alternatively, retrieve all points at once
    points = measured.Points;
except eVision.EException:
    # The points were not found.
    pass
# Save the point gauge measurement context
pointGauge.Save("myPointGauge.gge")