This example can be found in Development\trackingtarget\trackingtarget.cpp.
This example shows how to work with tracking targets using the PST SDK. Note that at this moment tracking targets can not be trained or imported using the PST SDK. In order to add new tracking targets, please use trhe PST Client together with the PSTech::pstsdk::Tracker::EnableSharedMemory() fuction, or use the stand-alone PST Server to configure the tracking targets.
#ifdef WIN32
#include <windows.h>
#endif
static void Exithandler(int sig);
#ifdef WIN32
BOOL WINAPI ConsoleHandler(DWORD CEvent)
{
Exithandler(CEvent);
return TRUE;
}
#endif
#include <memory>
#include <iostream>
static bool running = true;
static const uint32_t numberOfSamplesToGrab = 100;
{
{
static uint32_t samplesGrabbed = 0;
if (samplesGrabbed++ >= numberOfSamplesToGrab)
running = false;
std::cout <<
"Detected " << pose.
name <<
"\n";
}
} listener;
std::shared_ptr<PSTech::pstsdk::Tracker> pst;
static void Exithandler(int sig)
{
pst->Shutdown();
}
int main(int argc, char *argv[])
{
#ifdef WIN32
SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler, TRUE);
#else
signal(SIGTERM, Exithandler);
signal(SIGKILL, Exithandler);
signal(SIGQUIT, Exithandler);
signal(SIGINT, Exithandler);
#endif
try
{
pst = std::make_shared<PSTech::pstsdk::Tracker>();
std::cout << "Running PST Server version " << pst->GetVersionInfo() << "\n";
pst->AddTrackerListener(&listener);
pst->Start();
std::cout << "System check: " << (int)pst->Systemcheck() << "\n";
std::cout << "Found " << targets.size() << " tracking targets:\n";
std::cout << t.name << "\t" << t.status << "\n";
std::cout << "\n";
pst->SetTargetStatus("Reference", true);
std::cout << "3D marker positions making up the Reference target:\n";
for (auto& marker : markers)
std::cout << "x: " << marker[0] << "\t" << "y: " << marker[1] << "\t" << "z: " << marker[2] << "\n";
std::cout << "\n";
while (running)
{
Sleep(100);
}
}
{
}
std::cout << "Press enter to continue...\n";
std::cin.get();
pst->Shutdown();
return 0;
}