43 #include <visp3/core/vpConfig.h> 45 #if VISP_HAVE_OPENCV_VERSION >= 0x020300 46 #include <opencv2/imgproc/imgproc.hpp> 49 #include <visp3/tt/vpTemplateTrackerZone.h> 115 std::vector<vpImagePoint> vip;
127 if (vip.size() > 1) {
132 if (vip.size() % 3 == 2)
135 else if (vip.size() % 3 == 0) {
172 if (vip.size() == 3) {
174 }
else if (vip.size() == 4) {
175 std::vector<vpImagePoint> vip_delaunay;
176 vip_delaunay.push_back(vip[0]);
177 vip_delaunay.push_back(vip[1]);
178 vip_delaunay.push_back(vip[2]);
179 vip_delaunay.push_back(vip[2]);
180 vip_delaunay.push_back(vip[3]);
181 vip_delaunay.push_back(vip[0]);
184 #if VISP_HAVE_OPENCV_VERSION >= 0x020300 187 for (
size_t i = 0; i < vip.size(); i++) {
188 cv::Point2f fp((
float)vip[i].get_u(), (
float)vip[i].get_v());
194 std::vector<cv::Vec6f> triangleList;
195 subdiv.getTriangleList(triangleList);
200 std::vector<vpImagePoint> vip_delaunay;
201 for (
size_t i = 0; i < triangleList.size(); i++) {
202 cv::Vec6f t = triangleList[i];
203 std::vector<vpImagePoint> p(3);
205 p[0].set_uv(t[0], t[1]);
206 p[1].set_uv(t[2], t[3]);
207 p[2].set_uv(t[4], t[5]);
209 if (p[0].inRectangle(rect) && p[1].inRectangle(rect) && p[2].inRectangle(rect)) {
210 vip_delaunay.push_back(p[0]);
211 vip_delaunay.push_back(p[1]);
212 vip_delaunay.push_back(p[2]);
223 for (
unsigned int i = 0; i < vip.size(); i += 3) {
272 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
273 for (Iterateurvecteur =
Zone.begin(); Iterateurvecteur !=
Zone.end(); ++Iterateurvecteur) {
274 if (Iterateurvecteur->inTriangle(i, j))
288 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
289 for (Iterateurvecteur =
Zone.begin(); Iterateurvecteur !=
Zone.end(); ++Iterateurvecteur) {
290 if (Iterateurvecteur->inTriangle(i, j))
306 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
307 for (Iterateurvecteur =
Zone.begin(); Iterateurvecteur !=
Zone.end(); ++Iterateurvecteur) {
308 if (Iterateurvecteur->inTriangle(i, j)) {
327 std::vector<vpTemplateTrackerTriangle>::const_iterator Iterateurvecteur;
328 for (Iterateurvecteur =
Zone.begin(); Iterateurvecteur !=
Zone.end(); ++Iterateurvecteur) {
329 if (Iterateurvecteur->inTriangle(i, j)) {
448 std::vector<vpImagePoint> ip;
449 for (
unsigned int i = 0; i <
Zone.size(); i++) {
451 Zone[i].getCorners(ip);
465 std::vector<vpImagePoint> ip;
466 for (
unsigned int i = 0; i <
Zone.size(); i++) {
468 Zone[i].getCorners(ip);
492 for (
int i = 0; i < (int)I.
getHeight(); i++) {
493 for (
int j = 0; j < (int)I.
getWidth(); j++) {
495 I[i][j] = gray_level;
512 tempZone.
add(TtempDown);
550 double x_center = 0, y_center = 0;
551 for (
int j = 0; j < borne_x; j++)
552 for (
int i = 0; i < borne_y; i++)
563 x_center = x_center / cpt_pt;
564 y_center = y_center / cpt_pt;
566 center.
set_uv(x_center, y_center);
Used to indicate that a value is not in the allowed range.
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.
virtual ~vpTemplateTrackerZone()
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)
Function not implemented.
void setBottomRight(const vpImagePoint &bottomRight)
void fillTriangle(vpImage< unsigned char > &I, unsigned int id, unsigned char gray_level)
static const vpColor blue