46 #include <visp/vpPolygon.h>
47 #include <visp/vpException.h>
48 #include <visp/vpDisplay.h>
49 #include <visp/vpMeterPixelConversion.h>
50 #include <visp/vpNoise.h>
62 std::vector<vpImagePoint> corners;
78 if(corners.size() < 3){
146 std::vector<vpImagePoint> ipCorners(corners.size());
147 for(
unsigned int i=0; i<corners.size(); ++i){
165 std::vector<vpImagePoint> cornersClick;
171 cornersClick.push_back(ip);
220 double denominator = di1 * dj2 - dj1 * di2;
222 if(fabs(denominator) < std::numeric_limits<double>::epsilon()){
226 double alpha = - ( ( ip1.
get_i() - ip3.
get_i() ) * dj2 + di2 * ( ip3.
get_j() - ip1.
get_j())) / denominator;
227 if(alpha < 0 || alpha >= 1){
231 double beta = - (di1 * (ip3.
get_j() - ip1.
get_j() ) + dj1 * (ip1.
get_i() - ip3.
get_i()) ) / denominator;
232 if(beta < 0 || beta >= 1){
251 infPoint.
set_i( infPoint.
get_i() + 1000 * generator());
252 infPoint.
set_j( infPoint.
get_j() + 1000 * generator());
254 unsigned int nbinterscetion = 0;
255 for(
unsigned int i=0; i<
_corners.size(); ++i){
258 bool intersection =
false;
266 intersection = testIntersectionSegments(ip1, ip2, ip, infPoint );
276 return ((nbinterscetion%2)==1);
300 for(
unsigned int i=0; i<
_corners.size(); ++i){
301 unsigned int i_p_1 = ( i+1 ) %
_corners.size();
335 for(
unsigned int i=0; i<(
_corners.size()-1); ++i){
343 for(
unsigned int i=0; i<
_corners.size(); ++i){
344 unsigned int i_p_1 = ( i+1 ) %
_corners.size();
374 std::set<double> setI;
375 std::set<double> setJ;
376 for(
unsigned int i=0; i<
_corners.size(); ++i){
381 std::set<double>::const_iterator iterI = setI.end();
382 std::set<double>::const_iterator iterJ = setJ.end();
405 const unsigned int N = (
unsigned int)
_corners.size();
406 for(
unsigned int i=0; i<N; ++i){
void set_j(const double j)
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
Point coordinates conversion from normalized coordinates in meter to pixel coordinates ...
Class to define colors available for display functionnalities.
void init(const std::vector< vpImagePoint > &corners)
void set_i(const double i)
error that can be emited by ViSP classes.
vpPolygon & operator=(const vpPolygon &poly)
void display(const vpImage< unsigned char > &I, const vpColor &color, unsigned int thickness=1)
vpRect _bbox
Boumding box containing the polygon.
vpImagePoint _center
Center of the polygon. It is automatically computed when the corners are set.
static void flush(const vpImage< unsigned char > &I)
bool isInside(const vpImagePoint &iP)
Defines a generic 2D polygon.
virtual void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)=0
Generic class defining intrinsic camera parameters.
void setTopLeft(const vpImagePoint &topLeft)
std::vector< vpImagePoint > _corners
Collection of image points containing the corners.
void initClick(const vpImage< unsigned char > &I)
bool _goodPoly
Flag to indicate whether the polygon is a good polygon (ie. it has more than two corners, ...)
virtual bool getClick(bool blocking=true)=0
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Class for generating random numbers with uniform probability density.
virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
void setBottomRight(const vpImagePoint &bottomRight)
void buildFrom(const std::vector< vpImagePoint > &corners)
double _area
Area of the polygon.