EasyGauge - Measuring down to Sub-Pixel¶
Example of a rectangle gauge.¶
Purpose¶
The EasyGauge library can measure and fit various geometrical shapes (rectangles, circles, polygons, wedges, lines and points) to edges in the images.
Find and measure a geometrical shape¶
Create a gauge object that corresponds to the required geometrical shape.
Set the nominal shape on the object.
The nominal shape is an approximate definition of the shape to be measured.
Use
EBaseGauge::SetNominal.NET Python or the overloads in each gauge class (ERectangleGauge::SetRectangle.NET Python for example).
Set the tolerances of the shape.
The tolerances express how far away from the nominal shape to search for edge-crossing in the image.
Optionally change the various measurement and fitting parameters.
Call
EBaseGauge::Measure.NET Python to perform the measurement and get the measured shape.It throws an exception if the shape cannot be found.
The nominal shape, tolerance, various measurement parameters and the measured shape can be expressed with respect to a reference frame (EFrame .NET Python) given as a parameter to EBaseGauge::Measure .NET Python.
To perform calibrated or metric gauging, use a calibrated reference frame.
Note
The theoretical best-case accuracy is 1/64th pixel for all EasyGauge operators. In practice, you can assume an accuracy of 1/10th pixel.
See also
See Geometrical Shapes, Frame and Alignment, and Calibration.
#include <eVision/EasyGauge/ERectangleGauge.h>
using namespace eVision;
// Image constructor
EImageBW8 srcImage;
// ERectangleGauge constructor
ERectangleGauge rectangleGauge;
// Adjust the transition parameters
rectangleGauge.SetTransitionType(ETransitionType_Bw);
rectangleGauge.SetTransitionChoice(ETransitionChoice_LargestAmplitude);
// Set the rectangle fitting gauge position,
// size (50x30 units) and orientation (15)
EPoint center(256.f, 256.f);
ERectangle rectangle(center, 50.f, 30.f, Easy::FromDegrees(15.f));
rectangleGauge.SetRectangle(rectangle);
try
{
// Measure
ERectangle measured = rectangleGauge.Measure(srcImage);
// Get the size and the rotation angle of the fitted rectangle
float sizeX = measured.GetSizeX();
float sizeY = measured.GetSizeY();
float angle = measured.GetAngle();
}
catch (const EException& e)
{
// The rectangle was not found.
}
// Save the point gauge measurement context
rectangleGauge.Save("myRectangleGauge.gge");
using eVision;
// Image constructor
EImageBW8 srcImage = new EImageBW8();
// ERectangleGauge constructor
ERectangleGauge rectangleGauge = new ERectangleGauge();
// Adjust the transition parameters
rectangleGauge.TransitionType = ETransitionType.Bw;
rectangleGauge.TransitionChoice = ETransitionChoice.LargestAmplitude;
// Set the rectangle fitting gauge position,
// size (50x30 units) and orientation (15°)
rectangleGauge.Rectangle = new ERectangle(new EPoint(256.0f, 256.0f), 50.0f, 30.0f, Easy.FromDegrees(15.0f));
try
{
// Measure
ERectangle measured = rectangleGauge.Measure(srcImage);
// Get the size and the rotation angle of the fitted rectangle
float sizeX = measured.SizeX;
float sizeY = measured.SizeY;
float angle = measured.Angle;
}
catch (EException e)
{
// The rectangle was not found
}
// Save the rectangle gauge measurement context
rectangleGauge.Save("myRectangleGauge.gge");
import eVision
# Image constructor
src_image = eVision.EImageBW8()
# ERectangleGauge constructor
rectangle_gauge = eVision.ERectangleGauge()
# Adjust the transition parameters
rectangle_gauge.TransitionType = eVision.ETransitionType.Bw
rectangle_gauge.TransitionChoice = eVision.ETransitionChoice.LargestAmplitude
# Set the rectangle fitting gauge position,
# size (50x30 units) and orientation (15°)
rectangle_gauge.Rectangle = eVision.ERectangle(eVision.EPoint(256.0, 256.0), 50.0, 30.0, eVision.Easy.FromDegrees(15.0))
try:
# Measure
measured = rectangle_gauge.Measure(src_image)
# Get the size and the rotation angle of the fitted rectangle
sizeX = measured.SizeX
sizeY = measured.SizeY
angle = measured.Angle
except eVision.EException:
# The rectangle was not found.
pass
# Save the rectangle gauge measurement context
rectangle_gauge.Save("myRectangleGauge.gge")
Contents¶
Principles of EasyGauge.
The list of gauges and their parameters.
Measurement and fitting parameters.
Analyzing the results and advanced parameter tuning.
Display and graphical manipulations.
Differences between the current and legacy API of EasyGauge.
Legacy API
Quick Links¶
List of all Classes, Structs and Enumerations of the EasyGauge library.
Code snippets for the EasyGauge library.
See also
Some eVision Studio samples illustrate several aspects of the EasyGauge library:
Batch processing find and gaugeCalibrated circle gaugeCalibrated rectangle gaugeDetecting solder pads with gaugesMeasuring angle with line gaugePolygon gauge edge modeBearing inspection3D calibration and measure3D component check