ViSP  2.9.0
vpTemplateTrackerZone.h
1 /****************************************************************************
2  *
3  * $Id: vpTemplateTrackerZone.h 4661 2014-02-10 19:34:58Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  * Description:
34  * Template tracker.
35  *
36  * Authors:
37  * Amaury Dame
38  * Aurelien Yol
39  * Fabien Spindler
40  *
41  *****************************************************************************/
42 #ifndef vpTemplateTrackerZone_hh
43 #define vpTemplateTrackerZone_hh
44 
45 #include <vector>
46 
47 #include <visp/vpDisplay.h>
48 #include <visp/vpException.h>
49 #include <visp/vpImage.h>
50 #include <visp/vpTemplateTrackerTriangle.h>
51 #include <visp/vpTemplateTrackerHeader.h>
52 #include <visp/vpRect.h>
53 
60 class VISP_EXPORT vpTemplateTrackerZone
61 {
62  protected:
63  std::vector<vpTemplateTrackerTriangle> Zone;
64  int min_x;
65  int min_y;
66  int max_x;
67  int max_y;
68 
69  public:
73 
74  //add a triangle to the zone
75  void add(const vpTemplateTrackerTriangle &t);
76  void clear();
77  void copy(const vpTemplateTrackerZone& z);
78 
79  //display the area on an image
80  void display(const vpImage<unsigned char> &I, const vpColor &col = vpColor::green, const unsigned int thickness=3);
81  void display(const vpImage<vpRGBa> &I, const vpColor &col = vpColor::green, const unsigned int thickness=3);
82 
83  //colorie le tieme triangle
84  void fillTriangle(vpImage<unsigned char>& I, unsigned int id, unsigned char gray_level);
85 
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:125
int min_x
Bounding box parameter.
static const vpColor green
Definition: vpColor.h:170
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:85
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:92