Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpMbtDistanceKltPoints.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * See the file LICENSE.txt at the root directory of this source
10 * distribution for additional information about the GNU GPL.
11 *
12 * For using ViSP with software that can not be combined with the GNU
13 * GPL, please contact Inria about acquiring a ViSP Professional
14 * Edition License.
15 *
16 * See https://visp.inria.fr for more information.
17 *
18 * This software was developed at:
19 * Inria Rennes - Bretagne Atlantique
20 * Campus Universitaire de Beaulieu
21 * 35042 Rennes Cedex
22 * France
23 *
24 * If you have questions regarding the use of this file, please contact
25 * Inria at visp@inria.fr
26 *
27 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 *
30 * Description:
31 * Klt polygon, containing points of interest.
32 */
33
34#ifndef _vpMbtDistanceKltPoints_h_
35#define _vpMbtDistanceKltPoints_h_
36
37#include <visp3/core/vpConfig.h>
38
39#if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
40
41#include <map>
42
43#include <visp3/core/vpDisplay.h>
44#include <visp3/core/vpGEMM.h>
45#include <visp3/core/vpPlane.h>
46#include <visp3/core/vpPolygon3D.h>
47#include <visp3/klt/vpKltOpencv.h>
48#include <visp3/mbt/vpMbHiddenFaces.h>
49#include <visp3/vision/vpHomography.h>
50
74class VISP_EXPORT vpMbtDistanceKltPoints
75{
76private:
78 vpMatrix H;
82 vpColVector N_cur;
85 double invd0;
87 vpColVector cRc0_0n;
89 std::map<int, vpImagePoint> initPoints;
91 std::map<int, vpImagePoint> curPoints;
93 std::map<int, int> curPointsInd;
95 unsigned int nbPointsCur;
97 unsigned int nbPointsInit;
99 unsigned int minNbPoint;
101 bool enoughPoints;
103 double dt;
105 double d0;
109 bool isTrackedKltPoints;
110
111public:
118
119private:
120 double compute_1_over_Z(double x, double y);
121 void computeP_mu_t(double x_in, double y_in, double &x_out, double &y_out, const vpMatrix &cHc0);
122 bool isTrackedFeature(int id);
123
124 // private:
125 //#ifndef DOXYGEN_SHOULD_SKIP_THIS
126 // vpMbtDistanceKltPoints(const vpMbtDistanceKltPoints &)
127 // : H(), N(), N_cur(), invd0(1.), cRc0_0n(), initPoints(),
128 // curPoints(), curPointsInd(),
129 // nbPointsCur(0), nbPointsInit(0), minNbPoint(4),
130 // enoughPoints(false), dt(1.), d0(1.), cam(),
131 // isTrackedKltPoints(true), polygon(nullptr), hiddenface(nullptr),
132 // useScanLine(false)
133 // {
134 // throw vpException(vpException::functionNotImplementedError, "Not
135 // implemented!");
136 // }
137 // vpMbtDistanceKltPoints &operator=(const vpMbtDistanceKltPoints &){
138 // throw vpException(vpException::functionNotImplementedError, "Not
139 // implemented!"); return *this;
140 // }
141 //#endif
142
143#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
144 vpMbtDistanceKltPoints(const vpMbtDistanceKltPoints &) = delete; // non construction-copyable
145 vpMbtDistanceKltPoints &operator=(const vpMbtDistanceKltPoints &) = delete; // non copyable
146#endif
147
148public:
149 vpMbtDistanceKltPoints();
150 virtual ~vpMbtDistanceKltPoints();
151
152 unsigned int computeNbDetectedCurrent(const vpKltOpencv &_tracker, const vpImage<bool> *mask = nullptr);
153 void computeHomography(const vpHomogeneousMatrix &_cTc0, vpHomography &cHc0);
155
156 void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
157 const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
158 void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
159 const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
160
162 void displayPrimitive(const vpImage<vpRGBa> &_I);
163
164 std::vector<std::vector<double> > getFeaturesForDisplay();
165
166 std::vector<std::vector<double> > getModelForDisplay(const vpCameraParameters &cam, bool displayFullModel = false);
167
173 inline vpCameraParameters &getCameraParameters() { return cam; }
174
175 inline vpColVector getCurrentNormal() const { return N_cur; }
176
177 inline std::map<int, vpImagePoint> &getCurrentPoints() { return curPoints; }
178
179 inline std::map<int, int> &getCurrentPointsInd() { return curPointsInd; }
180
189 inline unsigned int getInitialNumberPoint() const { return nbPointsInit; }
200 inline unsigned int getCurrentNumberPoints() const { return nbPointsCur; }
201
202 inline bool hasEnoughPoints() const { return enoughPoints; }
203
204 void init(const vpKltOpencv &_tracker, const vpImage<bool> *mask = nullptr);
205
211 inline bool isTracked() const { return isTrackedKltPoints; }
212
213 void removeOutliers(const vpColVector &weight, const double &threshold_outlier);
214
220 virtual inline void setCameraParameters(const vpCameraParameters &_cam) { cam = _cam; }
221
227 inline void setTracked(const bool &track) { this->isTrackedKltPoints = track; }
228
229 void updateMask(cv::Mat &mask, unsigned char _nb = 255, unsigned int _shiftBorder = 0);
230};
231END_VISP_NAMESPACE
232#endif
233
234#endif // VISP_HAVE_OPENCV
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
Class to define RGB colors available for display functionalities.
Definition vpColor.h:157
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of an homography and operations on homographies.
Definition of the vpImage class member functions.
Definition vpImage.h:131
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
Definition vpKltOpencv.h:83
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:175
Implementation of the polygons management for the model-based trackers.
void displayPrimitive(const vpImage< unsigned char > &_I)
bool useScanLine
Use scanline rendering.
void computeInteractionMatrixAndResidu(vpColVector &_R, vpMatrix &_J)
unsigned int computeNbDetectedCurrent(const vpKltOpencv &_tracker, const vpImage< bool > *mask=nullptr)
vpColVector getCurrentNormal() const
std::vector< std::vector< double > > getFeaturesForDisplay()
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
vpCameraParameters & getCameraParameters()
virtual void setCameraParameters(const vpCameraParameters &_cam)
unsigned int getCurrentNumberPoints() const
std::vector< std::vector< double > > getModelForDisplay(const vpCameraParameters &cam, bool displayFullModel=false)
void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)
vpMbtPolygon * polygon
Pointer to the polygon that define a face.
std::map< int, int > & getCurrentPointsInd()
unsigned int getInitialNumberPoint() const
std::map< int, vpImagePoint > & getCurrentPoints()
void computeHomography(const vpHomogeneousMatrix &_cTc0, vpHomography &cHc0)
void setTracked(const bool &track)
Implementation of a polygon of the model used by the model-based tracker.