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