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(vip.size() == 3) {
178 else if(vip.size() == 4) {
179 std::vector<vpImagePoint> vip_delaunay;
180 vip_delaunay.push_back(vip[0]);
181 vip_delaunay.push_back(vip[1]);
182 vip_delaunay.push_back(vip[2]);
183 vip_delaunay.push_back(vip[2]);
184 vip_delaunay.push_back(vip[3]);
185 vip_delaunay.push_back(vip[0]);
189 #if VISP_HAVE_OPENCV_VERSION >= 0x020300
192 for(
size_t i=0; i< vip.size(); i++) {
193 cv::Point2f fp((
float)vip[i].get_u(), (
float)vip[i].get_v());
199 std::vector<cv::Vec6f> triangleList;
200 subdiv.getTriangleList(triangleList);
205 std::vector<vpImagePoint> vip_delaunay;
206 for(
size_t i = 0; i < triangleList.size(); i++ ) {
207 cv::Vec6f t = triangleList[i];
208 std::vector<vpImagePoint> p(3);
210 p[0].set_uv(t[0], t[1]);
211 p[1].set_uv(t[2], t[3]);
212 p[2].set_uv(t[4], t[5]);
214 if (p[0].inRectangle(rect) && p[1].inRectangle(rect) && p[2].inRectangle(rect)) {
215 vip_delaunay.push_back(p[0]);
216 vip_delaunay.push_back(p[1]);
217 vip_delaunay.push_back(p[2]);
229 for(
unsigned int i=0; i<vip.size(); i+=3) {
277 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
278 for(Iterateurvecteur=
Zone.begin();Iterateurvecteur!=
Zone.end();Iterateurvecteur++)
280 if(Iterateurvecteur->inTriangle(i,j))
293 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
294 for(Iterateurvecteur=
Zone.begin();Iterateurvecteur!=
Zone.end();Iterateurvecteur++)
296 if(Iterateurvecteur->inTriangle(i,j))
312 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
313 for(Iterateurvecteur=
Zone.begin();Iterateurvecteur!=
Zone.end();Iterateurvecteur++)
315 if(Iterateurvecteur->inTriangle(i,j))
335 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
336 for(Iterateurvecteur=
Zone.begin();Iterateurvecteur!=
Zone.end();Iterateurvecteur++)
338 if(Iterateurvecteur->inTriangle(i,j))
411 "Cannot compute the zone center: size = 0")) ;
473 std::vector<vpImagePoint> ip;
474 for (
unsigned int i=0; i <
Zone.size(); i++) {
476 Zone[i].getCorners(ip);
491 std::vector<vpImagePoint> ip;
492 for (
unsigned int i=0; i <
Zone.size(); i++) {
494 Zone[i].getCorners(ip);
521 for (
int i=0 ; i < (int) I.
getHeight() ; i++)
523 for (
int j=0 ; j < (int) I.
getWidth() ; j++)
545 tempZone.
add(TtempDown);
584 double x_center=0,y_center=0;
585 for(
int j=0;j<borne_x;j++)
586 for(
int i=0;i<borne_y;i++)
596 "Cannot compute the zone center: size = 0")) ;
599 x_center=x_center/cpt_pt;
600 y_center=y_center/cpt_pt;
602 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 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