E3DComparer Advanced Sample

This code snippet shows how to set the options when comparing two elements with E3DComparer.

C++

#include <eVision/Easy3D/Easy3DMatch/E3DComparer.h>
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;
float hystDistanceThresh = 1.5f, hystAreaThresh = .5f;
comparer.SetAnomalyThresholds(EAnomalyThresholds(distanceThresh, areaThresh));
comparer.SetAnomalyHysteresis(EAnomalyThresholds(hystDistanceThresh, hystAreaThresh));  // defined relatively to base thresholds

// Set ROIs
std::vector<E3DBox> rois = { E3DBox(15, 15, 15) };
comparer.SetROI(rois);
std::vector<E3DBox> dontCare = { E3DBox(5, 5, 5) };
comparer.SetDontCare(dontCare);
std::vector<E3DBox> noExtraMaterial = { E3DBox(E3DPoint(10, 15, 20), 0, 0, 0, 5, 5, 5) };
comparer.SetNoExtraMaterial(noExtraMaterial);

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

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

C#

using eVision.Easy3D;
// load the reference cad and set reference
E3DComparer comparer = new E3DComparer();
EMesh cad = new EMesh();
cad.Load("...");
comparer.MeshReference = cad;

// Set thresholds
float distanceThresh = 0.2f, areaThresh = 1.0f;
float hystDistanceThresh = 1.5f, hystAreaThresh = 0.5f;
comparer.AnomalyThresholds = new EAnomalyThresholds(distanceThresh, areaThresh);
comparer.AnomalyHysteresis = new EAnomalyThresholds(hystDistanceThresh, hystAreaThresh);  // defined relatively to base thresholds

// Set ROIs
E3DBox[] rois = new E3DBox[1];
rois[0] = new E3DBox(15, 15, 15);
comparer.ROI = rois;
E3DBox[] dontCare = new E3DBox[1];
dontCare[0] = new E3DBox(5, 5, 5);
comparer.DontCare = dontCare;
E3DBox[] noExtraMaterial = new E3DBox[1];
noExtraMaterial[0] = new E3DBox(new E3DPoint(10, 15, 20), 0, 0, 0, 5, 5, 5);
comparer.NoExtraMaterial = noExtraMaterial;

// 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

from eVision import Easy3D
# load the reference cad and set reference
comparer = Easy3D.E3DComparer()
cad = Easy3D.EMesh()
cad.Load("...")
comparer.MeshReference = cad

# Set thresholds
comparer.AnomalyThresholds = Easy3D.EAnomalyThresholds(distanceThreshold=0.2, areaThreshold=1.)
comparer.AnomalyHysteresis = Easy3D.EAnomalyThresholds(distanceThreshold=1.5, areaThreshold=0.5)  # defined relatively to base thresholds

# Set ROIs
rois = [Easy3D.E3DBox(15, 15, 15)]
comparer.ROI = rois
dontCare = [Easy3D.E3DBox(5, 5, 5)]
comparer.DontCare = dontCare
no_extra_material = [Easy3D.E3DBox(Easy3D.E3DPoint(10, 15, 20), 0, 0, 0, 5, 5, 5)]
comparer.NoExtraMaterial = no_extra_material

# 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)