Skip to content

Extras

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
    VIRNECT::LOG::registerLogCallbackFunction(logCallback);
    

    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
trackingFramework.setTargetInformation(targets);

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


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. 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 enables a convenient reading of calibration data from a JSON file.

#include <VARAPI/TrackingFramework/Tools.hpp>

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

// Use the calibration reader tool to load camera calibration from JSON file
VIRNECT::TOOLS::readCalibrationFile(calibrationPath, cameraCalibration);

// Set camera calibration
trackingFramework.setCameraCalibration(cameraCalibration);

The JSON needs to have the following format:

calibration.json

{
  "Intrinsic": {
    "Resolution": [ 640.0, 480.0 ],
    "FocalLength": [ 656.85, 662.13 ],
    "PrincipalPoint": [ 305.06, 222.43 ],
    "Distortion": [ -0.361067, 0.125624, 0.001535, -0.002319, 0.0 ]
  }
}

The distortion coefficients are in the order r1, r2, t1, t2, r3, where r and t are representing the radial and tangential distortion parameters. If you cannot determine some of these distortion parameters, set them to 0.0.


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
while(recording)
{
    trackingFramework.process();
}

// Retrieve recording state
VIRNECT::TOOLS::RECORDER::isRecording();

// Stop recording
VIRNECT::TOOLS::RECORDER::stopRecording();

To use the recording functionality the framework needs to be set up and running. Once 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 sequences can be used as an Image Source for the Track framework.

Extended Tracking

The extended tracking feature can be used to enlarge your tracking space:

// Enable extended tracking
trackingFramework.enableExtendedTracker(true);

When using this the extended tracking, only one target may be defined. This target needs to be stationary in its environment.

Warning

This feature is currently in experimental stage.

Back to top