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
46 class 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;
137 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)
139 const unsigned int nbPts =
static_cast<unsigned int>(pts.size());
140 const unsigned int nbCoeffs = degree + 1;
141 std::vector<VISP_NAMESPACE_ADDRESSING vpImagePoint> normalizedPts;
143 for (
const auto &pt: pts) {
144 normalizedPts.push_back(VISP_NAMESPACE_ADDRESSING
vpImagePoint(pt.get_i() / height, pt.get_j() / width));
146 A.resize(nbPts, nbCoeffs, 1.);
148 for (
unsigned int i = 0; i < nbPts; ++i) {
149 double u = normalizedPts[i].get_u();
150 double v = normalizedPts[i].get_v();
151 for (
unsigned int j = 0; j < nbCoeffs; ++j) {
152 A[i][j] = std::pow(u, j);
159 friend std::ostream &operator<<(std::ostream &os,
const vpTutoParabolaModel &model)
161 os <<
"Highest degree = " << model.m_degree << std::endl;
162 os <<
"Coeffs = [ " << model.m_coeffs.transpose() <<
" ]" << std::endl;
167 unsigned int m_degree;
168 unsigned int m_height;
169 unsigned int m_width;
Implementation of column vector and the associated operations.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Implementation of a matrix and operations on matrices.