RidgeRun Video Stabilization Library/API Reference/Adding Algorithms: Difference between revisions

From RidgeRun Developer Wiki
No edit summary
Line 22: Line 22:


==== Defining the Apply method ====
==== Defining the Apply method ====
This method receives two parameters:
* softgyro: This is the input data containing a vector of orientation values (Quaternions) along with their corresponding timestamps. It is used by the interpolation algorithm.
* interpolated: This contains a vector of interpolated orientation values with their corresponding interpolation timestamps.
The user must take into account that the method uses the IInterpolator start time member to perform the interpolation.
<syntaxhighlight lang=c++>
RuntimeError ExampleInterpolator::Apply(
    std::vector<std::pair<Quaternion<double>, uint64_t>>&interpolated,
    std::vector<std::pair<Quaternion<double>, uint64_t>>& softgyro) {
  RuntimeError ret{};
  /* Interpolation algorithm logic */
  return ret;
</syntaxhighlight>


==== Defining the Reset method ====
==== Defining the Reset method ====
This method receives an start time value as parameter and sets the IInterpolator start time member to the inserted value.
<syntaxhighlight lang=c++>
RuntimeError ExampleInterpolator::Reset(const uint64_t start_time) {
  RuntimeError ret{};
  /* Reset start time logic */
  return ret;
}
</syntaxhighlight>


<noinclude>
<noinclude>
{{RidgeRun Video Stabilization Library/Foot|API Reference/Adding New Sensors|API Reference/Adding Stabilization Algorithm}}
{{RidgeRun Video Stabilization Library/Foot|API Reference/Adding New Sensors|API Reference/Adding Stabilization Algorithm}}
</noinclude>
</noinclude>

Revision as of 23:28, 1 July 2024









Introduction

Integrator

Interpolator

The interpolator algorithms adjust the timestamps of the IMU sensor measurements to align with the timestamps of the captured frames. This alignment is necessary because the IMU sensor time and the camera sensor time (or system internal time) may not match. Therefore, the system needs to adjust the measurements based on the frame capture time. To add a new interpolator algorithm, follow these steps:

  • Define the Interpolator Algorithm class, inheriting from the IInterpolator class.
  • Add the new Interpolator Algorithm to the Interpolator Interface.

Define the Interpolator Algorithm

The RidgeRun Interpolator Interface, known as IInterpolator, is an extensible class design to support various types of interpolators. To add a new interpolator to it, the user must implement a new interpolator class that derives from the IInterpolator class. This class must implement the following methods:

  • Apply: applies the interpolator algorithm to the desired data based on a initial time.
  • Reset: sets the initial time of the interpolator to the desired value.

Defining the Apply method

This method receives two parameters:

  • softgyro: This is the input data containing a vector of orientation values (Quaternions) along with their corresponding timestamps. It is used by the interpolation algorithm.
  • interpolated: This contains a vector of interpolated orientation values with their corresponding interpolation timestamps.

The user must take into account that the method uses the IInterpolator start time member to perform the interpolation.

RuntimeError ExampleInterpolator::Apply(
    std::vector<std::pair<Quaternion<double>, uint64_t>>&interpolated,
    std::vector<std::pair<Quaternion<double>, uint64_t>>& softgyro) {
  RuntimeError ret{};

  /* Interpolation algorithm logic */

  return ret;


Defining the Reset method

This method receives an start time value as parameter and sets the IInterpolator start time member to the inserted value.

RuntimeError ExampleInterpolator::Reset(const uint64_t start_time) {
  RuntimeError ret{};

  /* Reset start time logic */

  return ret;
}