Complex Measurement

This code snippet shows how to use frame of reference to define gauges from the result of other gauges.

C++

#include <eVision/EasyGauge/ERectangleGauge.h>
#include <eVision/EasyGauge/ECircleGauge.h>
#include <eVision/Easy/ECameraCalibration.h>
using namespace eVision;
// Image constructor
EImageBW8 srcImage;
// ECameraCalibration constructor
ECameraCalibration calib;
// Load the calibration
calib.Load("calib.clb");

// Create a rectangle gauge
ERectangleGauge rectangleGauge;
// Define the nominal rectangle. It is defined in the reference frame provided by the calibration.
rectangleGauge.SetRectangle(ERectangle(EPoint(5.f, 5.f), 1.0f, 1.0f));

// Measure the rectangle gauge in the reference frame provided by the calibration
ERectangle measuredRectangle = rectangleGauge.Measure(srcImage, calib.ToFrame());

// Create a circle gauge that will be located in the reference frame of the measured rectangle
ECircleGauge circleGauge;
circleGauge.SetCircle(ECircle(EPoint(0.1f, 0.1f), 0.5f));
ECircle measuredCircle =
  circleGauge.Measure(srcImage, measuredRectangle.ToFrame(true, EFrameScaling_NoScaling, calib.ToFrame()));

C#

using eVision;
// Image constructor
EImageBW8 srcImage = new EImageBW8();
// ECameraCalibration constructor
ECameraCalibration calib = new ECameraCalibration();
// Load the calibration
calib.Load("calib.clb");

// Create a rectangle gauge
ERectangleGauge rectangleGauge = new ERectangleGauge();
// Define the nominal rectangle. It is defined in the reference frame provided by the calibration.
rectangleGauge.Rectangle = new ERectangle(new EPoint(5.0f, 5.0f), 1.0f, 1.0f);

// Measure the rectangle gauge in the reference frame provided by the calibration
ERectangle measuredRectangle = rectangleGauge.Measure(srcImage, calib.ToFrame());

// Create a circle gauge that will be located in the reference frame of the measured rectangle
ECircleGauge circleGauge = new ECircleGauge();
circleGauge.Circle = new ECircle(new EPoint(0.1f, 0.1f), 0.5f);
ECircle measuredCircle =
  circleGauge.Measure(srcImage, measuredRectangle.ToFrame(true, EFrameScaling.NoScaling, calib.ToFrame()));

Python

import eVision
from typing import cast
# Image constructor
src_image = eVision.EImageBW8()
# ECameraCalibration constructor
calib = eVision.ECameraCalibration()

# Load the calibration
calib.Load("calib.clb")

# Create a rectangle gauge
rectangleGauge = eVision.ERectangleGauge()
# Define the nominal rectangle. It is defined in the reference frame provided by the calibration.
rectangleGauge.Rectangle = eVision.ERectangle(eVision.EPoint(5.0, 5.0), 1.0, 1.0)

# Measure the rectangle gauge in the reference frame provided by the calibration
measuredRectangle = rectangleGauge.Measure(src_image, calib.ToFrame())

# Create a circle gauge that will be located in the reference frame of the measured rectangle
circleGauge = eVision.ECircleGauge()
circleGauge.Circle = eVision.ECircle(eVision.EPoint(0.1, 0.1), 0.5)
measuredCircle = circleGauge.Measure(src_image, measuredRectangle.ToFrame(True, eVision.EFrameScaling.NoScaling, calib.ToFrame()));