Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpTemplateTrackerZone.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
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 https://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 */
37#ifndef vpTemplateTrackerZone_hh
38#define vpTemplateTrackerZone_hh
39
40#include <vector>
41
42#include <visp3/core/vpConfig.h>
43#include <visp3/core/vpDisplay.h>
44#include <visp3/core/vpException.h>
45#include <visp3/core/vpImage.h>
46#include <visp3/core/vpRect.h>
47#include <visp3/tt/vpTemplateTrackerHeader.h>
48#include <visp3/tt/vpTemplateTrackerTriangle.h>
49
68class VISP_EXPORT vpTemplateTrackerZone
69{
70protected:
71 std::vector<vpTemplateTrackerTriangle> Zone;
72 int min_x;
73 int min_y;
74 int max_x;
75 int max_y;
76
77public:
80 virtual ~vpTemplateTrackerZone();
81
82 // add a triangle to the zone
83 void add(const vpTemplateTrackerTriangle &t);
84 void clear();
85 void copy(const vpTemplateTrackerZone &z);
86
87 // display the area on an image
88 void display(const vpImage<unsigned char> &I, const vpColor &col = vpColor::green, unsigned int thickness = 3);
89 void display(const vpImage<vpRGBa> &I, const vpColor &col = vpColor::green, unsigned int thickness = 3);
90
91 // colorie le tieme triangle
92 void fillTriangle(vpImage<unsigned char> &I, unsigned int id, unsigned char gray_level);
93
94 double getArea() const;
95 vpImagePoint getCenter() const;
96 vpImagePoint getCenter(int borne_x, int borne_y) const;
97 // get bounds of the area
98 int getMaxx() const;
99 int getMaxy() const;
100 int getMinx() const;
101 int getMiny() const;
102 vpRect getBoundingBox() const;
103
106 unsigned int getNbTriangle() const { return static_cast<unsigned int>(Zone.size()); }
107 vpTemplateTrackerZone getPyramidDown() const;
108 // renvoie le ieme triangle de la zone
109 void getTriangle(unsigned int i, vpTemplateTrackerTriangle &T) const;
110 vpTemplateTrackerTriangle getTriangle(unsigned int i) const;
111
112 // create an area by clicking on an image
113 void initClick(const vpImage<unsigned char> &I, bool delaunay = false);
114 // create an area with a pointer of integer that describes a series of
115 // triangles:
116 // *pt= t0.S1.x,t0.S1.y,t0.S2.x,t0.S2.y,t0.S3.x,t0.S3.y, t1.S1.x ...
117 void initFromPoints(const vpImage<unsigned char> &I, const std::vector<vpImagePoint> &ip, bool delaunay = false);
118
119 // check if a point is in the area
120 bool inZone(const int &i, const int &j) const;
121 bool inZone(const double &i, const double &j) const;
122 // check if a point is in the area and return the corresponding triangle
123 // id_triangle where the point is.
124 bool inZone(const int &i, const int &j, unsigned int &id_triangle) const;
125 bool inZone(const double &i, const double &j, unsigned int &id_triangle) const;
126
127 vpTemplateTrackerZone &operator=(const vpTemplateTrackerZone &z);
128};
129END_VISP_NAMESPACE
130#endif
Class to define RGB colors available for display functionalities.
Definition vpColor.h:157
static const vpColor green
Definition vpColor.h:201
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:131
Defines a rectangle in the plane.
Definition vpRect.h:79
std::vector< vpTemplateTrackerTriangle > Zone
Vector of triangles that defines the zone.
int max_y
Bounding box parameter.
unsigned int getNbTriangle() const
void copy(const vpTemplateTrackerZone &z)
int max_x
Bounding box parameter.
void fillTriangle(vpImage< unsigned char > &I, unsigned int id, unsigned char gray_level)
void add(const vpTemplateTrackerTriangle &t)
vpImagePoint getCenter() const
void display(const vpImage< unsigned char > &I, const vpColor &col=vpColor::green, unsigned int thickness=3)
int min_y
Bounding box parameter.
int min_x
Bounding box parameter.