Shows usage of david::ShapeFusion and david::Measure class.
#include "davidSDK/david.h"
#include <math.h>
#include <iostream>
#ifdef _WIN32
#include <conio.h>
#else
#include <curses.h>
#define _getch getch
#endif
namespace examples {
{
try
{
for (size_t i=0; i < cameraNames.size(); ++i)
{
if (cameraNames[i].find("DAVID-CAM") != std::string::npos)
{
break;
}
}
while (true)
{
printf("\nPress ESC to stop, or any other key to start new measurement\n");
char ch = _getch();
if (27==ch) break;
std::cout << "New scan consists of " << num << " 3D points\n";
const double MAX_DIST = 2.0;
std::vector<float> distances;
const float DIST_GOOD = 1.0f;
const float MAX_ALLOWED_RATIO = 0.05f;
int numBad=0;
for (float dist : distances)
{
if (fabs(dist)>DIST_GOOD)
{
numBad++;
}
}
float badRatio = (float)numBad / distances.size();
std::cout << badRatio*100 << " percent of vertices are 'bad'\n";
if (badRatio <= MAX_ALLOWED_RATIO)
{
std::cout << "==> PART IS GOOD :-)\n";
}
else
{
std::cout << "==> PART IS BAD :-(\n";
}
}
}
{
}
}
}