45 #include <visp/vpDisplay.h>
46 #include <visp/vpDisplayException.h>
47 #include <visp/vpImageConvert.h>
49 #include <visp/vpPoint.h>
50 #include <visp/vpMeterPixelConversion.h>
51 #include <visp/vpMath.h>
63 : displayHasBeenInitialized(false), windowXPosition(0), windowYPosition(0), width(0), height(0), title_() {}
69 : displayHasBeenInitialized(false), windowXPosition(0), windowYPosition(0), width(0), height(0), title_()
102 const char *fontname )
127 const char *windowtitle )
232 double top = floor(roi.
getTop());
233 double left = floor(roi.
getLeft());
234 double roiheight = floor(roi.
getHeight());
235 double roiwidth = floor(roi.
getWidth());
236 double iheight = (double)(I.
getHeight());
237 double iwidth = (double)(I.
getWidth());
239 if (top < 0 || top > iheight || left < 0 || left > iwidth || top+roiheight > iheight || left+roiwidth > iwidth)
241 vpERROR_TRACE (
"Region of interest outside of the image" ) ;
379 const vpColor &color,
unsigned int thickness)
448 double size,
const vpColor &color,
449 unsigned int thickness )
516 double size,
const vpColor &color,
517 unsigned int thickness)
520 double halfSize = size/2.0;
528 for (
int i = 0; i < 5; i++)
529 pt[i].track ( cMo ) ;
534 for (
int i = 0; i < 4; i++)
568 double size,
const vpColor &color,
569 unsigned int thickness)
572 double halfSize = size/2.0;
580 for (
int i = 0; i < 5; i++)
581 pt[i].track ( cMo ) ;
586 for (
int i = 0; i < 4; i++)
607 unsigned int w,
unsigned int h,
608 unsigned int thickness )
637 unsigned int w,
unsigned int h,
638 unsigned int thickness )
666 int i1,
int j1,
int i2,
int j2,
668 unsigned int w,
unsigned int h,
669 unsigned int thickness)
704 int i1,
int j1,
int i2,
int j2,
706 unsigned int w,
unsigned int h,
707 unsigned int thickness)
814 int i,
int j,
const char *
string,
852 int i,
int j,
const char *
string,
954 int i,
int j,
const std::string &s,
991 int i,
int j,
const std::string &s,
1026 unsigned int thickness)
1056 unsigned int thickness )
1085 int i,
int j,
unsigned int radius,
1088 unsigned int thickness)
1123 int i,
int j,
unsigned int radius,
1126 unsigned int thickness)
1156 unsigned int thickness )
1183 unsigned int thickness )
1208 unsigned int size,
const vpColor &color,
1209 unsigned int thickness )
1239 unsigned int size,
const vpColor &color,
1240 unsigned int thickness )
1270 unsigned int thickness )
1297 unsigned int thickness )
1322 int i1,
int j1,
int i2,
int j2,
1324 unsigned int thickness )
1357 unsigned int thickness )
1389 unsigned int thickness )
1416 int i1,
int j1,
int i2,
int j2,
1418 unsigned int thickness )
1454 unsigned int thickness )
1487 unsigned int thickness )
1514 unsigned int thickness )
1523 vpRect rect(0, 0, thickness, thickness);
1545 unsigned int thickness )
1554 vpRect rect(0, 0, thickness, thickness);
1577 unsigned int thickness )
1589 vpRect rect(0, 0, thickness, thickness);
1614 unsigned int thickness )
1626 vpRect rect(0, 0, thickness, thickness);
1649 const std::vector<vpImagePoint> &vip,
1651 unsigned int thickness)
1657 for (
unsigned int i=0; i< vip.size(); i++)
1658 ( I.
display )->displayLine ( vip[i], vip[(i+1)%vip.size()], color, thickness );
1678 const std::vector<vpImagePoint> &vip,
1680 unsigned int thickness)
1686 for (
unsigned int i=0; i< vip.size(); i++)
1687 ( I.
display )->displayLine ( vip[i], vip[(i+1)%vip.size()], color, thickness );
1714 unsigned int width,
unsigned int height,
1715 const vpColor &color,
bool fill,
1716 unsigned int thickness)
1752 const vpColor &color,
bool fill,
1753 unsigned int thickness)
1786 const vpColor &color,
bool fill,
1787 unsigned int thickness )
1823 unsigned int width,
unsigned int height,
1825 unsigned int thickness)
1831 double i = center.
get_i();
1832 double j = center.
get_j();
1836 double cosinus = cos(angle);
1837 double sinus = sin(angle);
1838 ipa.
set_u(j + 0.5*width*cosinus + 0.5*height*sinus);
1839 ipa.
set_v(i + 0.5*width*sinus - 0.5*height*cosinus);
1840 ipb.
set_u(j + 0.5*width*cosinus - 0.5*height*sinus);
1841 ipb.
set_v(i + 0.5*width*sinus + 0.5*height*cosinus);
1842 ipc.
set_u(j - 0.5*width*cosinus - 0.5*height*sinus);
1843 ipc.
set_v(i - 0.5*width*sinus + 0.5*height*cosinus);
1844 ipd.
set_u(j - 0.5*width*cosinus + 0.5*height*sinus);
1845 ipd.
set_v(i - 0.5*width*sinus - 0.5*height*cosinus);
1877 unsigned int width,
unsigned int height,
1878 const vpColor &color,
bool fill,
1879 unsigned int thickness)
1913 const vpColor &color,
bool fill,
1914 unsigned int thickness)
1947 const vpColor &color,
bool fill,
1948 unsigned int thickness )
1984 unsigned int width,
unsigned int height,
1986 unsigned int thickness)
1992 double i = center.
get_i();
1993 double j = center.
get_j();
1997 double cosinus = cos(angle);
1998 double sinus = sin(angle);
1999 ipa.
set_u(j + 0.5*width*cosinus + 0.5*height*sinus);
2000 ipa.
set_v(i + 0.5*width*sinus - 0.5*height*cosinus);
2001 ipb.
set_u(j + 0.5*width*cosinus - 0.5*height*sinus);
2002 ipb.
set_v(i + 0.5*width*sinus + 0.5*height*cosinus);
2003 ipc.
set_u(j - 0.5*width*cosinus - 0.5*height*sinus);
2004 ipc.
set_v(i - 0.5*width*sinus + 0.5*height*cosinus);
2005 ipd.
set_u(j - 0.5*width*cosinus + 0.5*height*sinus);
2006 ipd.
set_v(i - 0.5*width*sinus - 0.5*height*cosinus);
2040 unsigned int width,
unsigned int height,
2041 const vpColor &color,
bool fill,
2042 unsigned int thickness)
2053 color, fill, thickness ) ;
2079 unsigned int i,
unsigned int j,
float angle,
2080 unsigned int width,
unsigned int height,
2081 const vpColor &color,
unsigned int thickness)
2089 float cosinus = cos(angle);
2090 float sinus = sin(angle);
2091 ipa.
set_u(j + 0.5*width*cosinus + 0.5*height*sinus);
2092 ipa.
set_v(i + 0.5*width*sinus - 0.5*height*cosinus);
2093 ipb.
set_u(j + 0.5*width*cosinus - 0.5*height*sinus);
2094 ipb.
set_v(i + 0.5*width*sinus + 0.5*height*cosinus);
2095 ipc.
set_u(j - 0.5*width*cosinus - 0.5*height*sinus);
2096 ipc.
set_v(i - 0.5*width*sinus + 0.5*height*cosinus);
2097 ipd.
set_u(j - 0.5*width*cosinus + 0.5*height*sinus);
2098 ipd.
set_v(i - 0.5*width*sinus - 0.5*height*cosinus);
2132 unsigned int width,
unsigned int height,
2133 const vpColor &color,
bool fill,
2134 unsigned int thickness)
2145 color, fill, thickness ) ;
2170 unsigned int i,
unsigned int j,
float angle,
2171 unsigned int width,
unsigned int height,
2172 const vpColor &color,
unsigned int thickness)
2180 float cosinus = cos(angle);
2181 float sinus = sin(angle);
2182 ipa.
set_u(j + 0.5*width*cosinus + 0.5*height*sinus);
2183 ipa.
set_v(i + 0.5*width*sinus - 0.5*height*cosinus);
2184 ipb.
set_u(j + 0.5*width*cosinus - 0.5*height*sinus);
2185 ipb.
set_v(i + 0.5*width*sinus + 0.5*height*cosinus);
2186 ipc.
set_u(j - 0.5*width*cosinus - 0.5*height*sinus);
2187 ipc.
set_v(i - 0.5*width*sinus + 0.5*height*cosinus);
2188 ipd.
set_u(j - 0.5*width*cosinus + 0.5*height*sinus);
2189 ipd.
set_v(i - 0.5*width*sinus - 0.5*height*cosinus);
2430 double top = floor(roi.
getTop());
2431 double left = floor(roi.
getLeft());
2432 double roiheight = floor(roi.
getHeight());
2433 double roiwidth = floor(roi.
getWidth());
2434 double iheight = (double)(I.
getHeight());
2435 double iwidth = (double)(I.
getWidth());
2437 if (top < 0 || top >= iheight || left < 0 || left >= iwidth || top+roiheight >= iheight || left+roiwidth >= iwidth)
2439 vpERROR_TRACE (
"Region of interest outside of the image" ) ;
2441 "Region of interest outside of the image" ) ) ;
2653 return ( I.
display )->getClick(blocking) ;
2691 return ( I.
display )->getClick ( ip, blocking ) ;
2732 return ( I.
display )->getClick ( ip, button, blocking ) ;
2824 return ( I.
display )->getClickUp ( ip, button, blocking ) ;
2977 return ( I.
display )->getKeyboardEvent ( blocking ) ;
3079 char *
string,
bool blocking)
3085 return ( I.
display )->getKeyboardEvent (
string, blocking ) ;
3113 return ( I.
display )->getPointerMotionEvent ( ip ) ;
3142 return ( I.
display )->getPointerPosition ( ip ) ;
3172 return ( I.
display )->getClick(blocking) ;
3209 return ( I.
display )->getClick ( ip, blocking ) ;
3249 return ( I.
display )->getClick ( ip, button, blocking ) ;
3290 return ( I.
display )->getClickUp ( ip, button, blocking ) ;
3392 return ( I.
display )->getKeyboardEvent ( blocking ) ;
3492 char *
string,
bool blocking)
3498 return ( I.
display )->getKeyboardEvent (
string, blocking ) ;
3525 return ( I.
display )->getPointerMotionEvent ( ip ) ;
3552 return ( I.
display )->getPointerPosition ( ip ) ;
3610 const double &coef1,
const double &coef2,
const double &coef3,
3611 bool use_centered_moments,
3613 unsigned int thickness)
3669 const double &coef1,
const double &coef2,
const double &coef3,
3670 const double &theta1,
const double &theta2,
bool use_centered_moments,
3672 unsigned int thickness)
3682 j1 = j2 = i1 = i2 = 0 ;
3683 double a=0., b=0., e=0.;
3685 double mu20_p = coef1;
3686 double mu11_p = coef2;
3687 double mu02_p = coef3;
3689 if (use_centered_moments) {
3690 if (std::fabs(mu11_p) > std::numeric_limits<double>::epsilon()) {
3693 a = sqrt((mu20_p + mu02_p + val_p)/2);
3694 b = sqrt((mu20_p + mu02_p - val_p)/2);
3696 e = (mu02_p - mu20_p + val_p)/(2*mu11_p);
3714 double t = (a-b)/(a+b);
3717 int nbpoints = (int)(floor(circumference/5));
3720 double incr = 2*M_PI / nbpoints ;
3722 double smallalpha = theta1;
3723 double highalpha = theta2;
3727 double k = smallalpha ;
3734 iP11.
set_j ( center.
get_j() + ce *j1 - se *i1 );
3735 iP11.
set_i ( center.
get_i() + se *j1 + ce *i1 );
3737 while (k+incr<highalpha+incr)
3739 j2 = a *cos(k+incr) ;
3740 i2 = b *sin(k+incr) ;
3743 iP22.
set_j ( center.
get_j() + ce *j2 - se *i2 );
3744 iP22.
set_i ( center.
get_i() + se *j2 + ce *i2 );
3809 const double &coef1,
const double &coef2,
const double &coef3,
3810 bool use_centered_moments,
3812 unsigned int thickness)
3868 const double &coef1,
const double &coef2,
const double &coef3,
3869 const double &theta1,
const double &theta2,
bool use_centered_moments,
3871 unsigned int thickness)
3881 j1 = j2 = i1 = i2 = 0 ;
3882 double a=0., b=0., e=0.;
3884 double mu20_p = coef1;
3885 double mu11_p = coef2;
3886 double mu02_p = coef3;
3888 if (use_centered_moments) {
3889 if (std::fabs(mu11_p) > std::numeric_limits<double>::epsilon()) {
3892 a = sqrt((mu20_p + mu02_p + val_p)/2);
3893 b = sqrt((mu20_p + mu02_p - val_p)/2);
3895 e = (mu02_p - mu20_p + val_p)/(2*mu11_p);
3913 double t = (a-b)/(a+b);
3916 int nbpoints = (int)(floor(circumference/5));
3919 double incr = 2*M_PI / nbpoints ;
3921 double smallalpha = theta1;
3922 double highalpha = theta2;
3926 double k = smallalpha ;
3933 iP11.
set_j ( center.
get_j() + ce *j1 - se *i1 );
3934 iP11.
set_i ( center.
get_i() + se *j1 + ce *i1 );
3936 while (k+incr<highalpha+incr)
3938 j2 = a *cos(k+incr) ;
3939 i2 = b *sin(k+incr) ;
3942 iP22.
set_j ( center.
get_j() + ce *j2 - se *i2 );
3943 iP22.
set_i ( center.
get_i() + se *j2 + ce *i2 );
static void displayCamera(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, const vpColor &color, unsigned int thickness)
virtual void displayCircle(const vpImagePoint ¢er, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1)=0
static void displayEllipse(const vpImage< unsigned char > &I, const vpImagePoint ¢er, const double &coef1, const double &coef2, const double &coef3, bool use_centered_moments, const vpColor &color, unsigned int thickness=1)
virtual void displayImage(const vpImage< unsigned char > &I)=0
Class that defines generic functionnalities for display.
virtual void displayArrow(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1)=0
static void close(vpImage< unsigned char > &I)
unsigned int getWidth() const
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
static void displayPolygon(const vpImage< unsigned char > &I, const std::vector< vpImagePoint > &vip, const vpColor &color, unsigned int thickness=1)
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
Point coordinates conversion from normalized coordinates in meter to pixel coordinates ...
Class to define colors available for display functionnalities.
virtual void clearDisplay(const vpColor &color=vpColor::white)=0
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
static const vpColor none
virtual bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)=0
error that can be emited by ViSP classes.
void track(const vpHomogeneousMatrix &cMo)
virtual bool getPointerMotionEvent(vpImagePoint &ip)=0
bool displayHasBeenInitialized
display has been initialized
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
vpImagePoint getTopLeft() const
Class that defines what is a point.
virtual void flushDisplay()=0
void set_i(const double ii)
virtual bool getPointerPosition(vpImagePoint &ip)=0
virtual bool getKeyboardEvent(bool blocking=true)=0
void set_u(const double u)
virtual void setWindowPosition(int winx, int winy)=0
static double sqr(double x)
static void display(const vpImage< unsigned char > &I)
virtual void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)=0
void set_v(const double v)
Generic class defining intrinsic camera parameters.
virtual void displayImageROI(const vpImage< unsigned char > &I, const vpImagePoint &iP, const unsigned int width, const unsigned int height)=0
virtual void setTitle(const char *title)=0
void moveCenter(double x, double y)
virtual void setFont(const char *font)=0
static void displayFrame(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, const vpColor &color=vpColor::none, unsigned int thickness=1)
virtual void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)=0
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
static double rad(double deg)
virtual void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
void set_j(const double jj)
virtual void closeDisplay()=0
virtual void displayCharString(const vpImagePoint &ip, const char *text, const vpColor &color=vpColor::green)=0
int windowXPosition
display position
static void setBackground(const vpImage< unsigned char > &I, const vpColor &color)
unsigned int getHeight() const
Defines a rectangle in the plane.
static void flushROI(const vpImage< unsigned char > &I, const vpRect &roi)
static void displayROI(const vpImage< unsigned char > &I, const vpRect &roi)
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
virtual void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height)=0
int windowYPosition
display position
virtual void displayPoint(const vpImagePoint &ip, const vpColor &color)=0
static const vpColor blue
void setWorldCoordinates(const double ox, const double oy, const double oz)
Set the point world coordinates. We mean here the coordinates of the point in the object frame...