43 #include <visp3/core/vpConfig.h>
49 #include <visp3/mbt/vpMbtPolygon.h>
50 #include <visp3/core/vpPolygon.h>
56 : index(-1), isvisible(false), isappearing(false),
57 useLod(false), minLineLengthThresh(50.0), minPolygonAreaThresh(2500.0), name(
""),
63 :
vpPolygon3D(mbtp), index(mbtp.index), isvisible(mbtp.isvisible), isappearing(mbtp.isappearing),
64 useLod(mbtp.useLod), minLineLengthThresh(mbtp.minLineLengthThresh), minPolygonAreaThresh(mbtp.minPolygonAreaThresh), name(mbtp.name),
65 hasOrientation(mbtp.hasOrientation)
123 std::vector<vpImagePoint> roiImagePoints;
126 if (roiImagePoints.size() == 2) {
127 double x1 = roiImagePoints[0].get_u();
128 double y1 = roiImagePoints[0].get_v();
129 double x2 = roiImagePoints[1].get_u();
130 double y2 = roiImagePoints[1].get_v();
131 double length = std::sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
163 for(
unsigned int i = 0; i<
nbpt; i++) {
164 currentVertex =
p[i].
cP;
165 nextVertex =
p[(i+1) % nbpt].cP;
167 faceNormal[0] += (currentVertex[1] - nextVertex[1]) * (currentVertex[2] + nextVertex[2]);
168 faceNormal[1] += (currentVertex[2] - nextVertex[2]) * (currentVertex[0] + nextVertex[0]);
169 faceNormal[2] += (currentVertex[0] - nextVertex[0]) * (currentVertex[1] + nextVertex[1]);
175 for (
unsigned int i = 0; i <
nbpt; i += 1){
180 e4[0] = -pt.
get_X() / (double)nbpt;
181 e4[1] = -pt.
get_Y() / (double)nbpt;
182 e4[2] = -pt.
get_Z() / (double)nbpt;
189 if( angle < alpha || (modulo && (M_PI - angle) < alpha)) {
199 std::vector<vpImagePoint> roiImagePoints;
203 double area = roiPolygon.
getArea();
219 else if (modulo && (M_PI - angle) < alpha+
vpMath::rad(1) ){
void getRoiClipped(const vpCameraParameters &cam, std::vector< vpImagePoint > &roi)
Implements a 3D polygon with render functionnalities like clipping.
std::string name
Name of the polygon.
unsigned int getWidth() const
Implementation of an homogeneous matrix and operations on such kind of matrices.
bool hasOrientation
Boolean that specify if the polygon has an orientation or not (mainly used for cylinders) ...
int index
Index of the polygon. Cannot be unsigned int because default value is -1.
vpPoint * p
corners in the object frame
vpMbtPolygon & operator=(const vpMbtPolygon &mbtp)
void set_X(const double X)
Set the point X coordinate in the camera frame.
Class that defines what is a point.
Defines a generic 2D polygon.
void changeFrame(const vpHomogeneousMatrix &cMo)
vpColVector & normalize()
void set_Z(const double Z)
Set the point Z coordinate in the camera frame.
double minLineLengthThresh
Threshold for minimum line length in pixel to consider if the line is visible or not in LOD case...
Implementation of a polygon of the model used by the model-based tracker.
void computePolygonClipped(const vpCameraParameters &cam=vpCameraParameters())
Generic class defining intrinsic camera parameters.
void set_Y(const double Y)
Set the point Y coordinate in the camera frame.
double minPolygonAreaThresh
Threshold for minimum polygon area in pixel to consider if the polygon is visible or not in LOD case...
vpPolygon3D & operator=(const vpPolygon3D &mbtp)
double get_Y() const
Get the point Y coordinate in the camera frame.
static double rad(double deg)
double get_Z() const
Get the point Z coordinate in the camera frame.
unsigned int nbpt
Number of points used to define the polygon.
bool isappearing
flag to specify whether the face is appearing or not
bool useLod
Flag to specify if the visibility of the polygon depends also of the current level of detail (LOD) ...
Implementation of column vector and the associated operations.
void setLod(const bool use_lod)
static double dotProd(const vpColVector &a, const vpColVector &b)
unsigned int getHeight() const
unsigned int clippingFlag
Clipping flag.
bool isvisible
flag to specify whether the face is visible or not
double get_X() const
Get the point X coordinate in the camera frame.
void computeFov(const unsigned int &w, const unsigned int &h)