Skip to content


This section describes additional functions of the VIRNECT Track Framework.

Get Framework Log Messages

The Track framework provides three methods in the LOG namespace to retrieve log messages:

#include <VARAPI/TrackingFramework/Log.hpp>    

  • Latest log message
    To retrieve the latest log message as a string, simply call the following method:

    // Retrieve the latest log message
    const std::string lastLogMessage = VIRNECT::LOG::getLastLogMessage();
  • All log messages
    To retrieve a vector containing all log messages call:

    // Retrieve all log messages
    const std::vector<std::string> allLogMessages = VIRNECT::LOG::getAllLogMessages();
  • Register a callback function
    To automatically invoke a custom method on a logging event, you can register a callback function:

    // Register callback function for logging

    Example declaration for such a callback function:

    * @brief Callback function that will be invoked when Track logs a message
    * @param message Log message
    * @param level Log level
    void logCallback(const std::string& message, VIRNECT::LOG::LogLevel level)
        std::cout << message << std::endl;

Get Target Meta Information

Meta information about targets, like their type or physical size, can be retrieved by calling the following method:

// Get target meta information
const std::unordered_map<std::string, VIRNECT::TargetInformation> targets = trackingFramework.getTargetInformation();

// Log target meta information
for (const auto& [targetName, target] : targets)
    std::cout << targetName << std::endl;
    std::cout << VIRNECT::TargetTypeNames[static_cast<int32_t>(target.mType)] << std::endl;
    std::cout << "Size:" << std::endl;
    std::cout << "X: [ " << target.mDimensions.mMin.x << ", " << target.mDimensions.mMax.x << " ]" << std::endl;
    std::cout << "Y: [ " << target.mDimensions.mMin.y << ", " << target.mDimensions.mMax.y << " ]" << std::endl;
    std::cout << "Z: [ " << target.mDimensions.mMin.z << ", " << target.mDimensions.mMax.z << " ]" << std::endl;

Modify Trackable Targets at Runtime

By modifying the target meta information, you can activate and deactivate the tracking for each individual target during runtime. To do so, set the mIgnore property of the target information accordingly.

// Get target meta information
std::unordered_map<std::string, VIRNECT::TargetInformation> targets = trackingFramework.getTargetInformation();

// Deactivate tracking for target "VARIMG_000"
targets["VARIMG_000"].mIgnore = true;

// Set target meta information

Changing any other property of the target meta information will have no effect on the framework.

Get 3D Model data

In case a CAD model is used as a target, the 3D mesh information of this model can be loaded from the framework:

// Get 3D mesh information
VIRNECT::CADModel cadModel = trackingFramework.getCADModel();

The returned VIRNECT::CADModel contains the vertex data and vertex IDs, which can be used for visualization of the tracked model.

Retrieve Image from Image Source

You can retrieve a shallow copy of the latest processed image as a VIRNECT::ImageRGB for visualization purposes.

// Get last processed image
VIRNECT::ImageRGB image = trackingFramework.getLastProcessedImage();

Use a Custom Image Source

The process function can also be called with a parameter of type VIRNECT::ImageRGB. Instantiate an object of type VIRNECT::ImageRGB, set all parameters and fill the buffer. Note that the resolution must match the specified camera calibration. Use this object as an input for the Track framework process function:

// Instantiate image object
VIRNECT::ImageRGB image;

// Fill image
image.mWidth = 640;
image.mHeight = 480;
image.mStride = sizeof(byte) * image.mChannels * image.mWidth;
std::memcpy(image.mBuffer, source.buffer, std::sizeof(source.buffer))

// Use Image
bool success = trackingFramework.process(image);

Calibration Reader Tool

The Calibration Reader Tool allows convenient readout of calibration data from a JSON file. The format of the JSON file must follow the format specified here. Since the calibration format can reflect multiple cameras with multiple resolutions the desired camera ID and resolution can be specified as optional parameters in the readCalibrationFile function. Note that the resolution must be within the list of supported resolutions which is also defined in commons.hpp as VIRNECT::SupportedResolutions.

#include <VARAPI/TrackingFramework/Tools.hpp>

// Instantiate camera calibration object
VIRNECT::CameraCalibration cameraCalibration;

// Use the calibration reader tool to load camera calibration from JSON file
// with optional parameters for camera ID and resolution
VIRNECT::TOOLS::readCalibrationFile(calibrationPath, cameraCalibration, "cam0", {640, 480});

// Set camera calibration

Record Image Sequence

Track provides convenient methods to record the camera input stream as an image sequence:

#include <VARAPI/TrackingFramework/Tools.hpp>

// Start recording
VIRNECT::TOOLS::RECORDER::startRecording("../FolderPath", usePGMFormat);

// Process framework

// Retrieve recording state

// Stop recording

To use the recording functionality the framework needs to be set up and running. Once the recording is enabled via the startRecording method, each call of the process Method will record one frame.

Supported file formats are JPG & PGM.

A recorded file sequence can be used as an Image Source for the Track framework.

Use the map recorder

To record a Map target, the map recording mode needs to be enabled before the initialization of the framework. To initialize the recording, one image target needs to be set as well. Once the recording is finished, the map can be saved by calling saveMapTarget.

// Enable map recording
trackingFramework.enableMapTargetGeneration(true, "mapTargetName", targetDataPath);

// Set Image target for initialization

// Initialize framework


        // Save target with name "mapTargetName" to targetDataPath


Get 3D Map points

To visualize Map targets, the tracked 3D points can be loaded from the framework. To reduce the amount of data retrieved with this command, the version of the Map should be checked beforehand. When the Map data updates internally, the version number will be increased.

// Save latest retrieved version
uint64_t lastRetrievedVersion = 0;


    // Check MAP data version
    uint64_t currentVersion = trackingFramework.getMapVersion(targetName)
    if( currentVersion > lastRetrievedVersion){

        // Update version
        lastRetrievedVersion = currentVersion;

        // Retrieve tracked MAP points
        std::vector<Vec3<double>> trackedPoints = trackingFramework.getMapPoints(targetName);

        // Visualize points