# E3DComparer Minimal Sample

This code snippet shows how to compare a sample with a golden scan reference.

## C++

```cpp
#include <eVision/Easy3D/Easy3DMatch/E3DComparer.h>
```

```cpp
using namespace eVision;
using namespace eVision::Easy3D;

// load the reference golden scan and set reference
E3DComparer comparer;
EPointCloud cloud;
cloud.Load("...");
comparer.SetPointCloudReference(cloud);

// Set thresholds
float distanceThresh = .2f, areaThresh = 1.f;
comparer.SetAnomalyThresholds(EAnomalyThresholds(distanceThresh, areaThresh));
// Prepare data structures (optional)
comparer.PrepareReference();

// load the sample and perform comparison
EPointCloud sample;
sample.Load("...");
comparer.Compare(sample);

// compute anomalies
std::vector<E3DAnomaly> anomalies = comparer.ComputesAnomalies();

//TODO: if (anomalies.size() != 0u): an anomaly was detected: inspect the sample manually? throw it away?

// get cloud to inspect it manually
EPointCloud visualisationCloud;
comparer.GetComparisonPointCloud(visualisationCloud);
```

## C#

```cs
using eVision.Easy3D;
```

```cs
// load the reference golden scan and set reference
E3DComparer comparer = new E3DComparer();
EPointCloud reference = new EPointCloud();
reference.Load("...");
comparer.PointCloudReference = reference;

// Set thresholds
float distanceThresh = 0.2f, areaThresh = 1.0f;
comparer.AnomalyThresholds = new EAnomalyThresholds(distanceThresh, areaThresh);
// Prepare data structures (optional)
comparer.PrepareReference();

// load the sample and perform comparison
EPointCloud sample = new EPointCloud();
sample.Load("...");
comparer.Compare(sample);

// compute anomalies
E3DAnomaly[] anomalies = comparer.ComputesAnomalies();

//TODO: if (anomalies.Length != 0): an anomaly was detected: inspect the sample manually? throw it away?

// get cloud to inspect it manually
EPointCloud visualisationCloud = new EPointCloud();
comparer.GetComparisonPointCloud(visualisationCloud);
```

## Python

```py
from eVision import Easy3D
# load the reference golden scan and set reference
comparer = Easy3D.E3DComparer()
reference = Easy3D.EPointCloud()
reference.Load("...")
comparer.PointCloudReference = reference

# Set thresholds
comparer.AnomalyThresholds = Easy3D.EAnomalyThresholds(distanceThreshold=0.2, areaThreshold=1.)
# Prepare data structures (optional)
comparer.PrepareReference()

# load the sample and perform comparison
sample = Easy3D.EPointCloud()
sample.Load("...")
comparer.Compare(sample)

# compute anomalies
anomalies = comparer.ComputesAnomalies()

# TODO: if len(anomalies) != 0: an anomaly was detected: inspect the sample manually? throw it away?

# get cloud to inspect it manually
visualisation_cloud = Easy3D.EPointCloud()
comparer.GetComparisonPointCloud(visualisation_cloud)
```
