Coordinates Transform Code Snippet (Legacy)¶
This code snippet shows how to convert coordinates from the Sensor space to the World space and conversely using the legacy EasyGauge API.
C++¶
#include <eVision/EasyGauge/Legacy/EWorldShape.h>
using namespace eVision;
using namespace eVision::Legacy;
// EWorldShape constructor
EWorldShape worldShape;
// EPoint constructor
EPoint sensor;
EPoint world;
// ...
// Perform the calibration
worldShape.Calibrate(ECalibrationMode_Scaled | ECalibrationMode_Skewed);
// Retrieve the world coordinates of a point, knowing its sensor coordinates
world = worldShape.SensorToWorld(sensor);
// Retrieve the sensor coordinates of a point, knowing its world coordinates
sensor = worldShape.WorldToSensor(world);
C#¶
using eVision;
using Legacy = eVision.Legacy;
// EWorldShape constructor
Legacy.EWorldShape worldShape = new Legacy.EWorldShape();
// EPoint constructor
EPoint sensor = new EPoint();
EPoint world = new EPoint();
// ...
// Perform the calibration
worldShape.Calibrate((int)ECalibrationMode.Scaled | (int)ECalibrationMode.Skewed);
// Retrieve the world coordinates of a point, knowing its sensor coordinates
world = worldShape.SensorToWorld(sensor);
// Retrieve the sensor coordinates of a point, knowing its world coordinates
sensor = worldShape.WorldToSensor(world);
Python¶
import eVision
import eVision.Legacy as Legacy
# EWorldShape constructor
world_shape = Legacy.EWorldShape()
# EPoint constructor
sensor = eVision.EPoint()
world = eVision.EPoint()
# ...
# Perform the calibration
world_shape.Calibrate(eVision.ECalibrationMode.Scaled | eVision.ECalibrationMode.Skewed)
# Retrieve the world coordinates of a point, knowing its sensor coordinates
world = world_shape.SensorToWorld(sensor)
# Retrieve the sensor coordinates of a point, knowing its world coordinates
sensor = world_shape.WorldToSensor(world)