#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 inline void PrintMatrix(float mat[16])
{
for (int y = 0; y < 4; ++y)
{
for (int x = 0; x < 4; ++x)
{
printf("%f \t", mat[x + y * 4]);
}
printf("\n");
}
}
static sig_atomic_t running = 1;
static sig_atomic_t restart = 0;
static const uint32_t numberOfSamplesToGrab = 100;
{
static uint32_t samplesGrabbed = 0;
if (samplesGrabbed++ >= numberOfSamplesToGrab)
{
running = 0;
}
{
PrintMatrix(mat);
}
}
{
switch (mode)
{
printf("Tracker tracking\n");
break;
printf("Tracker paused\n");
break;
printf("Tracker disconnected\n");
break;
printf("Tracker reconnected\n");
restart = 1;
break;
default:
printf("Mode: %d\n", (int)mode);
break;
}
}
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
{
printf("\nNo calibration information could be found in the configuration directory. "
"Please use the PST Server and PST Client application to initialize the PST Tracker and create/import a tracking target. "
"More information can be found in the Initialization section of the PST SDK manual and the PST Manual.\n\n");
printf("Press enter to continue...\n");
getchar();
return 1;
}
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");
double fps;
printf("Frame rate set to %f \n", fps);
while (running == 1)
{
if (restart == 1)
{
restart = false;
}
#ifdef WIN32
Sleep(100);
#else
usleep(100000);
#endif
}
return 0;
}