This example can be found in examples\c\trackingtarget\trackingtarget.c
.
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 the PST Client together with the pst_sdk_enable_shared_memory() fuction, or use the stand-alone PST Server to configure the tracking targets.
When compiling and running this example, please make sure that the required dependencies can be found by the executable (e.g. by copying the Redist
directory into the build directory. When the PST SDK has been installed through the PST Software Suite installer the Redist folder can be found in the Development folder.).
#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
static void Exithandler(int sig);
#ifdef WIN32
BOOL WINAPI ConsoleHandler(DWORD CEvent)
{
Exithandler(CEvent);
return TRUE;
}
#endif
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <signal.h>
static sig_atomic_t running = 1;
static const uint32_t numberOfSamplesToGrab = 100;
{
static uint32_t samplesGrabbed = 0;
if (samplesGrabbed++ >= numberOfSamplesToGrab)
{
running = 0;
}
{
}
}
static void Exithandler(int sig)
{
running = 0;
}
void PrintLastErrorMessage()
{
char* last_error_message = NULL;
{
last_error_message = "Failed to allocate memory error.";
}
printf("last error message: %s \n", last_error_message);
}
{
{
PrintLastErrorMessage();
exit(status);
}
}
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
#ifdef WIN32
#else
CheckErrorCode(
pst_tracker_init4(&ctracker,
"",
"config.cfg",
"models.db", argv[1]));
#endif
char* version_string;
printf("Running PST Server version %s \n", version_string);
printf("Put the Reference card in front of the PST in order to see tracking results.\n\n");
size_t number_of_statuses;
printf("Found %zu tracking targets:\n", number_of_statuses);
for (int i = 0; i < number_of_statuses; ++i)
{
printf("%s\t%s\n", statuses[i].target.name, statuses[i].status ? "true" : "false");
}
printf("\n");
printf("3D marker positions making up the Reference target:\n");
{
}
printf("\n");
while (running == 1)
{
#ifdef WIN32
Sleep(100);
#else
usleep(100000);
#endif
}
printf("Press enter to continue...\n");
getchar();
return 0;
}