# Wedge Fitting

This code snippet shows how to create a wedge measurement tool, adjust the transition parameters, set the nominal gauge position, perform the measurement and retrieve the result.

## C++

```cpp
#include <eVision/EasyGauge/Legacy/EWedgeGauge.h>
```

```cpp
using namespace eVision;
// Image constructor
EImageBW8 srcImage;
// EWedgeGauge constructor
EWedgeGauge wedgeGauge;
// Adjust the transition parameters
wedgeGauge.SetTransitionType(ETransitionType_Bw);
wedgeGauge.SetTransitionChoice(ETransitionChoice_NthFromBegin);
wedgeGauge.SetTransitionIndex(0);
// Set the wedge fitting gauge position, diameter (50 units),
// breadth (-25 units), starting angle (0) and amplitude (270)
EPoint center(256.f, 256.f);
EWedge wedge(center, 50.f, -25.f, 0.f, 270.f);
wedgeGauge.SetWedge(wedge);
try
{
  // Measure
  EWedge measured = wedgeGauge.Measure(srcImage);
  // Get the inner and outer radius of the fitted wedge
  float innerRadius = measured.GetInnerRadius();
  float outerRadius = measured.GetOuterRadius();
}
catch (const EException& e)
{
  // The wedge was not found.
}

// Save the wedge gauge measurement context
wedgeGauge.Save("myWedgeGauge.gge");
```

## C#

```cs
using eVision;
```

```cs
// Image constructor
EImageBW8 srcImage = new EImageBW8();
// EWedgeGauge constructor
EWedgeGauge wedgeGauge = new EWedgeGauge();
// Adjust the transition parameters
wedgeGauge.TransitionType = ETransitionType.Bw;
wedgeGauge.TransitionChoice = ETransitionChoice.NthFromBegin;
wedgeGauge.TransitionIndex = 0;
// Set the wedge fitting gauge position, diameter (50 units),
// breadth (-25 units), starting angle (0°) and amplitude (270°)
EPoint center = new EPoint(256.0f, 256.0f);
EWedge wedge = new EWedge(center, 50.0f, -25.0f, 0.0f, 270.0f);
wedgeGauge.Wedge = wedge;
try
{
  // Measure
  EWedge measured = wedgeGauge.Measure(srcImage);
  // Get the inner and outer radius of the fitted wedge
  float innerRadius = measured.InnerRadius;
  float outerRadius = measured.OuterRadius;
}
catch (EException e)
{
  // The wedge was not found
}
// Save the wedge gauge measurement context
wedgeGauge.Save("myWedgeGauge.gge");
```

## Python

```py
import eVision
# Image constructor
src_image = eVision.EImageBW8()
# EWedgeGauge constructor
wedge_gauge = eVision.EWedgeGauge()
# Adjust the transition parameters
wedge_gauge.TransitionType = eVision.ETransitionType.Bw
wedge_gauge.TransitionChoice = eVision.ETransitionChoice.NthFromBegin
wedge_gauge.TransitionIndex = 0
# Set the wedge fitting gauge position, diameter (50 units),
# breadth (-25 units), starting angle (0°) and amplitude (270°)
center = eVision.EPoint(256.0, 256.0)
wedge = eVision.EWedge(center, 50.0, -25.0, 0.0, 270.0)
wedge_gauge.Wedge = wedge
try:
    # Measure
    measured = wedge_gauge.Measure(src_image)
    # Get the inner and outer radius of the fitted wedge
    innerRadius = measured.InnerRadius
    outerRadius = measured.OuterRadius
except eVision.EException:
    # The wedge was not found.
    pass

# Save the wedge gauge measurement context
wedge_gauge.Save("myWedgeGauge.gge")
```
