Visual Servoing Platform  version 3.0.0
vpDisplay.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 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/vpRGBa.h>
50 #include <visp3/core/vpHomogeneousMatrix.h>
51 #include <visp3/core/vpCameraParameters.h>
52 #include <visp3/core/vpRect.h>
53 #include <visp3/core/vpImagePoint.h>
54 
170 class VISP_EXPORT vpDisplay
171 {
172  protected :
179  unsigned int width ;
180  unsigned int height ;
181  std::string title_;
182 
190  virtual void displayArrow(const vpImagePoint &ip1, const vpImagePoint &ip2,
191  const vpColor &color=vpColor::white,
192  unsigned int w=4, unsigned int h=2,
193  unsigned int thickness=1) =0;
205  virtual void displayCharString(const vpImagePoint &ip, const char *text,
206  const vpColor &color=vpColor::green) =0;
216  virtual void displayCircle(const vpImagePoint &center, unsigned int radius,
217  const vpColor &color,
218  bool fill = false,
219  unsigned int thickness=1) =0;
227  virtual void displayCross(const vpImagePoint &ip, unsigned int size,
228  const vpColor &color,
229  unsigned int thickness=1) =0;
236  virtual void displayDotLine(const vpImagePoint &ip1,
237  const vpImagePoint &ip2,
238  const vpColor &color,
239  unsigned int thickness=1) =0;
246  virtual void displayLine(const vpImagePoint &ip1,
247  const vpImagePoint &ip2,
248  const vpColor &color,
249  unsigned int thickness=1) =0;
250 
256  virtual void displayPoint(const vpImagePoint &ip, const vpColor &color) =0;
257 
271  virtual void displayRectangle(const vpImagePoint &topLeft,
272  unsigned int width, unsigned int height,
273  const vpColor &color, bool fill = false,
274  unsigned int thickness=1)=0 ;
288  virtual void displayRectangle(const vpImagePoint &topLeft,
289  const vpImagePoint &bottomRight,
290  const vpColor &color, bool fill = false,
291  unsigned int thickness=1 )=0;
305  virtual void displayRectangle(const vpRect &rectangle,
306  const vpColor &color, bool fill = false,
307  unsigned int thickness=1)=0 ;
308 
309  public:
310  vpDisplay() ;
311  vpDisplay(const vpDisplay& d) ;
312  virtual ~vpDisplay();
313 
318  virtual void clearDisplay(const vpColor &color=vpColor::white) =0 ;
322  virtual void closeDisplay() =0;
323 
335  virtual void displayImage(const vpImage<unsigned char> &I) =0 ;
347  virtual void displayImage(const vpImage<vpRGBa> &I) =0 ;
348 
349  virtual void displayImageROI(const vpImage<unsigned char> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height) =0 ;
350  virtual void displayImageROI(const vpImage<vpRGBa> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height) =0 ;
351 
356  int getWindowXPosition() const {return windowXPosition;};
361  int getWindowYPosition() const {return windowYPosition;};
366  virtual void flushDisplay() =0;
367 
372  virtual void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height) =0;
373 
374 
375  /* Simple interface with the mouse event */
376 
392  virtual bool getClick(bool blocking=true) =0;
393 
409  virtual bool getClick(vpImagePoint &ip,
410  bool blocking=true) =0;
429  virtual bool getClick(vpImagePoint &ip,
431  bool blocking=true) =0 ;
454  virtual bool getClickUp(vpImagePoint &ip,
456  bool blocking=true) =0;
457 
473  virtual bool getKeyboardEvent(bool blocking=true) =0;
493  virtual bool getKeyboardEvent(char *string, bool blocking=true) =0;
504  virtual bool getPointerMotionEvent (vpImagePoint &ip) =0;
505 
516  virtual bool getPointerPosition (vpImagePoint &ip) =0;
517 
522  inline unsigned int getHeight() const { return height ; }
527  inline unsigned int getWidth() const { return width ; }
528 
536  virtual void init(vpImage<unsigned char> &I,
537  int x=-1, int y=-1,
538  const char *title=NULL) =0 ;
547  virtual void init(vpImage<vpRGBa> &I,
548  int x=-1, int y=-1,
549  const char *title=NULL) =0 ;
550 
609  virtual void init(unsigned int width, unsigned int height,
610  int x=-1, int y=-1 ,
611  const char *title=NULL) =0;
612 
618  inline bool isInitialised() { return displayHasBeenInitialized; }
619 
633  virtual void setFont(const char *font) =0;
638  virtual void setTitle(const char *title) =0;
646  virtual void setWindowPosition(int winx, int winy) = 0 ;
647 
651  static void close(vpImage<unsigned char> &I) ;
652  static void display(const vpImage<unsigned char> &I) ;
653  static void displayArrow(const vpImage<unsigned char> &I,
654  const vpImagePoint &ip1, const vpImagePoint &ip2,
655  const vpColor &color=vpColor::white,
656  unsigned int w=4, unsigned int h=2,
657  unsigned int thickness=1) ;
658  static void displayArrow(const vpImage<unsigned char> &I,
659  int i1, int j1, int i2, int j2,
660  const vpColor &color=vpColor::white,
661  unsigned int w=4, unsigned int h=2,
662  unsigned int thickness=1) ;
663  static void displayCamera(const vpImage<unsigned char> &I,
664  const vpHomogeneousMatrix &cMo,
665  const vpCameraParameters &cam,
666  double size, const vpColor &color,
667  unsigned int thickness) ;
668  static void displayCharString(const vpImage<unsigned char> &I,
669  const vpImagePoint &ip, const char *string,
670  const vpColor &color) ;
671  static void displayCharString(const vpImage<unsigned char> &I,
672  int i, int j, const char *string,
673  const vpColor &color) ;
674  static void displayCircle(const vpImage<unsigned char> &I,
675  const vpImagePoint &center, unsigned int radius,
676  const vpColor &color,
677  bool fill = false,
678  unsigned int thickness=1);
679  static void displayCircle(const vpImage<unsigned char> &I,
680  int i, int j, unsigned int radius,
681  const vpColor &color,
682  bool fill = false,
683  unsigned int thickness=1);
684  static void displayCross(const vpImage<unsigned char> &I,
685  const vpImagePoint &ip, unsigned int size,
686  const vpColor &color,
687  unsigned int thickness=1) ;
688  static void displayCross(const vpImage<unsigned char> &I,
689  int i, int j, unsigned int size,
690  const vpColor &color,
691  unsigned int thickness=1) ;
692  static void displayDotLine(const vpImage<unsigned char> &I,
693  const vpImagePoint &ip1,
694  const vpImagePoint &ip2,
695  const vpColor &color,
696  unsigned int thickness=1) ;
697  static void displayDotLine(const vpImage<unsigned char> &I,
698  int i1, int j1, int i2, int j2,
699  const vpColor &color,
700  unsigned int thickness=1) ;
701  static void displayEllipse(const vpImage<unsigned char> &I,
702  const vpImagePoint &center,
703  const double &coef1, const double &coef2, const double &coef3,
704  bool use_centered_moments,
705  const vpColor &color,
706  unsigned int thickness=1);
707  static void displayEllipse(const vpImage<unsigned char> &I,
708  const vpImagePoint &center,
709  const double &coef1, const double &coef2, const double &coef3,
710  const double &theta1, const double &theta2, bool use_centered_moments,
711  const vpColor &color,
712  unsigned int thickness=1);
713  static void displayFrame(const vpImage<unsigned char> &I,
714  const vpHomogeneousMatrix &cMo,
715  const vpCameraParameters &cam,
716  double size, const vpColor &color=vpColor::none,
717  unsigned int thickness=1, vpImagePoint offset=vpImagePoint(0,0)) ;
718  static void displayLine(const vpImage<unsigned char> &I,
719  const vpImagePoint &ip1,
720  const vpImagePoint &ip2,
721  const vpColor &color,
722  unsigned int thickness=1) ;
723  static void displayLine(const vpImage<unsigned char> &I,
724  int i1, int j1, int i2, int j2,
725  const vpColor &color,
726  unsigned int thickness=1) ;
727  static void displayPoint(const vpImage<unsigned char> &I,
728  const vpImagePoint &ip,
729  const vpColor &color,
730  unsigned int thickness=1) ;
731  static void displayPoint(const vpImage<unsigned char> &I,
732  int i, int j,
733  const vpColor &color,
734  unsigned int thickness=1) ;
735  static void displayPolygon(const vpImage<unsigned char> &I,
736  const std::vector<vpImagePoint> &vip,
737  const vpColor &color,
738  unsigned int thickness=1) ;
739  static void displayRectangle(const vpImage<unsigned char> &I,
740  const vpImagePoint &topLeft,
741  unsigned int width, unsigned int height,
742  const vpColor &color, bool fill = false,
743  unsigned int thickness=1);
744  static void displayRectangle(const vpImage<unsigned char> &I,
745  const vpImagePoint &topLeft,
746  const vpImagePoint &bottomRight,
747  const vpColor &color, bool fill = false,
748  unsigned int thickness=1);
749  static void displayRectangle(const vpImage<unsigned char> &I,
750  const vpRect &rectangle,
751  const vpColor &color, bool fill = false,
752  unsigned int thickness=1);
753  static void displayRectangle(const vpImage<unsigned char> &I,
754  const vpImagePoint &center,
755  float angle,
756  unsigned int width, unsigned int height,
757  const vpColor &color,
758  unsigned int thickness=1);
759  static void displayRectangle(const vpImage<unsigned char> &I,
760  int i, int j,
761  unsigned int width, unsigned int height,
762  const vpColor &color, bool fill = false,
763  unsigned int thickness=1);
764  static void displayRectangle(const vpImage<unsigned char> &I,
765  unsigned int i, unsigned int j, float angle,
766  unsigned int width, unsigned int height,
767  const vpColor &color,
768  unsigned int thickness=1);
769  static void displayROI(const vpImage<unsigned char> &I,const vpRect &roi) ;
770  static void displayText(const vpImage<unsigned char> &I,
771  const vpImagePoint &ip, const std::string &s,
772  const vpColor &color) ;
773  static void displayText(const vpImage<unsigned char> &I,
774  int i, int j, const std::string &s,
775  const vpColor &color) ;
776  static void flush(const vpImage<unsigned char> &I) ;
777  static void flushROI(const vpImage<unsigned char> &I,const vpRect &roi) ;
778 
779  static bool getClick(const vpImage<unsigned char> &I, bool blocking=true) ;
780  static bool getClick(const vpImage<unsigned char> &I,
781  vpImagePoint &ip, bool blocking=true) ;
782  static bool getClick(const vpImage<unsigned char> &I,
783  vpImagePoint &ip,
785  bool blocking=true) ;
786  static bool getClick(const vpImage<unsigned char> &I,
788  bool blocking=true) ;
789  static bool getClickUp(const vpImage<unsigned char> &I,
790  vpImagePoint &ip,
792  bool blocking=true) ;
793  static bool getClickUp(const vpImage<unsigned char> &I,
795  bool blocking=true) ;
796  static void getImage(const vpImage<unsigned char> &Is, vpImage<vpRGBa> &Id) ;
797 
798  static bool getKeyboardEvent(const vpImage<unsigned char> &I,
799  bool blocking=true);
800  static bool getKeyboardEvent(const vpImage<unsigned char> &I,
801  char *string, bool blocking=true);
802  static bool getPointerMotionEvent (const vpImage<unsigned char> &I,
803  vpImagePoint &ip);
804  static bool getPointerPosition (const vpImage<unsigned char> &I,
805  vpImagePoint &ip);
806  static void setBackground(const vpImage<unsigned char> &I, const vpColor &color);
807  static void setFont(const vpImage<unsigned char> &I, const char *font);
808  static void setTitle(const vpImage<unsigned char> &I,
809  const char *windowtitle);
810  static void setWindowPosition(const vpImage<unsigned char> &I,
811  int winx, int winy);
812 
816  static void close(vpImage<vpRGBa> &I) ;
817 
818  static void display(const vpImage<vpRGBa> &I) ;
819  static void displayArrow(const vpImage<vpRGBa> &I,
820  const vpImagePoint &ip1, const vpImagePoint &ip2,
821  const vpColor &color=vpColor::white,
822  unsigned int w=4, unsigned int h=2,
823  unsigned int thickness=1) ;
824  static void displayArrow(const vpImage<vpRGBa> &I,
825  int i1, int j1, int i2, int j2,
826  const vpColor &color=vpColor::white,
827  unsigned int w=4, unsigned int h=2,
828  unsigned int thickness=1) ;
829  static void displayCamera(const vpImage<vpRGBa> &I,
830  const vpHomogeneousMatrix &cMo,
831  const vpCameraParameters &cam,
832  double size, const vpColor &color,
833  unsigned int thickness) ;
834  static void displayCharString(const vpImage<vpRGBa> &I,
835  const vpImagePoint &ip, const char *string,
836  const vpColor &color) ;
837  static void displayCharString(const vpImage<vpRGBa> &I,
838  int i, int j, const char *string,
839  const vpColor &color) ;
840  static void displayCircle(const vpImage<vpRGBa> &I,
841  const vpImagePoint &center, unsigned int radius,
842  const vpColor &color,
843  bool fill = false,
844  unsigned int thickness=1);
845  static void displayCircle(const vpImage<vpRGBa> &I,
846  int i, int j, unsigned int radius,
847  const vpColor &color,
848  bool fill = false,
849  unsigned int thickness=1);
850  static void displayCross(const vpImage<vpRGBa> &I,
851  const vpImagePoint &ip, unsigned int size,
852  const vpColor &color,
853  unsigned int thickness=1) ;
854  static void displayCross(const vpImage<vpRGBa> &I,
855  int i, int j, unsigned int size,
856  const vpColor &color,
857  unsigned int thickness=1) ;
858  static void displayDotLine(const vpImage<vpRGBa> &I,
859  const vpImagePoint &ip1,
860  const vpImagePoint &ip2,
861  const vpColor &color,
862  unsigned int thickness=1) ;
863  static void displayDotLine(const vpImage<vpRGBa> &I,
864  int i1, int j1, int i2, int j2,
865  const vpColor &color,
866  unsigned int thickness=1) ;
867  static void displayFrame(const vpImage<vpRGBa> &I,
868  const vpHomogeneousMatrix &cMo,
869  const vpCameraParameters &cam,
870  double size, const vpColor &color=vpColor::none,
871  unsigned int thickness=1, vpImagePoint offset=vpImagePoint(0,0));
872  static void displayEllipse(const vpImage<vpRGBa> &I,
873  const vpImagePoint &center,
874  const double &coef1, const double &coef2, const double &coef3,
875  bool use_centered_moments,
876  const vpColor &color,
877  unsigned int thickness=1);
878  static void displayEllipse(const vpImage<vpRGBa> &I,
879  const vpImagePoint &center,
880  const double &coef1, const double &coef2, const double &coef3,
881  const double &angle1, const double &angle2, bool use_centered_moments,
882  const vpColor &color,
883  unsigned int thickness=1);
884  static void displayLine(const vpImage<vpRGBa> &I,
885  const vpImagePoint &ip1,
886  const vpImagePoint &ip2,
887  const vpColor &color,
888  unsigned int thickness=1) ;
889  static void displayLine(const vpImage<vpRGBa> &I,
890  int i1, int j1, int i2, int j2,
891  const vpColor &color,
892  unsigned int thickness=1) ;
893  static void displayPoint(const vpImage<vpRGBa> &I,
894  const vpImagePoint &ip,
895  const vpColor &color,
896  unsigned int thickness=1) ;
897  static void displayPoint(const vpImage<vpRGBa> &I,
898  int i, int j,
899  const vpColor &color,
900  unsigned int thickness=1) ;
901  static void displayPolygon(const vpImage<vpRGBa> &I,
902  const std::vector<vpImagePoint> &vip,
903  const vpColor &color,
904  unsigned int thickness=1) ;
905  static void displayRectangle(const vpImage<vpRGBa> &I,
906  const vpImagePoint &topLeft,
907  unsigned int width, unsigned int height,
908  const vpColor &color, bool fill = false,
909  unsigned int thickness=1);
910  static void displayRectangle(const vpImage<vpRGBa> &I,
911  const vpImagePoint &topLeft,
912  const vpImagePoint &bottomRight,
913  const vpColor &color, bool fill = false,
914  unsigned int thickness=1);
915  static void displayRectangle(const vpImage<vpRGBa> &I,
916  const vpRect &rectangle,
917  const vpColor &color, bool fill = false,
918  unsigned int thickness=1);
919  static void displayRectangle(const vpImage<vpRGBa> &I,
920  const vpImagePoint &center,
921  float angle,
922  unsigned int width, unsigned int height,
923  const vpColor &color,
924  unsigned int thickness=1);
925  static void displayRectangle(const vpImage<vpRGBa> &I,
926  int i, int j,
927  unsigned int width, unsigned int height,
928  const vpColor &color, bool fill = false,
929  unsigned int thickness=1);
930  static void displayRectangle(const vpImage<vpRGBa> &I,
931  unsigned int i, unsigned int j,
932  float angle,
933  unsigned int width, unsigned int height,
934  const vpColor &color,
935  unsigned int thickness=1);
936  static void displayROI(const vpImage<vpRGBa> &I, const vpRect &roi) ;
937  static void displayText(const vpImage<vpRGBa> &I,
938  const vpImagePoint &ip, const std::string &s,
939  const vpColor &color) ;
940  static void displayText(const vpImage<vpRGBa> &I,
941  int i, int j, const std::string &s,
942  const vpColor &color) ;
943 
944  static void flush(const vpImage<vpRGBa> &I) ;
945  static void flushROI(const vpImage<vpRGBa> &I, const vpRect &roi) ;
946  static bool getClick(const vpImage<vpRGBa> &I, bool blocking=true) ;
947  static bool getClick(const vpImage<vpRGBa> &I,
948  vpImagePoint &ip, bool blocking=true) ;
949  static bool getClick(const vpImage<vpRGBa> &I,
950  vpImagePoint &ip,
952  bool blocking=true) ;
953  static bool getClick(const vpImage<vpRGBa> &I,
955  bool blocking=true) ;
956  static bool getClickUp(const vpImage<vpRGBa> &I,
957  vpImagePoint &ip,
959  bool blocking=true) ;
960  static bool getClickUp(const vpImage<vpRGBa> &I,
962  bool blocking=true) ;
963  static void getImage(const vpImage<vpRGBa> &Is, vpImage<vpRGBa> &Id) ;
964 
965  static bool getKeyboardEvent(const vpImage<vpRGBa> &I,
966  bool blocking=true);
967  static bool getKeyboardEvent(const vpImage<vpRGBa> &I,
968  char *string, bool blocking=true);
969  static bool getPointerMotionEvent (const vpImage<vpRGBa> &I, vpImagePoint &ip);
970  static bool getPointerPosition (const vpImage<vpRGBa> &I, vpImagePoint &ip);
971 
972  static void setBackground(const vpImage<vpRGBa> &I, const vpColor &color);
973  static void setFont(const vpImage<vpRGBa> &I, const char *font);
974  static void setTitle(const vpImage<vpRGBa> &I, const char *windowtitle);
975  static void setWindowPosition(const vpImage<vpRGBa> &I, int winx, int winy);
976 
977  private:
979  virtual void getImage(vpImage<vpRGBa> &I) = 0;
980 
981 } ;
982 
983 #endif
bool isInitialised()
Definition: vpDisplay.h:618
Class that defines generic functionnalities for display.
Definition: vpDisplay.h:170
unsigned int width
Definition: vpDisplay.h:179
Implementation of an homogeneous matrix and operations on such kind of matrices.
unsigned int getWidth() const
Definition: vpDisplay.h:527
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
static const vpColor none
Definition: vpColor.h:175
bool displayHasBeenInitialized
display has been initialized
Definition: vpDisplay.h:174
static const vpColor green
Definition: vpColor.h:166
std::string title_
Definition: vpDisplay.h:181
unsigned int height
Definition: vpDisplay.h:180
Generic class defining intrinsic camera parameters.
int getWindowYPosition() const
Definition: vpDisplay.h:361
int windowXPosition
display position
Definition: vpDisplay.h:176
Defines a rectangle in the plane.
Definition: vpRect.h:81
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88
int windowYPosition
display position
Definition: vpDisplay.h:178
static const vpColor white
Definition: vpColor.h:158
unsigned int getHeight() const
Definition: vpDisplay.h:522
int getWindowXPosition() const
Definition: vpDisplay.h:356