DAVID4 SDK  1.8.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
TimedScans.cpp

Takes a scan every x minute.

/// @example TimedScans.cpp
///
/// Takes a scan every x minute.
#include "davidSDK/david.h"
#include <time.h>
#include <iostream>
#include <chrono>
#include <thread>
namespace examples {
/// Take a scan every 'waitTimeInSeconds' seconds.
/// This example assumes that the scanner is calibrated and camera and projector are connected and correctly configured.
/// The scans are saved in the current directory.
///
/// @param[in] waitTimeInSeconds Wait time in seconds until next scan.
/// @param[in] scanCount Total number of scans to be taken.
void main_TimedScans(double waitTimeInSeconds, int scanCount)
{
try
{
david.Connect();
for (int i=0; i < scanCount; ++i)
{
// Get filename and save current time.
time_t begin = time(0);
std::string filename;
{
tm tstruct;
#ifdef _WIN32
localtime_s(&tstruct, &begin);
#else
tstruct = *localtime(&begin);
#endif
char buf[80];
strftime(buf, sizeof(buf), "%Y-%m-%d_%H-%M-%S", &tstruct);
filename = buf;
filename += ".obj";
std::cout << "filename: " << filename << std::endl;
}
// Scan and export.
david.sls().Scan();
david.sls().ExportMesh(filename);
// Wait.
double dif = 0.0;
while (dif < waitTimeInSeconds)
{
dif = difftime(time(0), begin);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}
}
catch (david::Exception& e)
{
e.PrintError();
}
}
} // namespace