Visual Servoing Platform  version 3.0.0
vpTemplateTrackerTriangle.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
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 http://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  * Template tracker.
32  *
33  * Authors:
34  * Amaury Dame
35  * Aurelien Yol
36  * Fabien Spindler
37  *
38  *****************************************************************************/
44 #ifndef vpTemplateTrackerTriangle_hh
45 #define vpTemplateTrackerTriangle_hh
46 
47 #include <assert.h>
48 #include <vector>
49 
50 #include <visp3/core/vpMatrix.h>
51 #include <visp3/core/vpMath.h>
52 #include <visp3/core/vpColVector.h>
53 #include <visp3/core/vpImagePoint.h>
54 #include <visp3/tt/vpTemplateTrackerHeader.h>
55 
60 class VISP_EXPORT vpTemplateTrackerTriangle
61 {
62  protected:
63  double minx_temp;
64  double miny_temp;
68 
69  double l_t;
70  double h_t;
71 
72  bool not_good;
73  double uvinv00;
74  double uvinv01;
75  double uvinv10;
76  double uvinv11;
78  double area;
79 
80  private:
81  vpColVector getCorner1() const;
82  vpColVector getCorner2() const;
83  vpColVector getCorner3() const;
84 
85  public:
88  vpTemplateTrackerTriangle(const vpColVector &c1, const vpColVector &c2, const vpColVector &c3);
89  vpTemplateTrackerTriangle(const vpImagePoint &c1, const vpImagePoint &c2, const vpImagePoint &c3);
90  vpTemplateTrackerTriangle(int x1, int y1, int x2, int y2, int x3, int y3);
91  vpTemplateTrackerTriangle(double x1, double y1, double x2, double y2, double x3, double y3);
92 
98  inline double getArea() const{
99  return this->area;
100  }
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  assert(i<3);
119  if(i==0) return getCorner1();
120  else if(i==1) return getCorner2();
121  else /*if(i==2)*/ return getCorner3();
122  };
131  void getCorner(unsigned int i, double &x, double &y) const {
132  assert(i<3);
133  if(i==0) {
134  x = C1.x;
135  y = C1.y;
136  }
137  else if(i==1) {
138  x = C2.x;
139  y = C2.y;
140  }
141  else /*if(i==2)*/ {
142  x = C3.x;
143  y = C3.y;
144  }
145  };
146 
147  double getMaxx() const;
148  double getMaxy() const;
149  double getMinx() const;
150  double getMiny() const;
151 
152  void getSize(double &w, double &h) const;
153  void getSize(int &w, int &h) const;
154 
155  void init(const vpColVector &c1,const vpColVector &c2,const vpColVector &c3);
156  void init(const vpImagePoint &c1, const vpImagePoint &c2, const vpImagePoint &c3);
157  void init(int x1,int y1, int x2,int y2, int x3,int y3);
158  void init(double x1,double y1, double x2,double y2, double x3,double y3);
159  bool inTriangle(const vpImagePoint &ip) const;
160  bool inTriangle(const int &i, const int &j) const;
161  bool inTriangle(const double &i,const double &j) const;
162 
164 };
165 #endif
166 
void getCorner(unsigned int i, double &x, double &y) const
vpColVector getCorner(unsigned int i) const
vpTemplateTrackerDPoint C2
Corner 1.
vpTemplateTrackerDPoint C3
Corner 2.
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88