Commit 6b112dc6 authored by Patrik Huber's avatar Patrik Huber

Templated draw_sample method and added overloads for vector<float> and vector<double>

This is mainly to accommodate fit-model-ceres, where I've used double for all parameters
parent fa7d0eaa
......@@ -27,6 +27,8 @@
#include "glm/gtc/quaternion.hpp"
#include "ceres/cubic_interpolation.h"
#include "opencv2/core/core.hpp" // for Vec2f
#include <array>
......
......@@ -158,9 +158,14 @@ public:
* The given coefficients should follow a standard normal distribution, i.e.
* not be "normalised" with their eigenvalues/variances.
*
* @tparam T Precision of the given coefficients - can be double or float.
* @param[in] coefficients The PCA coefficients used to generate the sample.
* @return A model instance with given coefficients.
*/
template<typename T>
cv::Mat draw_sample(std::vector<T> coefficients) const;
template<>
cv::Mat draw_sample(std::vector<float> coefficients) const
{
// Fill the rest with zeros if not all coefficients are given:
......@@ -174,6 +179,14 @@ public:
return model_sample;
};
template<>
cv::Mat draw_sample(std::vector<double> coefficients) const
{
// We have to convert the vector of doubles to float:
std::vector<float> coeffs_float(std::begin(coefficients), std::end(coefficients));
return draw_sample(coeffs_float);
};
/**
* Returns the PCA basis matrix, i.e. the eigenvectors.
* Each column of the matrix is an eigenvector.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment