Calibration by Guesswork Code Snippet (Legacy)

This code snippet shows how to perform a calibration by guesswork using the legacy EasyGauge API.

C++

#include <eVision/EasyGauge/Legacy/EWorldShape.h>
using namespace eVision;
using namespace eVision::Legacy;
// Image constructor
EImageBW8 srcImage;
// EWorldShape constructor
EWorldShape worldShape;
// ...
// Compute the calibration coefficients
// Field of view: 32x24 mm
worldShape.SetSensor(srcImage.GetWidth(), srcImage.GetHeight(), 32.f, 24.f);
// Retrieve the spatial resolution
float resolutionX = worldShape.GetXResolution();
float resolutionY = worldShape.GetYResolution();

C#

using eVision;
using Legacy = eVision.Legacy;
// Image constructor
EImageBW8 srcImage = new EImageBW8();
// EWorldShape constructor
Legacy.EWorldShape worldShape = new Legacy.EWorldShape();
// ...
// Compute the calibration coefficients
// Field of view: 32x24 mm
worldShape.SetSensor(srcImage.Width, srcImage.Height, 32.0f, 24.0f);
// Retrieve the spatial resolution
float resolutionX = worldShape.XResolution;
float resolutionY = worldShape.YResolution;

Python

import eVision
import eVision.Legacy as Legacy
# Image constructor
src_image = eVision.EImageBW8()
# EWorldShape constructor
world_shape = Legacy.EWorldShape()
# ...
# Compute the calibration coefficients
# Field of view: 32x24 mm
world_shape.SetSensor(src_image.Width, src_image.Height, 32.0, 24.0)
# Retrieve the spatial resolution
resolutionX = world_shape.XResolution
resolutionY = world_shape.YResolution