Visual Servoing Platform  version 3.0.0
vpTemplateTrackerZone.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  *****************************************************************************/
39 #ifndef vpTemplateTrackerZone_hh
40 #define vpTemplateTrackerZone_hh
41 
42 #include <vector>
43 
44 #include <visp3/core/vpDisplay.h>
45 #include <visp3/core/vpException.h>
46 #include <visp3/core/vpImage.h>
47 #include <visp3/tt/vpTemplateTrackerTriangle.h>
48 #include <visp3/tt/vpTemplateTrackerHeader.h>
49 #include <visp3/core/vpRect.h>
50 
59 class VISP_EXPORT vpTemplateTrackerZone
60 {
61  protected:
62  std::vector<vpTemplateTrackerTriangle> Zone;
63  int min_x;
64  int min_y;
65  int max_x;
66  int max_y;
67 
68  public:
72 
73  //add a triangle to the zone
74  void add(const vpTemplateTrackerTriangle &t);
75  void clear();
76  void copy(const vpTemplateTrackerZone& z);
77 
78  //display the area on an image
79  void display(const vpImage<unsigned char> &I, const vpColor &col = vpColor::green, const unsigned int thickness=3);
80  void display(const vpImage<vpRGBa> &I, const vpColor &col = vpColor::green, const unsigned int thickness=3);
81 
82  //colorie le tieme triangle
83  void fillTriangle(vpImage<unsigned char>& I, unsigned int id, unsigned char gray_level);
84 
85  double getArea() const;
86  vpImagePoint getCenter() const;
87  vpImagePoint getCenter(int borne_x, int borne_y) const;
88  //get bounds of the area
89  int getMaxx() const;
90  int getMaxy() const;
91  int getMinx() const;
92  int getMiny() const;
93  vpRect getBoundingBox() const;
94 
96  unsigned int getNbTriangle() const { return (unsigned int)Zone.size(); }
97  vpTemplateTrackerZone getPyramidDown() const;
98  //renvoie le ieme triangle de la zone
99  void getTriangle(unsigned int i, vpTemplateTrackerTriangle &T) const;
100  vpTemplateTrackerTriangle getTriangle(unsigned int i) const;
101 
102  //create an area by clicking on an image
103  void initClick(const vpImage<unsigned char>& I, bool delaunay = false);
104  //create an area with a pointer of integer that describes a series of triangles:
105  // *pt= t0.S1.x,t0.S1.y,t0.S2.x,t0.S2.y,t0.S3.x,t0.S3.y, t1.S1.x ...
106  void initFromPoints(const vpImage<unsigned char>& I, const std::vector< vpImagePoint > &ip, bool delaunay = false);
107 
108  //check if a point is in the area
109  bool inZone(const int &i,const int &j) const;
110  bool inZone(const double &i,const double &j) const;
111  //check if a point is in the area and return the corresponding triangle id_triangle where the point is.
112  bool inZone(const int &i,const int &j, unsigned int &id_triangle) const;
113  bool inZone(const double &i,const double &j, unsigned int &id_triangle) const;
114 
115  vpTemplateTrackerZone & operator=(const vpTemplateTrackerZone &z);
116 };
117 #endif
118 
std::vector< vpTemplateTrackerTriangle > Zone
Vector of triangles that defines the zone.
int max_y
Bounding box parameter.
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
int min_x
Bounding box parameter.
static const vpColor green
Definition: vpColor.h:166
unsigned int getNbTriangle() const
int min_y
Bounding box parameter.
int max_x
Bounding box parameter.
Defines a rectangle in the plane.
Definition: vpRect.h:81
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88