41 #include <visp3/core/vpDisplay.h>
42 #include <visp3/core/vpDisplayException.h>
43 #include <visp3/core/vpImageConvert.h>
45 #include <visp3/core/vpPoint.h>
46 #include <visp3/core/vpMeterPixelConversion.h>
47 #include <visp3/core/vpMath.h>
59 : displayHasBeenInitialized(false), windowXPosition(0), windowYPosition(0), width(0), height(0), title_() {}
65 : displayHasBeenInitialized(false), windowXPosition(0), windowYPosition(0), width(0), height(0), title_()
98 const char *fontname )
123 const char *windowtitle )
228 double top = floor(roi.
getTop());
229 double left = floor(roi.
getLeft());
230 double roiheight = floor(roi.
getHeight());
231 double roiwidth = floor(roi.
getWidth());
232 double iheight = (double)(I.
getHeight());
233 double iwidth = (double)(I.
getWidth());
235 if (top < 0 || top > iheight || left < 0 || left > iwidth || top+roiheight > iheight || left+roiwidth > iwidth)
237 vpERROR_TRACE (
"Region of interest outside of the image" ) ;
376 double size,
const vpColor &color,
377 unsigned int thickness,
448 double size,
const vpColor &color,
449 unsigned int thickness,
517 double size,
const vpColor &color,
518 unsigned int thickness)
521 double halfSize = size/2.0;
529 for (
int i = 0; i < 5; i++)
530 pt[i].track ( cMo ) ;
535 for (
int i = 0; i < 4; i++)
569 double size,
const vpColor &color,
570 unsigned int thickness)
573 double halfSize = size/2.0;
581 for (
int i = 0; i < 5; i++)
582 pt[i].track ( cMo ) ;
587 for (
int i = 0; i < 4; i++)
608 unsigned int w,
unsigned int h,
609 unsigned int thickness )
638 unsigned int w,
unsigned int h,
639 unsigned int thickness )
667 int i1,
int j1,
int i2,
int j2,
669 unsigned int w,
unsigned int h,
670 unsigned int thickness)
705 int i1,
int j1,
int i2,
int j2,
707 unsigned int w,
unsigned int h,
708 unsigned int thickness)
815 int i,
int j,
const char *
string,
853 int i,
int j,
const char *
string,
955 int i,
int j,
const std::string &s,
992 int i,
int j,
const std::string &s,
1027 unsigned int thickness)
1057 unsigned int thickness )
1086 int i,
int j,
unsigned int radius,
1089 unsigned int thickness)
1124 int i,
int j,
unsigned int radius,
1127 unsigned int thickness)
1157 unsigned int thickness )
1184 unsigned int thickness )
1209 unsigned int size,
const vpColor &color,
1210 unsigned int thickness )
1240 unsigned int size,
const vpColor &color,
1241 unsigned int thickness )
1271 unsigned int thickness )
1298 unsigned int thickness )
1323 int i1,
int j1,
int i2,
int j2,
1325 unsigned int thickness )
1358 unsigned int thickness )
1390 unsigned int thickness )
1417 int i1,
int j1,
int i2,
int j2,
1419 unsigned int thickness )
1455 unsigned int thickness )
1488 unsigned int thickness )
1515 unsigned int thickness )
1524 vpRect rect(0, 0, thickness, thickness);
1546 unsigned int thickness )
1555 vpRect rect(0, 0, thickness, thickness);
1578 unsigned int thickness )
1590 vpRect rect(0, 0, thickness, thickness);
1615 unsigned int thickness )
1627 vpRect rect(0, 0, thickness, thickness);
1650 const std::vector<vpImagePoint> &vip,
1652 unsigned int thickness)
1658 for (
unsigned int i=0; i< vip.size(); i++)
1659 ( I.
display )->displayLine ( vip[i], vip[(i+1)%vip.size()], color, thickness );
1679 const std::vector<vpImagePoint> &vip,
1681 unsigned int thickness)
1687 for (
unsigned int i=0; i< vip.size(); i++)
1688 ( I.
display )->displayLine ( vip[i], vip[(i+1)%vip.size()], color, thickness );
1715 unsigned int width,
unsigned int height,
1716 const vpColor &color,
bool fill,
1717 unsigned int thickness)
1753 const vpColor &color,
bool fill,
1754 unsigned int thickness)
1787 const vpColor &color,
bool fill,
1788 unsigned int thickness )
1824 unsigned int width,
unsigned int height,
1826 unsigned int thickness)
1832 double i = center.
get_i();
1833 double j = center.
get_j();
1837 double cosinus = cos(angle);
1838 double sinus = sin(angle);
1839 ipa.
set_u(j + 0.5*width*cosinus + 0.5*height*sinus);
1840 ipa.
set_v(i + 0.5*width*sinus - 0.5*height*cosinus);
1841 ipb.
set_u(j + 0.5*width*cosinus - 0.5*height*sinus);
1842 ipb.
set_v(i + 0.5*width*sinus + 0.5*height*cosinus);
1843 ipc.
set_u(j - 0.5*width*cosinus - 0.5*height*sinus);
1844 ipc.
set_v(i - 0.5*width*sinus + 0.5*height*cosinus);
1845 ipd.
set_u(j - 0.5*width*cosinus + 0.5*height*sinus);
1846 ipd.
set_v(i - 0.5*width*sinus - 0.5*height*cosinus);
1878 unsigned int width,
unsigned int height,
1879 const vpColor &color,
bool fill,
1880 unsigned int thickness)
1914 const vpColor &color,
bool fill,
1915 unsigned int thickness)
1948 const vpColor &color,
bool fill,
1949 unsigned int thickness )
1985 unsigned int width,
unsigned int height,
1987 unsigned int thickness)
1993 double i = center.
get_i();
1994 double j = center.
get_j();
1998 double cosinus = cos(angle);
1999 double sinus = sin(angle);
2000 ipa.
set_u(j + 0.5*width*cosinus + 0.5*height*sinus);
2001 ipa.
set_v(i + 0.5*width*sinus - 0.5*height*cosinus);
2002 ipb.
set_u(j + 0.5*width*cosinus - 0.5*height*sinus);
2003 ipb.
set_v(i + 0.5*width*sinus + 0.5*height*cosinus);
2004 ipc.
set_u(j - 0.5*width*cosinus - 0.5*height*sinus);
2005 ipc.
set_v(i - 0.5*width*sinus + 0.5*height*cosinus);
2006 ipd.
set_u(j - 0.5*width*cosinus + 0.5*height*sinus);
2007 ipd.
set_v(i - 0.5*width*sinus - 0.5*height*cosinus);
2041 unsigned int width,
unsigned int height,
2042 const vpColor &color,
bool fill,
2043 unsigned int thickness)
2054 color, fill, thickness ) ;
2080 unsigned int i,
unsigned int j,
float angle,
2081 unsigned int width,
unsigned int height,
2082 const vpColor &color,
unsigned int thickness)
2090 float cosinus = cos(angle);
2091 float sinus = sin(angle);
2092 ipa.
set_u(j + 0.5*width*cosinus + 0.5*height*sinus);
2093 ipa.
set_v(i + 0.5*width*sinus - 0.5*height*cosinus);
2094 ipb.
set_u(j + 0.5*width*cosinus - 0.5*height*sinus);
2095 ipb.
set_v(i + 0.5*width*sinus + 0.5*height*cosinus);
2096 ipc.
set_u(j - 0.5*width*cosinus - 0.5*height*sinus);
2097 ipc.
set_v(i - 0.5*width*sinus + 0.5*height*cosinus);
2098 ipd.
set_u(j - 0.5*width*cosinus + 0.5*height*sinus);
2099 ipd.
set_v(i - 0.5*width*sinus - 0.5*height*cosinus);
2133 unsigned int width,
unsigned int height,
2134 const vpColor &color,
bool fill,
2135 unsigned int thickness)
2146 color, fill, thickness ) ;
2171 unsigned int i,
unsigned int j,
float angle,
2172 unsigned int width,
unsigned int height,
2173 const vpColor &color,
unsigned int thickness)
2181 float cosinus = cos(angle);
2182 float sinus = sin(angle);
2183 ipa.
set_u(j + 0.5*width*cosinus + 0.5*height*sinus);
2184 ipa.
set_v(i + 0.5*width*sinus - 0.5*height*cosinus);
2185 ipb.
set_u(j + 0.5*width*cosinus - 0.5*height*sinus);
2186 ipb.
set_v(i + 0.5*width*sinus + 0.5*height*cosinus);
2187 ipc.
set_u(j - 0.5*width*cosinus - 0.5*height*sinus);
2188 ipc.
set_v(i - 0.5*width*sinus + 0.5*height*cosinus);
2189 ipd.
set_u(j - 0.5*width*cosinus + 0.5*height*sinus);
2190 ipd.
set_v(i - 0.5*width*sinus - 0.5*height*cosinus);
2431 double top = floor(roi.
getTop());
2432 double left = floor(roi.
getLeft());
2433 double roiheight = floor(roi.
getHeight());
2434 double roiwidth = floor(roi.
getWidth());
2435 double iheight = (double)(I.
getHeight());
2436 double iwidth = (double)(I.
getWidth());
2438 if (top < 0 || top >= iheight || left < 0 || left >= iwidth || top+roiheight >= iheight || left+roiwidth >= iwidth)
2440 vpERROR_TRACE (
"Region of interest outside of the image" ) ;
2442 "Region of interest outside of the image" ) ) ;
2654 return ( I.
display )->getClick(blocking) ;
2692 return ( I.
display )->getClick ( ip, blocking ) ;
2733 return ( I.
display )->getClick ( ip, button, blocking ) ;
2825 return ( I.
display )->getClickUp ( ip, button, blocking ) ;
2978 return ( I.
display )->getKeyboardEvent ( blocking ) ;
3080 char *
string,
bool blocking)
3086 return ( I.
display )->getKeyboardEvent (
string, blocking ) ;
3114 return ( I.
display )->getPointerMotionEvent ( ip ) ;
3143 return ( I.
display )->getPointerPosition ( ip ) ;
3173 return ( I.
display )->getClick(blocking) ;
3210 return ( I.
display )->getClick ( ip, blocking ) ;
3250 return ( I.
display )->getClick ( ip, button, blocking ) ;
3291 return ( I.
display )->getClickUp ( ip, button, blocking ) ;
3393 return ( I.
display )->getKeyboardEvent ( blocking ) ;
3493 char *
string,
bool blocking)
3499 return ( I.
display )->getKeyboardEvent (
string, blocking ) ;
3526 return ( I.
display )->getPointerMotionEvent ( ip ) ;
3553 return ( I.
display )->getPointerPosition ( ip ) ;
3611 const double &coef1,
const double &coef2,
const double &coef3,
3612 bool use_centered_moments,
3614 unsigned int thickness)
3670 const double &coef1,
const double &coef2,
const double &coef3,
3671 const double &theta1,
const double &theta2,
bool use_centered_moments,
3673 unsigned int thickness)
3683 j1 = j2 = i1 = i2 = 0 ;
3684 double a=0., b=0., e=0.;
3686 double mu20_p = coef1;
3687 double mu11_p = coef2;
3688 double mu02_p = coef3;
3690 if (use_centered_moments) {
3691 if (std::fabs(mu11_p) > std::numeric_limits<double>::epsilon()) {
3694 a = sqrt((mu20_p + mu02_p + val_p)/2);
3695 b = sqrt((mu20_p + mu02_p - val_p)/2);
3697 e = (mu02_p - mu20_p + val_p)/(2*mu11_p);
3715 double t = (a-b)/(a+b);
3718 int nbpoints = (int)(floor(circumference/5));
3721 double incr = 2*M_PI / nbpoints ;
3723 double smallalpha = theta1;
3724 double highalpha = theta2;
3728 double k = smallalpha ;
3735 iP11.
set_j ( center.
get_j() + ce *j1 - se *i1 );
3736 iP11.
set_i ( center.
get_i() + se *j1 + ce *i1 );
3738 while (k+incr<highalpha+incr)
3740 j2 = a *cos(k+incr) ;
3741 i2 = b *sin(k+incr) ;
3744 iP22.
set_j ( center.
get_j() + ce *j2 - se *i2 );
3745 iP22.
set_i ( center.
get_i() + se *j2 + ce *i2 );
3810 const double &coef1,
const double &coef2,
const double &coef3,
3811 bool use_centered_moments,
3813 unsigned int thickness)
3869 const double &coef1,
const double &coef2,
const double &coef3,
3870 const double &theta1,
const double &theta2,
bool use_centered_moments,
3872 unsigned int thickness)
3882 j1 = j2 = i1 = i2 = 0 ;
3883 double a=0., b=0., e=0.;
3885 double mu20_p = coef1;
3886 double mu11_p = coef2;
3887 double mu02_p = coef3;
3889 if (use_centered_moments) {
3890 if (std::fabs(mu11_p) > std::numeric_limits<double>::epsilon()) {
3893 a = sqrt((mu20_p + mu02_p + val_p)/2);
3894 b = sqrt((mu20_p + mu02_p - val_p)/2);
3896 e = (mu02_p - mu20_p + val_p)/(2*mu11_p);
3914 double t = (a-b)/(a+b);
3917 int nbpoints = (int)(floor(circumference/5));
3920 double incr = 2*M_PI / nbpoints ;
3922 double smallalpha = theta1;
3923 double highalpha = theta2;
3927 double k = smallalpha ;
3934 iP11.
set_j ( center.
get_j() + ce *j1 - se *i1 );
3935 iP11.
set_i ( center.
get_i() + se *j1 + ce *i1 );
3937 while (k+incr<highalpha+incr)
3939 j2 = a *cos(k+incr) ;
3940 i2 = b *sin(k+incr) ;
3943 iP22.
set_j ( center.
get_j() + ce *j2 - se *i2 );
3944 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)
Implementation of an homogeneous matrix and operations on such kind of matrices.
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
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)
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, vpImagePoint offset=vpImagePoint(0, 0))
void setWorldCoordinates(const double oX, const double oY, const double oZ)
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