Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpPolygon.h
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2024 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
* Defines a generic 2D polygon.
32
*/
33
34
#ifndef VP_POLYGON_H
35
#define VP_POLYGON_H
36
37
#include <list>
38
#include <vector>
39
40
#include <visp3/core/vpConfig.h>
41
#include <visp3/core/vpCameraParameters.h>
42
#include <visp3/core/vpColor.h>
43
#include <visp3/core/vpImage.h>
44
#include <visp3/core/vpImagePoint.h>
45
#include <visp3/core/vpPoint.h>
46
#include <visp3/core/vpRect.h>
47
48
BEGIN_VISP_NAMESPACE
102
class
VISP_EXPORT
vpPolygon
103
{
104
public
:
105
enum
PointInPolygonMethod
106
{
107
PnPolySegmentIntersection
,
108
PnPolyRayCasting
110
};
111
112
vpPolygon
();
113
VP_EXPLICIT
vpPolygon
(
const
std::vector<vpImagePoint> &corners);
114
VP_EXPLICIT
vpPolygon
(
const
std::list<vpImagePoint> &corners);
115
vpPolygon
(
const
vpPolygon
&poly);
116
virtual
~vpPolygon
();
117
118
vpPolygon
&operator=(
const
vpPolygon
&poly);
119
120
vpPolygon
&buildFrom(
const
std::vector<vpImagePoint> &corners,
const
bool
&create_convex_hull =
false
);
121
vpPolygon
&buildFrom(
const
std::list<vpImagePoint> &corners,
const
bool
&create_convex_hull =
false
);
122
vpPolygon
&buildFrom(
const
std::vector<vpPoint> &corners,
const
vpCameraParameters
&cam,
123
const
bool
&create_convex_hull =
false
);
124
125
unsigned
int
getSize()
const
;
126
void
initClick(
const
vpImage<unsigned char>
&I,
unsigned
int
size = 5,
const
vpColor
&color =
vpColor::red
,
127
unsigned
int
thickness = 1);
128
void
initClick(
const
vpImage<vpRGBa>
&I,
unsigned
int
size = 5,
const
vpColor
&color =
vpColor::red
,
129
unsigned
int
thickness = 1);
130
131
bool
isInside(
const
vpImagePoint
&iP,
const
PointInPolygonMethod &method = PnPolyRayCasting)
const
;
132
133
void
display(
const
vpImage<unsigned char>
&I,
const
vpColor
&color,
unsigned
int
thickness = 1)
const
;
134
140
const
std::vector<vpImagePoint> &
getCorners
()
const
{
return
_corners
; }
141
148
inline
double
getArea
()
const
{
return
this->
_area
; }
149
156
inline
vpImagePoint
getCenter
()
const
{
return
this->
_center
; }
157
164
inline
vpRect
getBoundingBox
()
const
{
return
_bbox
; }
165
166
//###################
167
// Static Functions
168
//###################
169
static
bool
isInside(
const
std::vector<vpImagePoint> &roi,
const
double
&i,
const
double
&j,
170
const
PointInPolygonMethod &method = PnPolyRayCasting);
171
172
protected
:
173
void
init(
const
std::vector<vpImagePoint> &corners);
174
void
init(
const
std::list<vpImagePoint> &corners);
175
void
updateArea();
176
void
updateCenter();
177
void
updateBoundingBox();
178
179
protected
:
181
std::vector<vpImagePoint>
_corners
;
184
vpImagePoint
_center
;
186
double
_area
;
189
bool
_goodPoly
;
191
vpRect
_bbox
;
192
193
private
:
194
bool
testIntersectionSegments(
const
vpImagePoint
&ip1,
const
vpImagePoint
&ip2,
const
vpImagePoint
&ip3,
195
const
vpImagePoint
&ip4)
const
;
196
void
precalcValuesPnPoly();
197
198
std::vector<double> m_PnPolyConstants;
199
std::vector<double> m_PnPolyMultiples;
200
};
201
END_VISP_NAMESPACE
202
#endif
vpCameraParameters
Generic class defining intrinsic camera parameters.
Definition
vpCameraParameters.h:311
vpColor
Class to define RGB colors available for display functionalities.
Definition
vpColor.h:157
vpColor::red
static const vpColor red
Definition
vpColor.h:198
vpImagePoint
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition
vpImagePoint.h:82
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:131
vpPolygon
Defines a generic 2D polygon.
Definition
vpPolygon.h:103
vpPolygon::_goodPoly
bool _goodPoly
Definition
vpPolygon.h:189
vpPolygon::getBoundingBox
vpRect getBoundingBox() const
Definition
vpPolygon.h:164
vpPolygon::getCenter
vpImagePoint getCenter() const
Definition
vpPolygon.h:156
vpPolygon::getCorners
const std::vector< vpImagePoint > & getCorners() const
Definition
vpPolygon.h:140
vpPolygon::_center
vpImagePoint _center
Definition
vpPolygon.h:184
vpPolygon::getArea
double getArea() const
Definition
vpPolygon.h:148
vpPolygon::_bbox
vpRect _bbox
Bounding box containing the polygon.
Definition
vpPolygon.h:191
vpPolygon::PointInPolygonMethod
PointInPolygonMethod
Definition
vpPolygon.h:106
vpPolygon::PnPolyRayCasting
@ PnPolyRayCasting
Definition
vpPolygon.h:108
vpPolygon::PnPolySegmentIntersection
@ PnPolySegmentIntersection
Definition
vpPolygon.h:107
vpPolygon::_corners
std::vector< vpImagePoint > _corners
Collection of image points containing the corners.
Definition
vpPolygon.h:181
vpPolygon::vpPolygon
vpPolygon()
Definition
vpPolygon.cpp:114
vpPolygon::_area
double _area
Area of the polygon.
Definition
vpPolygon.h:186
vpRect
Defines a rectangle in the plane.
Definition
vpRect.h:79
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
core
include
visp3
core
vpPolygon.h
Generated by
1.17.0