E3DMatcher Advanced Sample

This code snippet shows how to set the options when matching two elements with E3DMatcher.

C++

#include <eVision/Easy3D/Easy3DMatch/E3DMatcher.h>
using namespace eVision;
using namespace eVision::Easy3D;

// load the reference golden scan and set reference
E3DMatcher matcher;
EPointCloud reference;
float azimuthReference = 0.f, elevationReference = 90.f;
reference.Load("...");
matcher.SetReference(reference, azimuthReference, elevationReference);

// Use advanced comparison mode
matcher.SetComparisonDistanceMode(EComparisonDistanceMode_Advanced);
// ignore shadows
matcher.SetEnableMissingPointAsAnomaly(false);
// Set thresholds
float distanceThresh = .2f, areaThresh = 1.f;
float hystDistanceThresh = 1.5f, hystAreaThresh = .5f;
matcher.SetAnomalyThresholds(EAnomalyThresholds(distanceThresh, areaThresh));
matcher.SetAnomalyHysteresis(EAnomalyThresholds(hystDistanceThresh, hystAreaThresh));  // defined relatively to base thresholds

// Retrieve reference poses (reference must have been set)
std::vector<EZMap8> referencePoseProjections;
matcher.RetrieveReferencePosesProjections(referencePoseProjections);
// Set ROI on the left half of the object
ERectangleRegion roiRegion(0.f, 0.f, float(referencePoseProjections[0].GetWidth()) / 2.f, float(referencePoseProjections[0].GetHeight()));
matcher.SetComparisonROI(&roiRegion);
// Set No Extra material on the whole object
ERectangleRegion noExtraMatRegion(0.f, 0.f, float(referencePoseProjections[0].GetWidth()) / 2.f, float(referencePoseProjections[0].GetHeight()));
matcher.SetComparisonNoExtraMaterial(&noExtraMatRegion);

// Prepare data structures (optional)
matcher.PrepareReference();

// load the sample and perform comparison
EPointCloud sample;
float azimuthSample = 0.f, elevationSample = -90.f;
sample.Load("...");
E3DMatch match = matcher.Match(sample, azimuthSample, elevationSample);
std::vector<E3DAnomaly> anomalies = match.GetAnomalies();
// TODO: if (anomalies.size() != 0u):an anomaly was detected: inspect the sample manually? throw it away?

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

C#

using eVision;
using eVision.Easy3D;
// load the reference golden scan and set reference
E3DMatcher matcher = new E3DMatcher();
EPointCloud reference = new EPointCloud();
float azimuthReference = 0.0f, elevationReference = 90.0f;
reference.Load("...");
matcher.SetReference(reference, azimuthReference, elevationReference);

// Use advanced comparison mode
matcher.ComparisonDistanceMode = EComparisonDistanceMode.Advanced;
// ignore shadows
matcher.EnableMissingPointAsAnomaly = false;
// Set thresholds
float distanceThresh = 0.2f, areaThresh = 1.0f;
float hystDistanceThresh = 1.5f, hystAreaThresh = 0.5f;
matcher.AnomalyThresholds = new EAnomalyThresholds(distanceThresh, areaThresh);
matcher.AnomalyHysteresis = new EAnomalyThresholds(hystDistanceThresh, hystAreaThresh);  // defined relatively to base thresholds

// Retrieve reference poses (reference must have been set)
EZMap8[] referencePoseProjections;
matcher.RetrieveReferencePosesProjections(out referencePoseProjections);
// Set ROI on the left half of the object
float originX = 0.0f, originY = 0.0f, width = referencePoseProjections[0].Width / 2, height = referencePoseProjections[0].Height / 2;
ERectangleRegion roiRegion = new ERectangleRegion(originX, originY, width, height);
matcher.SetComparisonROI(roiRegion);
// Set No Extra material on the whole object
originX = 0.0f; originY = 0.0f; width = referencePoseProjections[0].Width / 2; height = referencePoseProjections[0].Height / 2;
ERectangleRegion noExtraMatRegion = new ERectangleRegion(originX, originY, width, height);
matcher.SetComparisonNoExtraMaterial(roiRegion);

// Prepare data structures (optional)
matcher.PrepareReference();

// load the sample and perform comparison
EPointCloud sample = new EPointCloud();
float azimuthSample = 0.0f, elevationSample = -90.0f;
sample.Load("...");
E3DMatch match = matcher.Match(sample, azimuthSample, elevationSample);
E3DAnomaly[] anomalies = match.Anomalies;
// 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();
matcher.GetComparisonPointCloud(visualisationCloud);

Python

import eVision
from eVision import Easy3D
# load the reference golden scan and set reference
matcher = Easy3D.E3DMatcher()
reference = Easy3D.EPointCloud()
reference.Load("...")
matcher.SetReference(reference, azimuth=0., elevation=90.)

# Use advanced comparison mode
matcher.ComparisonDistanceMode = Easy3D.EComparisonDistanceMode.Advanced
# ignore shadows
matcher.EnableMissingPointAsAnomaly = False
# Set thresholds
matcher.AnomalyThresholds = Easy3D.EAnomalyThresholds(distanceThreshold=0.2, areaThreshold=1.)
matcher.AnomalyHysteresis = Easy3D.EAnomalyThresholds(distanceThreshold=1.5, areaThreshold=0.5)  # defined relatively to base thresholds

# Retrieve reference poses (reference must have been set)
reference_pose_projections = []
matcher.RetrieveReferencePosesProjections(reference_pose_projections)
# Set ROI on the left half of the object
roiRegion = eVision.ERectangleRegion(originX=0., originY=0.,
  width=reference_pose_projections[0].Width / 2, height=reference_pose_projections[0].Height / 2)
matcher.SetComparisonROI(roiRegion)
# Set No Extra material on the whole object
noExtraMatRegion = eVision.ERectangleRegion()
matcher.SetComparisonNoExtraMaterial(roiRegion)

# Prepare data structures (optional)
matcher.PrepareReference()

# load the sample and perform comparison
sample = Easy3D.EPointCloud()
sample.Load("...")
match = matcher.Match(sample, azimuth=0., elevation=-90.)
anomalies = match.Anomalies
# 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()
matcher.GetComparisonPointCloud(visualisation_cloud)