This example can be found in examples\c\minimal\minimal.c.
This minimal example shows how to connect to the PST SDK and how to register a callback function to receive data.
Note that for simplicity reasons, this example does not take the recommended safety precautions to shut down the PST Tracker when the application shuts down. In an actual implementation, please follow the safety precautions recommended in the Safe Tracker Termination section of the Using PST SDK page of the manual. Examples of how to implement the safety precautions can be found in the other examples.
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.).
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif
{
}
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
#else
CheckErrorCode(
pst_tracker_init4(&ctracker,
"",
"config.cfg",
"models.db", argv[1]));
#endif
#ifdef WIN32
Sleep(10000);
#else
sleep(10);
#endif
return 0;
}
EPstErrorStatus pst_tracker_init(PstTracker *ctracker)
This function initializes the tracker object.
EPstErrorStatus pst_alloc_and_get_last_error_message(char **cstring)
This function returns the last error message that was recorded by the system.
EPstErrorStatus pst_tracker_init4(PstTracker *ctracker, const char path[], const char config_file[], const char db_file[], const char grabber_name[])
This function initializes the tracker object.
void pst_tracker_destroy(PstTracker *ctracker)
void pst_sdk_shutdown()
Shutdown the tracking system, stopping tracking.
void pst_free(void *data)
Free data allocated by the PST SDK.
EPstErrorStatus pst_tracker_start(PstTracker *ctracker)
Start tracking.
EPstErrorStatus pst_tracker_add_tracker_data_callback(PstTracker *ctracker, void(*on_tracker_data)(const PstTrackerData *, EPstErrorStatus))
Add a callback function for tracker data.
EPstErrorStatus
Tracker error messages enum class.
Definition pstsdk_c.h:44
@ PST_ERROR_STATUS_OK
Definition pstsdk_c.h:45
Tracking information retrieved from tracker.
Definition pstsdk_c.h:248
Main PST SDK struct for tracker communication.
Definition pstsdk_c.h:264