Visual Servoing Platform  version 3.6.1 under development (2024-07-27)
vpTemplateTrackerTriangle.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  * Template tracker.
33  *
34  * Authors:
35  * Amaury Dame
36  * Aurelien Yol
37  *
38 *****************************************************************************/
44 #ifndef vpTemplateTrackerTriangle_hh
45 #define vpTemplateTrackerTriangle_hh
46 
47 #include <assert.h>
48 #include <vector>
49 
50 #include <visp3/core/vpColVector.h>
51 #include <visp3/core/vpConfig.h>
52 #include <visp3/core/vpImagePoint.h>
53 #include <visp3/core/vpMath.h>
54 #include <visp3/core/vpMatrix.h>
55 #include <visp3/tt/vpTemplateTrackerHeader.h>
56 
62 class VISP_EXPORT vpTemplateTrackerTriangle
63 {
64 protected:
65  double minx_temp;
66  double miny_temp;
70 
71  double l_t;
72  double h_t;
73 
74  bool not_good;
75  double uvinv00;
76  double uvinv01;
77  double uvinv10;
78  double uvinv11;
80  double area;
81 
82 private:
83  vpColVector getCorner1() const;
84  vpColVector getCorner2() const;
85  vpColVector getCorner3() const;
86 
87 public:
90  vpTemplateTrackerTriangle(const vpColVector &c1, const vpColVector &c2, const vpColVector &c3);
91  vpTemplateTrackerTriangle(const vpImagePoint &c1, const vpImagePoint &c2, const vpImagePoint &c3);
92  vpTemplateTrackerTriangle(int x1, int y1, int x2, int y2, int x3, int y3);
93  vpTemplateTrackerTriangle(double x1, double y1, double x2, double y2, double x3, double y3);
94 
100  inline double getArea() const { return this->area; }
101 
102  vpTemplateTrackerTriangle getPyramidDown() const;
103  void getCorners(vpColVector &c1, vpColVector &c2, vpColVector &c3) const;
104  void getCorners(vpImagePoint &c1, vpImagePoint &c2, vpImagePoint &c3) const;
105  void getCorners(std::vector<vpImagePoint> &c) const;
106 
117  vpColVector getCorner(unsigned int i) const
118  {
119  assert(i < 3);
120  if (i == 0)
121  return getCorner1();
122  else if (i == 1)
123  return getCorner2();
124  else /*if(i==2)*/
125  return getCorner3();
126  };
136  void getCorner(unsigned int i, double &x, double &y) const
137  {
138  assert(i < 3);
139  if (i == 0) {
140  x = C1.x;
141  y = C1.y;
142  }
143  else if (i == 1) {
144  x = C2.x;
145  y = C2.y;
146  }
147  else /*if(i==2)*/ {
148  x = C3.x;
149  y = C3.y;
150  }
151  };
152 
153  double getMaxx() const;
154  double getMaxy() const;
155  double getMinx() const;
156  double getMiny() const;
157 
158  void getSize(double &w, double &h) const;
159  void getSize(int &w, int &h) const;
160 
161  void init(const vpColVector &c1, const vpColVector &c2, const vpColVector &c3);
162  void init(const vpImagePoint &c1, const vpImagePoint &c2, const vpImagePoint &c3);
163  void init(int x1, int y1, int x2, int y2, int x3, int y3);
164  void init(double x1, double y1, double x2, double y2, double x3, double y3);
165  bool inTriangle(const vpImagePoint &ip) const;
166  bool inTriangle(const int &i, const int &j) const;
167  bool inTriangle(const double &i, const double &j) const;
168 
170 };
171 END_VISP_NAMESPACE
172 #endif
Implementation of column vector and the associated operations.
Definition: vpColVector.h:191
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:82
vpColVector getCorner(unsigned int i) const
vpTemplateTrackerDPoint C3
Corner 2.
vpTemplateTrackerDPoint C2
Corner 1.
void getCorner(unsigned int i, double &x, double &y) const