Visual Servoing Platform  version 3.6.1 under development (2025-02-11)
vpRBSilhouetteControlPoint.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2024 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 
36 #ifndef VP_RB_SILHOUETTE_CONTROL_POINT_H
37 #define VP_RB_SILHOUETTE_CONTROL_POINT_H
38 
39 #include <visp3/core/vpConfig.h>
40 
41 #include <visp3/core/vpPoint.h>
42 #include <visp3/core/vpPlane.h>
43 #include <visp3/core/vpLine.h>
44 #include <visp3/core/vpImagePoint.h>
45 #include <visp3/core/vpCameraParameters.h>
46 #include <visp3/me/vpMe.h>
47 #include <visp3/visual_features/vpFeatureLine.h>
48 #include <visp3/me/vpMeSite.h>
49 #include <visp3/core/vpDisplay.h>
50 
51 BEGIN_VISP_NAMESPACE
52 
58 class VISP_EXPORT vpRBSilhouetteControlPoint
59 {
60 private:
61 
62  double rho, theta;
63  double thetaInit;
64  double delta;
65  int sign;
66  //double a,b,c;
67  vpFeatureLine featureline;
68  vpLine line;
69 
70  std::vector<vpMeSite> m_candidates;
71  unsigned int m_numCandidates;
72  const vpMe *m_me;
73  vpMeSite s;
74 
76  vpColVector norm;
77  vpColVector normw;
78 
79  bool m_valid;
80 
81  bool m_isSilhouette;
82 
83  const vpCameraParameters *m_cam;
84 public:
85 
87 
88  // the 3D point
91 
92  double xs, ys, nxs, nys, Zs;
93 
94 public:
95 
96  void init();
100  vpRBSilhouetteControlPoint &operator=(const vpRBSilhouetteControlPoint &meTracker);
101  vpRBSilhouetteControlPoint &operator=(const vpRBSilhouetteControlPoint &&meTracker);
103 
109  void setNumCandidates(unsigned numCandidates) { m_numCandidates = numCandidates; }
110  unsigned getNumCandidates() const { return m_numCandidates; }
111  void setValid(bool valid) { m_valid = valid; }
112  bool isValid() const { return m_valid; }
113 
114 
115 
116  const vpCameraParameters &getCameraParameters() const { return *m_cam; }
117  bool siteIsValid() const { return s.getState() == vpMeSite::NO_SUPPRESSION; }
118  const vpMeSite &getSite() const { return s; }
119  vpMeSite &getSite() { return s; }
120  const vpFeatureLine &getFeatureLine() const { return featureline; }
121  const vpLine &getLine() const { return line; }
122  double getTheta() const { return theta; }
123  bool isSilhouette() const { return m_isSilhouette; }
124 
125  void initControlPoint(const vpImage<unsigned char> &I, double cvlt);
126  void detectSilhouette(const vpImage<float> &I);
127  void buildPoint(int n, int m, const double &Z, double orient, const vpColVector &normo, const vpHomogeneousMatrix &cMo, const vpHomogeneousMatrix &oMc, const vpCameraParameters &cam, const vpMe &me);
128  void buildSilhouettePoint(int n, int m, const double &Z, double orient, const vpColVector &normo, const vpHomogeneousMatrix &cMo, const vpHomogeneousMatrix &oMc, const vpCameraParameters &cam);
129 
130  void update(const vpHomogeneousMatrix &_cMo);
131  void updateSilhouettePoint(const vpHomogeneousMatrix &_cMo);
132 
138  void track(const vpImage<unsigned char> &I);
139 
147  void trackMultipleHypotheses(const vpImage<unsigned char> &I);
148 
149  void computeMeInteractionMatrixError(const vpHomogeneousMatrix &cMo, unsigned int i, vpMatrix &L, vpColVector &e);
150  void computeMeInteractionMatrixErrorMH(const vpHomogeneousMatrix &cMo, unsigned int i, vpMatrix &L, vpColVector &e);
151 
152 private:
153  bool isLineDegenerate() const;
154 
155  int outOfImage(int i, int j, int half, int rows, int cols) const;
156  int outOfImage(const vpImagePoint &iP, int half, int rows, int cols) const;
157  void buildPlane(const vpPoint &pointn, const vpColVector &normal, vpPlane &plane);
158  void buildPLine(const vpHomogeneousMatrix &oMc);
159 
160 };
161 
162 END_VISP_NAMESPACE
163 
164 #endif
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
Definition: vpColVector.h:191
Class that defines a 2D line visual feature which is composed by two parameters that are and ,...
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:82
Class that defines a 3D line in the object frame and allows forward projection of the line in the cam...
Definition: vpLine.h:103
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:169
Performs search in a given direction(normal) for a given distance(pixels) for a given 'site'....
Definition: vpMeSite.h:68
@ NO_SUPPRESSION
Point successfully tracked.
Definition: vpMeSite.h:86
vpMeSiteState getState() const
Definition: vpMeSite.h:283
Definition: vpMe.h:134
This class defines the container for a plane geometrical structure.
Definition: vpPlane.h:56
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:79
Trackable silhouette point representation.
~vpRBSilhouetteControlPoint()=default
void setNumCandidates(unsigned numCandidates)
Set the number of candidates to use for multiple hypotheses testing.
const vpFeatureLine & getFeatureLine() const
const vpCameraParameters & getCameraParameters() const