42 #include <visp3/core/vpConfig.h>
44 #if VISP_HAVE_OPENCV_VERSION >= 0x020300
45 #include <opencv2/imgproc/imgproc.hpp>
48 #include <visp3/tt/vpTemplateTrackerZone.h>
55 : Zone(), min_x(-1), min_y(-1), max_x(-1), max_y(-1)
63 : Zone(), min_x(-1), min_y(-1), max_x(-1), max_y(-1)
116 std::vector<vpImagePoint> vip;
128 if (vip.size() > 1) {
134 if(vip.size() % 3 ==2)
137 else if(vip.size() % 3 ==0) {
172 if(vip.size() == 3) {
175 else if(vip.size() == 4) {
176 std::vector<vpImagePoint> vip_delaunay;
177 vip_delaunay.push_back(vip[0]);
178 vip_delaunay.push_back(vip[1]);
179 vip_delaunay.push_back(vip[2]);
180 vip_delaunay.push_back(vip[2]);
181 vip_delaunay.push_back(vip[3]);
182 vip_delaunay.push_back(vip[0]);
186 #if VISP_HAVE_OPENCV_VERSION >= 0x020300
189 for(
size_t i=0; i< vip.size(); i++) {
190 cv::Point2f fp((
float)vip[i].get_u(), (
float)vip[i].get_v());
196 std::vector<cv::Vec6f> triangleList;
197 subdiv.getTriangleList(triangleList);
202 std::vector<vpImagePoint> vip_delaunay;
203 for(
size_t i = 0; i < triangleList.size(); i++ ) {
204 cv::Vec6f t = triangleList[i];
205 std::vector<vpImagePoint> p(3);
207 p[0].set_uv(t[0], t[1]);
208 p[1].set_uv(t[2], t[3]);
209 p[2].set_uv(t[4], t[5]);
211 if (p[0].inRectangle(rect) && p[1].inRectangle(rect) && p[2].inRectangle(rect)) {
212 vip_delaunay.push_back(p[0]);
213 vip_delaunay.push_back(p[1]);
214 vip_delaunay.push_back(p[2]);
226 for(
unsigned int i=0; i<vip.size(); i+=3) {
274 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
275 for(Iterateurvecteur=
Zone.begin();Iterateurvecteur!=
Zone.end();++Iterateurvecteur)
277 if(Iterateurvecteur->inTriangle(i,j))
290 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
291 for(Iterateurvecteur=
Zone.begin();Iterateurvecteur!=
Zone.end();++Iterateurvecteur)
293 if(Iterateurvecteur->inTriangle(i,j))
309 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
310 for(Iterateurvecteur=
Zone.begin();Iterateurvecteur!=
Zone.end();++Iterateurvecteur)
312 if(Iterateurvecteur->inTriangle(i,j))
332 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
333 for(Iterateurvecteur=
Zone.begin();Iterateurvecteur!=
Zone.end(); ++Iterateurvecteur)
335 if(Iterateurvecteur->inTriangle(i,j))
408 "Cannot compute the zone center: size = 0")) ;
470 std::vector<vpImagePoint> ip;
471 for (
unsigned int i=0; i <
Zone.size(); i++) {
473 Zone[i].getCorners(ip);
488 std::vector<vpImagePoint> ip;
489 for (
unsigned int i=0; i <
Zone.size(); i++) {
491 Zone[i].getCorners(ip);
518 for (
int i=0 ; i < (int) I.
getHeight() ; i++)
520 for (
int j=0 ; j < (int) I.
getWidth() ; j++)
542 tempZone.
add(TtempDown);
581 double x_center=0,y_center=0;
582 for(
int j=0;j<borne_x;j++)
583 for(
int i=0;i<borne_y;i++)
593 "Cannot compute the zone center: size = 0")) ;
596 x_center=x_center/cpt_pt;
597 y_center=y_center/cpt_pt;
599 center.
set_uv(x_center, y_center);
VISP_EXPORT int wait(double t0, double t)
std::vector< vpTemplateTrackerTriangle > Zone
Vector of triangles that defines the zone.
vpTemplateTrackerTriangle getPyramidDown() const
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
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 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)
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)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
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.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
void setBottomRight(const vpImagePoint &bottomRight)
void fillTriangle(vpImage< unsigned char > &I, unsigned int id, unsigned char gray_level)
static const vpColor blue