Differences with the Legacy API¶
This section talks about the differences between the new API of EasyGauge and the legacy API and how to port an application that uses the legacy API to the new API.
There is no internal hierarchy of gauges.
To link a gauge to the results of another gauge, convert the results of the parent gauge to a frame and use that frame in the children gauges.
Calibration is no longer part of the gauge object, refer to Calibration instead.
The center of the top left pixel of the image has the coordinates (0.5, 0.5) compared to (0, 0) in the legacy API.
Measurenow returns the measured shape and throws an exception if not found.The classes
ExxxShapehave been removed.Instead, use the geometrical shapes
Exxx.
The EasyGauge classes inherits from
EBaseGauge.NET Python
Differences for Drawing and Graphical Manipulation¶
The quick draw and optional draw properties have been removed.
The property “dragging mode” property has been removed. All the shapes and gauges are dragged in a way that is similar to the
ERegion.NET Python dragging.Zoom and pan are now arguments of
Draw,HitTest… instead of properties of the class.The properties “behavior filter”, “selected”, “selectable”, “active” and “visible” have been removed.
The tolerances are drawn by calling the method
Drawwith the modeEDrawingMode_Tolerances.NET Python.Before, they were drawn along with the mode
EDrawingMode_Nominal.NET Python.
The transition types are drawn by calling the method
Drawwith the modeEDrawingMode_TransitionType.NET Python.Before, they were drawn with the mode
EDrawingMode_Nominal.NET Python if the optional draw was enabled.
The
HitHandleproperty has been removed.Now,
HitTestreturns an edition mode corresponding to the handle under the mouse.
The draggable and rotatable properties have been removed.
Use the property
EBaseGauge::SetEditionMode.NET Python to specify the enabled modes of edition.Use
EBaseGauge::GetAvailableEditionModes.NET Python to get the list of modes supported by the gauge.
Keep Using the Legacy Gauge API¶
To keep using the legacy gauge API, prefix all the EasyGauge types that you use:
In C++: with
Legacy::In Python and .NET: with
Legacy.
Porting your Application Using the Legacy Application to the New API¶
You must:
If you use calibration, recalibrate your setup with
ECameraCalibration.NET Python instead ofEWorldShape.NET Python.For each gauge in your hierarchy, create a corresponding new gauge and set all its parameters.
Perform the measurement of the hierarchy by calling
Measureon the root gauges to convert their result to a frame. Then callMeasureon their children gauges with this frame.
For example, the legacy gauge API code
#include <eVision/EasyGauge/Legacy/ERectangleGauge.h>
#include <eVision/EasyGauge/Legacy/ECircleGauge.h>
#include <eVision/EasyGauge/Legacy/EWorldShape.h>
using namespace eVision;
// Image constructor
EImageBW8 img;
// EWorldShape constructor
Legacy::EWorldShape worldShape;
// Gauges constructor
Legacy::ERectangleGauge rectangleGauge;
Legacy::ECircleGauge circleGauge1, circleGauge2;
// Attach the rectangle gauge to the EWorldShape
rectangleGauge.Attach(&worldShape);
// Attach the circle gauges to the rectangle gauge
circleGauge1.Attach(&rectangleGauge);
circleGauge2.Attach(&rectangleGauge);
// Trigger the measurement of all the
// gauges attached to the EWorldShape
worldShape.Process(&img, true);
// Retrieve the measurement result of the rectangle gauge
float sizeX = rectangleGauge.GetMeasuredRectangle().GetSizeX();
// Retrieve the measurement result of the circle gauges
Legacy::ECircle circ1 = circleGauge1.GetMeasuredCircle();
Legacy::ECircle circ2 = circleGauge2.GetMeasuredCircle();
using eVision;
using Legacy = eVision.Legacy;
// Image constructor
EImageBW8 img = new EImageBW8();
// EWorldShape constructor
Legacy.EWorldShape worldShape = new Legacy.EWorldShape();
// Gauges constructor
Legacy.ERectangleGauge rectangleGauge = new Legacy.ERectangleGauge();
Legacy.ECircleGauge circleGauge1 = new Legacy.ECircleGauge();
Legacy.ECircleGauge circleGauge2 = new Legacy.ECircleGauge();
// Attach the rectangle gauge to the EWorldShape
rectangleGauge.Attach(worldShape);
// Attach the circle gauges to the rectangle gauge
circleGauge1.Attach(rectangleGauge);
circleGauge2.Attach(rectangleGauge);
// Trigger the measurement of all the
// gauges attached to the EWorldShape
worldShape.Process(img, true);
// Retrieve the measurement result of the rectangle gauge
float sizeX = rectangleGauge.MeasuredRectangle.SizeX;
// Retrieve the measurement result of the circle gauges
Legacy.ECircle circ1 = circleGauge1.MeasuredCircle;
Legacy.ECircle circ2 = circleGauge2.MeasuredCircle;
import eVision
import eVision.Legacy
# Image constructor
img = eVision.EImageBW8()
# EWorldShape constructor
worldShape = eVision.Legacy.EWorldShape()
# Gauges constructor
rectangleGauge = eVision.Legacy.ERectangleGauge()
circleGauge1 = eVision.Legacy.ECircleGauge()
circleGauge2 = eVision.Legacy.ECircleGauge()
# Attach the rectangle gauge to the EWorldShape
rectangleGauge.Attach(worldShape)
# Attach the circle gauges to the rectangle gauge
circleGauge1.Attach(rectangleGauge)
circleGauge2.Attach(rectangleGauge)
# Trigger the measurement of all the
# gauges attached to the EWorldShape
worldShape.Process(img, True)
# Retrieve the measurement result of the rectangle gauge
sizeX = rectangleGauge.MeasuredRectangle.SizeX
# Retrieve the measurement result of the circle gauges
circ1 = circleGauge1.MeasuredCircle
circ1 = circleGauge2.MeasuredCircle
is converted to:
#include <eVision/EasyGauge/ERectangleGauge.h>
#include <eVision/EasyGauge/ECircleGauge.h>
#include <eVision/Easy/ECameraCalibration.h>
using namespace eVision;
// Image constructor
EImageBW8 img;
// Optional if no calibration is needed
ECameraCalibration calibration;
// Gauges constructor
ERectangleGauge rectangleGauge;
ECircleGauge circleGauge1, circleGauge2;
try
{
ERectangle rect = rectangleGauge.Measure(img, calibration.ToFrame());
ECircle circ1 = circleGauge1.Measure(img, rect.ToFrame(true, EFrameScaling_NormalizeXY));
ECircle circ2 = circleGauge2.Measure(img, rect.ToFrame(true, EFrameScaling_NormalizeXY));
}
catch (const EException& e)
{
// One of the measurement failed.
}
using eVision;
using Legacy = eVision.Legacy;
// Image constructor
EImageBW8 img = new EImageBW8();
// Optional if no calibration is needed
ECameraCalibration calibration = new ECameraCalibration();
// Gauges constructor
ERectangleGauge rectangleGauge = new ERectangleGauge();
ECircleGauge circleGauge1 = new ECircleGauge();
ECircleGauge circleGauge2 = new ECircleGauge();
try
{
ERectangle rect = rectangleGauge.Measure(img, calibration.ToFrame());
ECircle circ1 = circleGauge1.Measure(img, rect.ToFrame(true, EFrameScaling.NormalizeXY));
ECircle circ2 = circleGauge2.Measure(img, rect.ToFrame(true, EFrameScaling.NormalizeXY));
}
catch (EException e)
{
// One of the measurement failed.
}
import eVision
# Image constructor
img = eVision.EImageBW8()
# Optional if no calibration is needed
calibration = eVision.ECameraCalibration()
# Gauges constructor
rectangleGauge = eVision.ERectangleGauge()
circleGauge1 = eVision.ECircleGauge()
circleGauge2 = eVision.ECircleGauge()
try:
rect = rectangleGauge.Measure(img, calibration.ToFrame())
circ1 = circleGauge1.Measure(img, rect.ToFrame(True, eVision.EFrameScaling.NormalizeXY))
circ2 = circleGauge2.Measure(img, rect.ToFrame(True, eVision.EFrameScaling.NormalizeXY))
except eVision.EException:
# One of the measurement failed.
pass