# Complex Measurement

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

## C++

```cpp
#include <eVision/EasyGauge/ERectangleGauge.h>
#include <eVision/EasyGauge/ECircleGauge.h>
#include <eVision/Easy/ECameraCalibration.h>
```

```cpp
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()));
```

#### SEE ALSO
[`ECameraCalibration::Load`](../../../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#a542d06e670bd86c5a15e3319dc4cac29) [<sub>.NET</sub>](../../../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#ac8f4cfd112774379d66379a7b05f1039) [<sub>Python</sub>](../../../../../doxygen_python/classeVision_1_1ECameraCalibration.html#a8553215083e06fa6ee189c86fcc3fe01)

## C#

```cs
using eVision;
```

```cs
// 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()));
```

#### SEE ALSO
[`ECameraCalibration.Load`](../../../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#ac8f4cfd112774379d66379a7b05f1039) [<sub>C++</sub>](../../../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#a542d06e670bd86c5a15e3319dc4cac29) [<sub>Python</sub>](../../../../../doxygen_python/classeVision_1_1ECameraCalibration.html#a8553215083e06fa6ee189c86fcc3fe01)

## Python

```py
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()));
```

#### SEE ALSO
[`ECameraCalibration.Load`](../../../../../doxygen_python/classeVision_1_1ECameraCalibration.html#a8553215083e06fa6ee189c86fcc3fe01) [<sub>C++</sub>](../../../../../doxygen_cpp/classeVision_1_1ECameraCalibration.html#a542d06e670bd86c5a15e3319dc4cac29) [<sub>.NET</sub>](../../../../../doxygen_cs/classeVision_1_1ECameraCalibration.html#ac8f4cfd112774379d66379a7b05f1039)
