Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpMbtDistanceKltCylinder.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 cylinder, containing points of interest.
32 */
33
34#ifndef vpMbtDistanceKltCylinder_h
35#define vpMbtDistanceKltCylinder_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/vpCircle.h>
44#include <visp3/core/vpCylinder.h>
45#include <visp3/core/vpDisplay.h>
46#include <visp3/core/vpGEMM.h>
47#include <visp3/core/vpPlane.h>
48#include <visp3/core/vpPolygon3D.h>
49#include <visp3/klt/vpKltOpencv.h>
50#include <visp3/mbt/vpMbHiddenFaces.h>
51#include <visp3/vision/vpHomography.h>
52
76class VISP_EXPORT vpMbtDistanceKltCylinder
77{
78private:
82 vpPoint p1Ext;
84 vpPoint p2Ext;
86 vpCylinder cylinder;
88 vpCircle circle1;
90 vpCircle circle2;
92 std::map<int, vpImagePoint> initPoints;
94 std::map<int, vpPoint> initPoints3D;
96 std::map<int, vpImagePoint> curPoints;
98 std::map<int, int> curPointsInd;
100 unsigned int nbPointsCur;
102 unsigned int nbPointsInit;
104 unsigned int minNbPoint;
106 bool enoughPoints;
110 bool isTrackedKltCylinder;
111
112public:
114 std::vector<int> listIndicesCylinderBBox;
119
120private:
121 double computeZ(const double &x, const double &y);
122 bool isTrackedFeature(int id);
123
124 // private:
125 //#ifndef DOXYGEN_SHOULD_SKIP_THIS
126 // vpMbtDistanceKltCylinder(const vpMbtDistanceKltCylinder &)
127 // : c0Mo(), p1Ext(), p2Ext(), cylinder(), circle1(), circle2(),
128 // initPoints(), initPoints3D(), curPoints(), curPointsInd(),
129 // nbPointsCur(0), nbPointsInit(0), minNbPoint(4),
130 // enoughPoints(false), cam(), isTrackedKltCylinder(true),
131 // listIndicesCylinderBBox(), hiddenface(nullptr), useScanLine(false)
132 // {
133 // throw vpException(vpException::functionNotImplementedError, "Not
134 // implemented!");
135 // }
136 // vpMbtDistanceKltCylinder &operator=(const vpMbtDistanceKltCylinder &){
137 // throw vpException(vpException::functionNotImplementedError, "Not
138 // implemented!"); return *this;
139 // }
140 //#endif
141
142#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
143 vpMbtDistanceKltCylinder(const vpMbtDistanceKltCylinder &) = delete; // non construction-copyable
144 vpMbtDistanceKltCylinder &operator=(const vpMbtDistanceKltCylinder &) = delete; // non copyable
145#endif
146
147public:
148 vpMbtDistanceKltCylinder();
149 virtual ~vpMbtDistanceKltCylinder();
150
151 void buildFrom(const vpPoint &p1, const vpPoint &p2, const double &r);
152
153 unsigned int computeNbDetectedCurrent(const vpKltOpencv &_tracker);
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
169 inline vpCameraParameters &getCameraParameters() { return cam; }
170
171 inline std::map<int, vpImagePoint> &getCurrentPoints() { return curPoints; }
172
173 inline std::map<int, int> &getCurrentPointsInd() { return curPointsInd; }
174
175 inline vpCylinder getCylinder() const { return cylinder; }
176
185 inline unsigned int getInitialNumberPoint() const { return nbPointsInit; }
196 inline unsigned int getCurrentNumberPoints() const { return nbPointsCur; }
197
198 std::vector<std::vector<double> > getFeaturesForDisplay();
199
200 std::vector<std::vector<double> > getModelForDisplay(const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam);
201
202 inline bool hasEnoughPoints() const { return enoughPoints; }
203
209 inline bool isTracked() const { return isTrackedKltCylinder; }
210
211 void init(const vpKltOpencv &_tracker, const vpHomogeneousMatrix &cMo);
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->isTrackedKltCylinder = 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.
Class that defines a 3D circle in the object frame and allows forward projection of a 3D circle in th...
Definition vpCircle.h:87
Implementation of column vector and the associated operations.
Class to define RGB colors available for display functionalities.
Definition vpColor.h:157
Class that defines a 3D cylinder in the object frame and allows forward projection of a 3D cylinder i...
Definition vpCylinder.h:101
Implementation of an homogeneous matrix and operations on such kind of matrices.
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.
virtual void setCameraParameters(const vpCameraParameters &_cam)
void buildFrom(const vpPoint &p1, const vpPoint &p2, const double &r)
vpCameraParameters & getCameraParameters()
std::map< int, int > & getCurrentPointsInd()
unsigned int computeNbDetectedCurrent(const vpKltOpencv &_tracker)
void computeInteractionMatrixAndResidu(const vpHomogeneousMatrix &cMc0, vpColVector &_R, vpMatrix &_J)
bool useScanLine
Use scanline rendering.
void setTracked(const bool &track)
void displayPrimitive(const vpImage< unsigned char > &_I)
unsigned int getCurrentNumberPoints() const
std::vector< int > listIndicesCylinderBBox
Pointer to the polygon that define a face.
void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
unsigned int getInitialNumberPoint() const
std::map< int, vpImagePoint > & getCurrentPoints()
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition vpPoint.h:79