Client library

The client support library provides a C++ client class that uses C++ protocol API to communicate with the tracker process, besides communication the class also takes care of launching tracker process, handling timeouts, logging, and other things. The class also supports setting up communication over streams as well as over TCP sockets. A detailed tutorial on how to use the client library is available here. To compile the module you have to enable BUILD_CLIENT flag in CMake build system (check out the tutorial on compiling the project for more details).

CONNECTION_DEFAULT

Default connection mode, standard input and output streams.

CONNECTION_EXPLICIT

Non-standard input and output streams are created, passed to tracker via environment variables TRAX_IN and TRAX_OUT.

CONNECTION_SOCKETS

Using TCP socket for communication, connection parameters passed to tracker via environment variable TRAX_SOCKET.

class TrackerProcess
TrackerProcess(const std::string &command, const std::map<string, string> environment, int timeout = 10, trax::ConnectionMode connection = trax::CONNECTION_DEFAULT, VerbosityMode verbosity = trax::VERBOSITY_DEFAULT)
Parameters:
  • command – The name of tracker program followed by its input arguments
  • environment – A map of environmental variables that have to be set for the tracker process
  • timeout – Number of seconds to wait for tracker’s response before terminating the session
  • connection – Type of connection, supported are either CONNECTION_DEFAULT, CONNECTION_EXPLICIT, or CONNECTION_SOCKETS.
  • verbosity – How verbose should the output be
~TrackerProcess()

Destroys the process and cleans up data.

int image_formats()
Returns:A bitset of image formats supported by the tracker.
int region_formats()
Returns:A bitset of region formats supported by the tracker.
bool ready()
Returns:True if the tracker process is alive.
bool tracking()
Returns:True if the tracker process is tracking an object (was initalized).
bool initialize(const trax::Image &image, const trax::Region &region, const trax::Properties &properties = trax::Properties())

Request tracker initialization with a given image and region.

Parameters:
  • image – Input image object
  • region – Input region object
  • properties – Optional properties passed to the tracker
Returns:

True on success, if the function returns false check trax::TrackerProcess::ready() if the process has crashed or simply requested termination

bool frame(const trax::Image &image, const trax::Properties &properties = trax::Properties())

Request tracker update with a given image.

Parameters:
  • image – Input image object
  • properties – Optional properties passed to the tracker
Returns:

True on success, if the function returns false check trax::TrackerProcess::ready() if the process has crashed or simply requested termination

bool wait(trax::Region &region, trax::Properties &properties)

Waits for tracker’s response to the previous request (either initialization or update).

Parameters:
  • region – Output region object, on success populated with output region
  • properties – Optional output properties object, populated by returned optional values, if any
Returns:

True on success, if the function returns false check trax::TrackerProcess::ready() if the process has crashed or simply requested termination

bool reset()

Restarts the tracker process. The function terminates the tracker process and starts a new one.

int load_trajectory(const std::string &file, std::vector<Region> &trajectory)

Utility function to load a trajectory (a sequence of object states) form a text file.

Parameters:
  • file – Filename string
  • trajectory – Empty vector that will be populated with region states
Returns:

Number of read states

void save_trajectory(const std::string &file, std::vector<Region> &trajectory)

Utility function to save a trajectory (a sequence of object states) to a text file.

Parameters:
  • file – Filename string
  • trajectory – Vector that contains the trajectory