EasyGauge - Measuring down to Sub-Pixel

../../../_images/rectanglegauge.jpg

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

  1. Create a gauge object that corresponds to the required geometrical shape.

  2. Set the nominal shape on the object.

  3. Set the tolerances of the shape.

    • The tolerances express how far away from the nominal shape to search for edge-crossing in the image.

  4. Optionally change the various measurement and fitting parameters.

  5. 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.

#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

Principles of EasyGauge.

Principles of EasyGauge
Gauge Types

The list of gauges and their parameters.

Gauge Types
Parameters

Measurement and fitting parameters.

Measurement and Fitting Parameters
Advanced Usage

Analyzing the results and advanced parameter tuning.

Advanced Usage
Display

Display and graphical manipulations.

Display and Graphical Manipulation
Differences with Legacy API

Differences between the current and legacy API of EasyGauge.

Differences with the Legacy API
Legacy API

Legacy API

Legacy EasyGauge