Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpMbtDistanceKltCylinder.h
1/****************************************************************************
2 *
3 * ViSP, open source Visual Servoing Platform software.
4 * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5 *
6 * This software is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 * See the file LICENSE.txt at the root directory of this source
11 * distribution for additional information about the GNU GPL.
12 *
13 * For using ViSP with software that can not be combined with the GNU
14 * GPL, please contact Inria about acquiring a ViSP Professional
15 * Edition License.
16 *
17 * See https://visp.inria.fr for more information.
18 *
19 * This software was developed at:
20 * Inria Rennes - Bretagne Atlantique
21 * Campus Universitaire de Beaulieu
22 * 35042 Rennes Cedex
23 * France
24 *
25 * If you have questions regarding the use of this file, please contact
26 * Inria at visp@inria.fr
27 *
28 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30 *
31 * Description:
32 * Klt cylinder, containing points of interest.
33 *
34*****************************************************************************/
35
36#ifndef vpMbtDistanceKltCylinder_h
37#define vpMbtDistanceKltCylinder_h
38
39#include <visp3/core/vpConfig.h>
40
41#if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
42
43#include <map>
44
45#include <visp3/core/vpCircle.h>
46#include <visp3/core/vpCylinder.h>
47#include <visp3/core/vpDisplay.h>
48#include <visp3/core/vpGEMM.h>
49#include <visp3/core/vpPlane.h>
50#include <visp3/core/vpPolygon3D.h>
51#include <visp3/klt/vpKltOpencv.h>
52#include <visp3/mbt/vpMbHiddenFaces.h>
53#include <visp3/vision/vpHomography.h>
54
65class VISP_EXPORT vpMbtDistanceKltCylinder
66{
67private:
71 vpPoint p1Ext;
73 vpPoint p2Ext;
75 vpCylinder cylinder;
77 vpCircle circle1;
79 vpCircle circle2;
81 std::map<int, vpImagePoint> initPoints;
83 std::map<int, vpPoint> initPoints3D;
85 std::map<int, vpImagePoint> curPoints;
87 std::map<int, int> curPointsInd;
89 unsigned int nbPointsCur;
91 unsigned int nbPointsInit;
93 unsigned int minNbPoint;
95 bool enoughPoints;
99 bool isTrackedKltCylinder;
100
101public:
103 std::vector<int> listIndicesCylinderBBox;
108
109private:
110 double computeZ(const double &x, const double &y);
111 bool isTrackedFeature(int id);
112
113 // private:
114 //#ifndef DOXYGEN_SHOULD_SKIP_THIS
115 // vpMbtDistanceKltCylinder(const vpMbtDistanceKltCylinder &)
116 // : c0Mo(), p1Ext(), p2Ext(), cylinder(), circle1(), circle2(),
117 // initPoints(), initPoints3D(), curPoints(), curPointsInd(),
118 // nbPointsCur(0), nbPointsInit(0), minNbPoint(4),
119 // enoughPoints(false), cam(), isTrackedKltCylinder(true),
120 // listIndicesCylinderBBox(), hiddenface(NULL), useScanLine(false)
121 // {
122 // throw vpException(vpException::functionNotImplementedError, "Not
123 // implemented!");
124 // }
125 // vpMbtDistanceKltCylinder &operator=(const vpMbtDistanceKltCylinder &){
126 // throw vpException(vpException::functionNotImplementedError, "Not
127 // implemented!"); return *this;
128 // }
129 //#endif
130
131public:
134
135 void buildFrom(const vpPoint &p1, const vpPoint &p2, const double &r);
136
137 unsigned int computeNbDetectedCurrent(const vpKltOpencv &_tracker);
138 void computeInteractionMatrixAndResidu(const vpHomogeneousMatrix &cMc0, vpColVector &_R, vpMatrix &_J);
139
140 void display(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
141 const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
142 void display(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam,
143 const vpColor &col, unsigned int thickness = 1, bool displayFullModel = false);
144
145 void displayPrimitive(const vpImage<unsigned char> &_I);
146 void displayPrimitive(const vpImage<vpRGBa> &_I);
147
153 inline vpCameraParameters &getCameraParameters() { return cam; }
154
155 inline std::map<int, vpImagePoint> &getCurrentPoints() { return curPoints; }
156
157 inline std::map<int, int> &getCurrentPointsInd() { return curPointsInd; }
158
159 inline vpCylinder getCylinder() const { return cylinder; }
160
169 inline unsigned int getInitialNumberPoint() const { return nbPointsInit; }
180 inline unsigned int getCurrentNumberPoints() const { return nbPointsCur; }
181
182 std::vector<std::vector<double> > getFeaturesForDisplay();
183
184 std::vector<std::vector<double> > getModelForDisplay(const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam);
185
186 inline bool hasEnoughPoints() const { return enoughPoints; }
187
193 inline bool isTracked() const { return isTrackedKltCylinder; }
194
195 void init(const vpKltOpencv &_tracker, const vpHomogeneousMatrix &cMo);
196
197 void removeOutliers(const vpColVector &weight, const double &threshold_outlier);
198
204 virtual inline void setCameraParameters(const vpCameraParameters &_cam) { cam = _cam; }
205
211 inline void setTracked(const bool &track) { this->isTrackedKltCylinder = track; }
212
213 void updateMask(cv::Mat &mask, unsigned char _nb = 255, unsigned int _shiftBorder = 0);
214};
215
216#endif
217
218#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:152
Class that defines a 3D cylinder in the object frame and allows forward projection of a 3D cylinder i...
Definition vpCylinder.h:98
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition of the vpImage class member functions.
Definition vpImage.h:135
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
Definition vpKltOpencv.h:73
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:152
Implementation of the polygons management for the model-based trackers.
Implementation of a polygon of the model containing points of interest. It is used by the model-based...
virtual void setCameraParameters(const vpCameraParameters &_cam)
vpCameraParameters & getCameraParameters()
std::map< int, int > & getCurrentPointsInd()
bool useScanLine
Use scanline rendering.
void setTracked(const bool &track)
unsigned int getCurrentNumberPoints() const
std::vector< int > listIndicesCylinderBBox
Pointer to the polygon that define a face.
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:77