Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpDisplay.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Image display.
32  *
33  * Authors:
34  * Eric Marchand
35  * Fabien Spindler
36  *
37  *****************************************************************************/
38 
39 
40 #ifndef vpDisplay_h
41 #define vpDisplay_h
42 
43 #include <string>
44 #include <sstream>
45 
46 #include <visp3/core/vpImage.h>
47 #include <visp3/core/vpColor.h>
48 #include <visp3/core/vpMouseButton.h>
49 #include <visp3/core/vpHomogeneousMatrix.h>
50 #include <visp3/core/vpCameraParameters.h>
51 #include <visp3/core/vpRect.h>
52 #include <visp3/core/vpImagePoint.h>
53 
169 class VISP_EXPORT vpDisplay
170 {
171 public:
173  typedef enum {
185  SCALE_DEFAULT
186  } vpScaleType;
187 
188 protected :
195  unsigned int m_width ;
196  unsigned int m_height ;
197  std::string m_title;
198  unsigned int m_scale;
200 
201  void setScale(vpScaleType scaleType, unsigned int width, unsigned int height);
202 
203 public:
204  vpDisplay() ;
205  vpDisplay(const vpDisplay& d) ;
206  virtual ~vpDisplay();
207 
210  unsigned int computeAutoScale(unsigned int width, unsigned int height);
214  unsigned int getDownScalingFactor() { return m_scale; };
219  inline unsigned int getHeight() const { return m_height ; }
224  inline unsigned int getWidth() const { return m_width ; }
225 
230  int getWindowXPosition() const { return m_windowXPosition; };
235  int getWindowYPosition() const { return m_windowYPosition; };
236 
242  inline bool isInitialised() { return m_displayHasBeenInitialized; }
243  virtual void setDownScalingFactor(unsigned int scale);
244  void setDownScalingFactor(vpScaleType scaleType);
246 
247 #ifndef DOXYGEN_SHOULD_SKIP_THIS
248 
254  virtual void clearDisplay(const vpColor &color=vpColor::white) =0 ;
258  virtual void closeDisplay() =0;
259 
269  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;
281  virtual void displayCharString(const vpImagePoint &ip, const char *text, const vpColor &color=vpColor::green) =0;
291  virtual void displayCircle(const vpImagePoint &center, unsigned int radius, const vpColor &color, bool fill = false, unsigned int thickness=1) =0;
299  virtual void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1) =0;
307  virtual void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1) =0;
315  virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1) =0;
316 
328  virtual void displayImage(const vpImage<unsigned char> &I) =0 ;
329 
341  virtual void displayImage(const vpImage<vpRGBa> &I) =0 ;
342 
343  virtual void displayImageROI(const vpImage<unsigned char> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height) =0 ;
344  virtual void displayImageROI(const vpImage<vpRGBa> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height) =0 ;
345 
352  virtual void displayPoint(const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1) =0;
353 
368  virtual void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height,
369  const vpColor &color, bool fill = false, unsigned int thickness=1)=0 ;
383  virtual void displayRectangle(const vpImagePoint &topLeft, const vpImagePoint &bottomRight,
384  const vpColor &color, bool fill = false, unsigned int thickness=1 )=0;
398  virtual void displayRectangle(const vpRect &rectangle, const vpColor &color, bool fill = false, unsigned int thickness=1)=0 ;
399 
404  virtual void flushDisplay() =0;
405 
410  virtual void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height) =0;
411 
412 
413  /* Simple interface with the mouse event */
414 
430  virtual bool getClick(bool blocking=true) =0;
431 
447  virtual bool getClick(vpImagePoint &ip, bool blocking=true) =0;
466  virtual bool getClick(vpImagePoint &ip, vpMouseButton::vpMouseButtonType& button, bool blocking=true) =0 ;
489  virtual bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true) =0;
490 
506  virtual bool getKeyboardEvent(bool blocking=true) =0;
526  virtual bool getKeyboardEvent(std::string &key, bool blocking=true) =0;
537  virtual bool getPointerMotionEvent (vpImagePoint &ip) =0;
538 
549  virtual bool getPointerPosition (vpImagePoint &ip) =0;
550 
554  virtual unsigned int getScreenHeight() =0;
559  virtual void getScreenSize(unsigned int &width, unsigned int &height) =0;
563  virtual unsigned int getScreenWidth() =0;
564 
573  virtual void init(vpImage<unsigned char> &I, int x=-1, int y=-1, const std::string &title="") =0 ;
583  virtual void init(vpImage<vpRGBa> &I, int x=-1, int y=-1, const std::string &title="") =0 ;
584 
645  virtual void init(unsigned int width, unsigned int height, int x=-1, int y=-1, const std::string &title="") =0;
646 
660  virtual void setFont(const std::string &font) =0;
665  virtual void setTitle(const std::string &title) =0;
673  virtual void setWindowPosition(int x, int y) = 0 ;
675 #endif // ifndef DOXYGEN_SHOULD_SKIP_THIS
676 
677 
682  static void close(vpImage<unsigned char> &I) ;
683  static void display(const vpImage<unsigned char> &I) ;
684  static void displayArrow(const vpImage<unsigned char> &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1) ;
685  static void displayArrow(const vpImage<unsigned char> &I, int i1, int j1, int i2, int j2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1) ;
686  static void displayCamera(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, const vpColor &color, unsigned int thickness);
687  static void displayCharString(const vpImage<unsigned char> &I, const vpImagePoint &ip, const char *string, const vpColor &color) ;
688  static void displayCharString(const vpImage<unsigned char> &I, int i, int j, const char *string, const vpColor &color) ;
689  static void displayCircle(const vpImage<unsigned char> &I, const vpImagePoint &center, unsigned int radius, const vpColor &color, bool fill = false, unsigned int thickness=1);
690  static void displayCircle(const vpImage<unsigned char> &I, int i, int j, unsigned int radius, const vpColor &color, bool fill = false, unsigned int thickness=1);
691  static void displayCross(const vpImage<unsigned char> &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1) ;
692  static void displayCross(const vpImage<unsigned char> &I, int i, int j, unsigned int size, const vpColor &color, unsigned int thickness=1) ;
693  static void displayDotLine(const vpImage<unsigned char> &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1) ;
694  static void displayDotLine(const vpImage<unsigned char> &I, int i1, int j1, int i2, int j2, const vpColor &color, unsigned int thickness=1) ;
695  static void displayEllipse(const vpImage<unsigned char> &I, const vpImagePoint &center, const double &coef1, const double &coef2, const double &coef3, bool use_centered_moments, const vpColor &color, unsigned int thickness=1);
696  static void displayEllipse(const vpImage<unsigned char> &I, const vpImagePoint &center, const double &coef1, const double &coef2, const double &coef3, const double &theta1, const double &theta2, bool use_centered_moments, const vpColor &color, unsigned int thickness=1);
697  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)) ;
698  static void displayLine(const vpImage<unsigned char> &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1) ;
699  static void displayLine(const vpImage<unsigned char> &I, int i1, int j1, int i2, int j2, const vpColor &color, unsigned int thickness=1) ;
700  static void displayPoint(const vpImage<unsigned char> &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1) ;
701  static void displayPoint(const vpImage<unsigned char> &I, int i, int j, const vpColor &color, unsigned int thickness=1) ;
702  static void displayPolygon(const vpImage<unsigned char> &I, const std::vector<vpImagePoint> &vip, const vpColor &color, unsigned int thickness=1) ;
703  static void displayRectangle(const vpImage<unsigned char> &I, const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill = false, unsigned int thickness=1);
704  static void displayRectangle(const vpImage<unsigned char> &I, const vpImagePoint &topLeft, const vpImagePoint &bottomRight, const vpColor &color, bool fill = false, unsigned int thickness=1);
705  static void displayRectangle(const vpImage<unsigned char> &I, const vpRect &rectangle, const vpColor &color, bool fill = false, unsigned int thickness=1);
706  static void displayRectangle(const vpImage<unsigned char> &I, const vpImagePoint &center, float angle, unsigned int width, unsigned int height, const vpColor &color, unsigned int thickness=1);
707  static void displayRectangle(const vpImage<unsigned char> &I, int i, int j, unsigned int width, unsigned int height, const vpColor &color, bool fill = false, unsigned int thickness=1);
708  static void displayRectangle(const vpImage<unsigned char> &I, unsigned int i, unsigned int j, float angle, unsigned int width, unsigned int height, const vpColor &color, unsigned int thickness=1);
709  static void displayROI(const vpImage<unsigned char> &I,const vpRect &roi) ;
710  static void displayText(const vpImage<unsigned char> &I, const vpImagePoint &ip, const std::string &s, const vpColor &color) ;
711  static void displayText(const vpImage<unsigned char> &I, int i, int j, const std::string &s, const vpColor &color) ;
712 
713  static void flush(const vpImage<unsigned char> &I) ;
714  static void flushROI(const vpImage<unsigned char> &I,const vpRect &roi) ;
715 
716  static bool getClick(const vpImage<unsigned char> &I, bool blocking=true) ;
717  static bool getClick(const vpImage<unsigned char> &I, vpImagePoint &ip, bool blocking=true) ;
718  static bool getClick(const vpImage<unsigned char> &I, vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true) ;
719  static bool getClick(const vpImage<unsigned char> &I, vpMouseButton::vpMouseButtonType &button, bool blocking=true) ;
720  static bool getClickUp(const vpImage<unsigned char> &I, vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true) ;
721  static bool getClickUp(const vpImage<unsigned char> &I, vpMouseButton::vpMouseButtonType &button, bool blocking=true) ;
722  static unsigned int getDownScalingFactor(const vpImage<unsigned char> &I);
723  static void getImage(const vpImage<unsigned char> &Is, vpImage<vpRGBa> &Id) ;
724  static bool getKeyboardEvent(const vpImage<unsigned char> &I, bool blocking=true);
725  static bool getKeyboardEvent(const vpImage<unsigned char> &I, std::string &key, bool blocking=true);
726  static bool getKeyboardEvent(const vpImage<unsigned char> &I, char *key, bool blocking=true);
727  static bool getPointerMotionEvent (const vpImage<unsigned char> &I, vpImagePoint &ip);
728  static bool getPointerPosition(const vpImage<unsigned char> &I, vpImagePoint &ip);
729 
730  static void setBackground(const vpImage<unsigned char> &I, const vpColor &color);
731  static void setFont(const vpImage<unsigned char> &I, const std::string &font);
732  static void setTitle(const vpImage<unsigned char> &I, const std::string &windowtitle);
733  static void setWindowPosition(const vpImage<unsigned char> &I, int winx, int winy);
735 
740  static void close(vpImage<vpRGBa> &I) ;
741  static void display(const vpImage<vpRGBa> &I) ;
742  static void displayArrow(const vpImage<vpRGBa> &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1) ;
743  static void displayArrow(const vpImage<vpRGBa> &I, int i1, int j1, int i2, int j2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1) ;
744  static void displayCamera(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, const vpColor &color, unsigned int thickness);
745  static void displayCharString(const vpImage<vpRGBa> &I, const vpImagePoint &ip, const char *string, const vpColor &color) ;
746  static void displayCharString(const vpImage<vpRGBa> &I, int i, int j, const char *string, const vpColor &color) ;
747  static void displayCircle(const vpImage<vpRGBa> &I, const vpImagePoint &center, unsigned int radius, const vpColor &color, bool fill = false, unsigned int thickness=1);
748  static void displayCircle(const vpImage<vpRGBa> &I, int i, int j, unsigned int radius, const vpColor &color, bool fill = false, unsigned int thickness=1);
749  static void displayCross(const vpImage<vpRGBa> &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1) ;
750  static void displayCross(const vpImage<vpRGBa> &I, int i, int j, unsigned int size, const vpColor &color, unsigned int thickness=1) ;
751  static void displayDotLine(const vpImage<vpRGBa> &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1) ;
752  static void displayDotLine(const vpImage<vpRGBa> &I, int i1, int j1, int i2, int j2, const vpColor &color, unsigned int thickness=1) ;
753  static void displayEllipse(const vpImage<vpRGBa> &I, const vpImagePoint &center, const double &coef1, const double &coef2, const double &coef3, bool use_centered_moments, const vpColor &color, unsigned int thickness=1);
754  static void displayEllipse(const vpImage<vpRGBa> &I, const vpImagePoint &center, const double &coef1, const double &coef2, const double &coef3, const double &theta1, const double &theta2, bool use_centered_moments, const vpColor &color, unsigned int thickness=1);
755  static void displayFrame(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, const vpColor &color=vpColor::none, unsigned int thickness=1, vpImagePoint offset=vpImagePoint(0,0)) ;
756  static void displayLine(const vpImage<vpRGBa> &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1) ;
757  static void displayLine(const vpImage<vpRGBa> &I, int i1, int j1, int i2, int j2, const vpColor &color, unsigned int thickness=1) ;
758  static void displayPoint(const vpImage<vpRGBa> &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1) ;
759  static void displayPoint(const vpImage<vpRGBa> &I, int i, int j, const vpColor &color, unsigned int thickness=1) ;
760  static void displayPolygon(const vpImage<vpRGBa> &I, const std::vector<vpImagePoint> &vip, const vpColor &color, unsigned int thickness=1) ;
761  static void displayRectangle(const vpImage<vpRGBa> &I, const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill = false, unsigned int thickness=1);
762  static void displayRectangle(const vpImage<vpRGBa> &I, const vpImagePoint &topLeft, const vpImagePoint &bottomRight, const vpColor &color, bool fill = false, unsigned int thickness=1);
763  static void displayRectangle(const vpImage<vpRGBa> &I, const vpRect &rectangle, const vpColor &color, bool fill = false, unsigned int thickness=1);
764  static void displayRectangle(const vpImage<vpRGBa> &I, const vpImagePoint &center, float angle, unsigned int width, unsigned int height, const vpColor &color, unsigned int thickness=1);
765  static void displayRectangle(const vpImage<vpRGBa> &I, int i, int j, unsigned int width, unsigned int height, const vpColor &color, bool fill = false, unsigned int thickness=1);
766  static void displayRectangle(const vpImage<vpRGBa> &I, unsigned int i, unsigned int j, float angle, unsigned int width, unsigned int height, const vpColor &color, unsigned int thickness=1);
767  static void displayROI(const vpImage<vpRGBa> &I,const vpRect &roi) ;
768  static void displayText(const vpImage<vpRGBa> &I, const vpImagePoint &ip, const std::string &s, const vpColor &color) ;
769  static void displayText(const vpImage<vpRGBa> &I, int i, int j, const std::string &s, const vpColor &color) ;
770 
771  static void flush(const vpImage<vpRGBa> &I) ;
772  static void flushROI(const vpImage<vpRGBa> &I,const vpRect &roi) ;
773 
774  static bool getClick(const vpImage<vpRGBa> &I, bool blocking=true) ;
775  static bool getClick(const vpImage<vpRGBa> &I, vpImagePoint &ip, bool blocking=true) ;
776  static bool getClick(const vpImage<vpRGBa> &I, vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true) ;
777  static bool getClick(const vpImage<vpRGBa> &I, vpMouseButton::vpMouseButtonType &button, bool blocking=true) ;
778  static bool getClickUp(const vpImage<vpRGBa> &I, vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true) ;
779  static bool getClickUp(const vpImage<vpRGBa> &I, vpMouseButton::vpMouseButtonType &button, bool blocking=true) ;
780  static unsigned int getDownScalingFactor(const vpImage<vpRGBa> &I);
781  static void getImage(const vpImage<vpRGBa> &Is, vpImage<vpRGBa> &Id) ;
782  static bool getKeyboardEvent(const vpImage<vpRGBa> &I, bool blocking=true);
783  static bool getKeyboardEvent(const vpImage<vpRGBa> &I, std::string &key, bool blocking=true);
784  static bool getKeyboardEvent(const vpImage<vpRGBa> &I, char *key, bool blocking=true);
785  static bool getPointerMotionEvent (const vpImage<vpRGBa> &I, vpImagePoint &ip);
786  static bool getPointerPosition (const vpImage<vpRGBa> &I, vpImagePoint &ip);
787 
788  static void setBackground(const vpImage<vpRGBa> &I, const vpColor &color);
789  static void setFont(const vpImage<vpRGBa> &I, const std::string &font);
790  static void setTitle(const vpImage<vpRGBa> &I, const std::string &windowtitle);
791  static void setWindowPosition(const vpImage<vpRGBa> &I, int winx, int winy);
793 
794  private:
796  virtual void getImage(vpImage<vpRGBa> &I) = 0;
797 
798 } ;
799 
800 #endif
unsigned int m_height
Definition: vpDisplay.h:196
bool isInitialised()
Definition: vpDisplay.h:242
int m_windowYPosition
display position
Definition: vpDisplay.h:194
Class that defines generic functionnalities for display.
Definition: vpDisplay.h:169
Implementation of an homogeneous matrix and operations on such kind of matrices.
unsigned int getWidth() const
Definition: vpDisplay.h:224
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
static const vpColor none
Definition: vpColor.h:175
bool m_displayHasBeenInitialized
display has been initialized
Definition: vpDisplay.h:190
static const vpColor green
Definition: vpColor.h:166
int m_windowXPosition
display position
Definition: vpDisplay.h:192
unsigned int m_scale
Definition: vpDisplay.h:198
Generic class defining intrinsic camera parameters.
vpScaleType m_scaleType
Definition: vpDisplay.h:199
std::string m_title
Definition: vpDisplay.h:197
int getWindowYPosition() const
Definition: vpDisplay.h:235
unsigned int m_width
Definition: vpDisplay.h:195
vpScaleType
Values that could be applied to a display to down scale the size of the display.
Definition: vpDisplay.h:173
unsigned int getDownScalingFactor()
Definition: vpDisplay.h:214
Defines a rectangle in the plane.
Definition: vpRect.h:82
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88
static const vpColor white
Definition: vpColor.h:158
unsigned int getHeight() const
Definition: vpDisplay.h:219
int getWindowXPosition() const
Definition: vpDisplay.h:230