45 #include <visp/vpConfig.h>
47 #if VISP_HAVE_OPENCV_VERSION >= 0x020300
48 #include <opencv2/imgproc/imgproc.hpp>
51 #include <visp/vpTemplateTrackerZone.h>
58 : Zone(), min_x(-1), min_y(-1), max_x(-1), max_y(-1)
66 : Zone(), min_x(-1), min_y(-1), max_x(-1), max_y(-1)
119 std::vector<vpImagePoint> vip;
131 if (vip.size() > 1) {
137 if(vip.size() % 3 ==2)
140 else if(vip.size() % 3 ==0) {
175 #if VISP_HAVE_OPENCV_VERSION >= 0x020300
178 for(
size_t i=0; i< vip.size(); i++) {
179 cv::Point2f fp((
float)vip[i].get_u(), (
float)vip[i].get_v());
180 std::cout <<
"Click point: " << vip[i] << std::endl;
185 std::vector<cv::Vec6f> triangleList;
186 subdiv.getTriangleList(triangleList);
191 std::vector<vpImagePoint> vip_delaunay;
193 for(
size_t i = 0; i < triangleList.size(); i++ ) {
194 cv::Vec6f t = triangleList[i];
195 std::vector<vpImagePoint> p(3);
197 p[0].set_uv(t[0], t[1]);
198 p[1].set_uv(t[2], t[3]);
199 p[2].set_uv(t[4], t[5]);
200 if (p[0].inRectangle(rect) && p[1].inRectangle(rect) && p[2].inRectangle(rect)) {
201 vip_delaunay.push_back(p[0]);
202 vip_delaunay.push_back(p[1]);
203 vip_delaunay.push_back(p[2]);
214 for(
unsigned int i=0; i<vip.size(); i+=3) {
262 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
263 for(Iterateurvecteur=
Zone.begin();Iterateurvecteur!=
Zone.end();Iterateurvecteur++)
265 if(Iterateurvecteur->inTriangle(i,j))
278 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
279 for(Iterateurvecteur=
Zone.begin();Iterateurvecteur!=
Zone.end();Iterateurvecteur++)
281 if(Iterateurvecteur->inTriangle(i,j))
297 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
298 for(Iterateurvecteur=
Zone.begin();Iterateurvecteur!=
Zone.end();Iterateurvecteur++)
300 if(Iterateurvecteur->inTriangle(i,j))
320 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
321 for(Iterateurvecteur=
Zone.begin();Iterateurvecteur!=
Zone.end();Iterateurvecteur++)
323 if(Iterateurvecteur->inTriangle(i,j))
396 "Cannot compute the zone center: size = 0")) ;
458 std::vector<vpImagePoint> ip;
459 for (
unsigned int i=0; i <
Zone.size(); i++) {
461 Zone[i].getCorners(ip);
476 std::vector<vpImagePoint> ip;
477 for (
unsigned int i=0; i <
Zone.size(); i++) {
479 Zone[i].getCorners(ip);
506 for (
int i=0 ; i < (int) I.
getHeight() ; i++)
508 for (
int j=0 ; j < (int) I.
getWidth() ; j++)
530 tempZone.
add(TtempDown);
569 double x_center=0,y_center=0;
570 for(
int j=0;j<borne_x;j++)
571 for(
int i=0;i<borne_y;i++)
581 "Cannot compute the zone center: size = 0")) ;
584 x_center=x_center/cpt_pt;
585 y_center=y_center/cpt_pt;
587 center.
set_uv(x_center, y_center);
std::vector< vpTemplateTrackerTriangle > Zone
Vector of triangles that defines the zone.
vpTemplateTrackerTriangle getPyramidDown() const
void getTriangle(unsigned int i, vpTemplateTrackerTriangle &T) const
unsigned int getWidth() const
int max_y
Bounding box parameter.
Class to define colors available for display functionnalities.
vpRect getBoundingBox() const
int min_x
Bounding box parameter.
error that can be emited by ViSP classes.
void initClick(const vpImage< unsigned char > &I, bool delaunay=false)
void display(const vpImage< unsigned char > &I, const vpColor &col=vpColor::green, const unsigned int thickness=3)
vpImagePoint getCenter() const
static int wait(double t0, double t)
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
void copy(const vpTemplateTrackerZone &z)
void add(const vpTemplateTrackerTriangle &t)
unsigned int getNbTriangle() const
vpTemplateTrackerZone & operator=(const vpTemplateTrackerZone &z)
virtual void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)=0
bool inTriangle(const vpImagePoint &ip) const
void initFromPoints(const vpImage< unsigned char > &I, const std::vector< vpImagePoint > &ip, bool delaunay=false)
int min_y
Bounding box parameter.
void setTopLeft(const vpImagePoint &topLeft)
bool inZone(const int &i, const int &j) const
int max_x
Bounding box parameter.
vpTemplateTrackerZone getPyramidDown() const
unsigned int getHeight() const
void set_uv(const double u, const double v)
Defines a rectangle in the plane.
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 ...
virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
void setBottomRight(const vpImagePoint &bottomRight)
void fillTriangle(vpImage< unsigned char > &I, unsigned int id, unsigned char gray_level)
static const vpColor blue