31#ifndef VP_PARABOLA_MODEL_H
32#define VP_PARABOLA_MODEL_H
34#include <visp3/core/vpConfig.h>
35#include <visp3/core/vpColVector.h>
36#include <visp3/core/vpMatrix.h>
38#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
39#ifndef DOXYGEN_SHOULD_SKIP_THIS
46class vpTutoParabolaModel
49 inline vpTutoParabolaModel(
const unsigned int °ree,
const unsigned int &height,
const unsigned int &width)
51 , m_height(static_cast<unsigned
int>(
height))
52 , m_width(static_cast<unsigned
int>(
width))
53 , m_coeffs(degree + 1, 0.)
64 inline vpTutoParabolaModel(
const VISP_NAMESPACE_ADDRESSING vpColVector &coeffs,
const unsigned int &height,
const unsigned int &width)
65 : m_degree(coeffs.size() - 1)
66 , m_height(static_cast<unsigned
int>(
height))
67 , m_width(static_cast<unsigned
int>(
width))
79 inline vpTutoParabolaModel(
const VISP_NAMESPACE_ADDRESSING vpMatrix &coeffs,
const unsigned int &height,
const unsigned int &width)
80 : m_degree(coeffs.getRows() - 1)
81 , m_height(static_cast<unsigned
int>(
height))
82 , m_width(static_cast<unsigned
int>(
width))
83 , m_coeffs(coeffs.getCol(0))
92 inline double eval(
const double &u)
const
94 double normalizedU =
u / m_width;
96 for (
unsigned int i = 0;
i <= m_degree; ++
i) {
97 v += m_coeffs[
i] * std::pow(normalizedU, i);
108 inline VISP_NAMESPACE_ADDRESSING vpColVector toVpColVector()
const
113 inline vpTutoParabolaModel &operator=(
const vpTutoParabolaModel &other)
115 m_degree = other.m_degree;
116 m_height = other.m_height;
117 m_width = other.m_width;
118 m_coeffs = other.m_coeffs;
136 static void fillSystem(
const unsigned int °ree,
const double &height,
const double &width,
const std::vector<VISP_NAMESPACE_ADDRESSING vpImagePoint> &pts, VISP_NAMESPACE_ADDRESSING vpMatrix &A, VISP_NAMESPACE_ADDRESSING vpMatrix &b)
138 const unsigned int nbPts =
static_cast<unsigned int>(pts.size());
139 const unsigned int nbCoeffs = degree + 1;
140 std::vector<VISP_NAMESPACE_ADDRESSING vpImagePoint> normalizedPts;
142 for (
const auto &pt: pts) {
143 normalizedPts.push_back(VISP_NAMESPACE_ADDRESSING vpImagePoint(pt.get_i() / height, pt.get_j() / width));
145 A.resize(nbPts, nbCoeffs, 1.);
147 for (
unsigned int i = 0;
i < nbPts; ++
i) {
148 double u = normalizedPts[
i].get_u();
149 double v = normalizedPts[
i].get_v();
150 for (
unsigned int j = 0;
j < nbCoeffs; ++
j) {
151 A[
i][
j] = std::pow(u, j);
158 friend std::ostream &operator<<(std::ostream &os,
const vpTutoParabolaModel &model)
160 os <<
"Highest degree = " << model.m_degree << std::endl;
161 os <<
"Coeffs = [ " << model.m_coeffs.transpose() <<
" ]" << std::endl;
166 unsigned int m_degree;
167 unsigned int m_height;
168 unsigned int m_width;
169 VISP_NAMESPACE_ADDRESSING vpColVector m_coeffs;