ViSP  2.10.0
vpDisplay.h
1 /****************************************************************************
2  *
3  * $Id: vpDisplay.h 5089 2014-12-19 07:58:34Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Image display.
36  *
37  * Authors:
38  * Eric Marchand
39  * Fabien Spindler
40  *
41  *****************************************************************************/
42 
43 
44 #ifndef vpDisplay_h
45 #define vpDisplay_h
46 
47 #include <string>
48 #include <sstream>
49 
50 #include <visp/vpImage.h>
51 #include <visp/vpColor.h>
52 #include <visp/vpMouseButton.h>
53 #include <visp/vpRGBa.h>
54 #include <visp/vpHomogeneousMatrix.h>
55 #include <visp/vpCameraParameters.h>
56 #include <visp/vpRect.h>
57 #include <visp/vpImagePoint.h>
58 
174 class VISP_EXPORT vpDisplay
175 {
176  protected :
183  unsigned int width ;
184  unsigned int height ;
185  std::string title_;
186 
194  virtual void displayArrow(const vpImagePoint &ip1, const vpImagePoint &ip2,
195  const vpColor &color=vpColor::white,
196  unsigned int w=4, unsigned int h=2,
197  unsigned int thickness=1) =0;
209  virtual void displayCharString(const vpImagePoint &ip, const char *text,
210  const vpColor &color=vpColor::green) =0;
220  virtual void displayCircle(const vpImagePoint &center, unsigned int radius,
221  const vpColor &color,
222  bool fill = false,
223  unsigned int thickness=1) =0;
231  virtual void displayCross(const vpImagePoint &ip, unsigned int size,
232  const vpColor &color,
233  unsigned int thickness=1) =0;
240  virtual void displayDotLine(const vpImagePoint &ip1,
241  const vpImagePoint &ip2,
242  const vpColor &color,
243  unsigned int thickness=1) =0;
250  virtual void displayLine(const vpImagePoint &ip1,
251  const vpImagePoint &ip2,
252  const vpColor &color,
253  unsigned int thickness=1) =0;
254 
260  virtual void displayPoint(const vpImagePoint &ip, const vpColor &color) =0;
261 
275  virtual void displayRectangle(const vpImagePoint &topLeft,
276  unsigned int width, unsigned int height,
277  const vpColor &color, bool fill = false,
278  unsigned int thickness=1)=0 ;
292  virtual void displayRectangle(const vpImagePoint &topLeft,
293  const vpImagePoint &bottomRight,
294  const vpColor &color, bool fill = false,
295  unsigned int thickness=1 )=0;
309  virtual void displayRectangle(const vpRect &rectangle,
310  const vpColor &color, bool fill = false,
311  unsigned int thickness=1)=0 ;
312 
313  public:
314  vpDisplay() ;
315  vpDisplay(const vpDisplay& d) ;
316  virtual ~vpDisplay();
317 
322  virtual void clearDisplay(const vpColor &color=vpColor::white) =0 ;
326  virtual void closeDisplay() =0;
327 
339  virtual void displayImage(const vpImage<unsigned char> &I) =0 ;
351  virtual void displayImage(const vpImage<vpRGBa> &I) =0 ;
352 
353  virtual void displayImageROI(const vpImage<unsigned char> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height) =0 ;
354  virtual void displayImageROI(const vpImage<vpRGBa> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height) =0 ;
355 
360  int getWindowXPosition() const {return windowXPosition;};
365  int getWindowYPosition() const {return windowYPosition;};
370  virtual void flushDisplay() =0;
371 
376  virtual void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height) =0;
377 
378 
379  /* Simple interface with the mouse event */
380 
396  virtual bool getClick(bool blocking=true) =0;
397 
413  virtual bool getClick(vpImagePoint &ip,
414  bool blocking=true) =0;
433  virtual bool getClick(vpImagePoint &ip,
435  bool blocking=true) =0 ;
458  virtual bool getClickUp(vpImagePoint &ip,
460  bool blocking=true) =0;
461 
477  virtual bool getKeyboardEvent(bool blocking=true) =0;
497  virtual bool getKeyboardEvent(char *string, bool blocking=true) =0;
508  virtual bool getPointerMotionEvent (vpImagePoint &ip) =0;
509 
520  virtual bool getPointerPosition (vpImagePoint &ip) =0;
521 
526  inline unsigned int getHeight() const { return height ; }
531  inline unsigned int getWidth() const { return width ; }
532 
540  virtual void init(vpImage<unsigned char> &I,
541  int x=-1, int y=-1,
542  const char *title=NULL) =0 ;
551  virtual void init(vpImage<vpRGBa> &I,
552  int x=-1, int y=-1,
553  const char *title=NULL) =0 ;
554 
562  virtual void init(unsigned int width, unsigned int height,
563  int x=-1, int y=-1 ,
564  const char *title=NULL) =0;
565 
571  inline bool isInitialised() { return displayHasBeenInitialized; }
572 
586  virtual void setFont(const char *font) =0;
591  virtual void setTitle(const char *title) =0;
599  virtual void setWindowPosition(int winx, int winy) = 0 ;
600 
604  static void close(vpImage<unsigned char> &I) ;
605  static void display(const vpImage<unsigned char> &I) ;
606  static void displayArrow(const vpImage<unsigned char> &I,
607  const vpImagePoint &ip1, const vpImagePoint &ip2,
608  const vpColor &color=vpColor::white,
609  unsigned int w=4, unsigned int h=2,
610  unsigned int thickness=1) ;
611  static void displayArrow(const vpImage<unsigned char> &I,
612  int i1, int j1, int i2, int j2,
613  const vpColor &color=vpColor::white,
614  unsigned int w=4, unsigned int h=2,
615  unsigned int thickness=1) ;
616  static void displayCamera(const vpImage<unsigned char> &I,
617  const vpHomogeneousMatrix &cMo,
618  const vpCameraParameters &cam,
619  double size, const vpColor &color,
620  unsigned int thickness) ;
621  static void displayCharString(const vpImage<unsigned char> &I,
622  const vpImagePoint &ip, const char *string,
623  const vpColor &color) ;
624  static void displayCharString(const vpImage<unsigned char> &I,
625  int i, int j, const char *string,
626  const vpColor &color) ;
627  static void displayCircle(const vpImage<unsigned char> &I,
628  const vpImagePoint &center, unsigned int radius,
629  const vpColor &color,
630  bool fill = false,
631  unsigned int thickness=1);
632  static void displayCircle(const vpImage<unsigned char> &I,
633  int i, int j, unsigned int radius,
634  const vpColor &color,
635  bool fill = false,
636  unsigned int thickness=1);
637  static void displayCross(const vpImage<unsigned char> &I,
638  const vpImagePoint &ip, unsigned int size,
639  const vpColor &color,
640  unsigned int thickness=1) ;
641  static void displayCross(const vpImage<unsigned char> &I,
642  int i, int j, unsigned int size,
643  const vpColor &color,
644  unsigned int thickness=1) ;
645  static void displayDotLine(const vpImage<unsigned char> &I,
646  const vpImagePoint &ip1,
647  const vpImagePoint &ip2,
648  const vpColor &color,
649  unsigned int thickness=1) ;
650  static void displayDotLine(const vpImage<unsigned char> &I,
651  int i1, int j1, int i2, int j2,
652  const vpColor &color,
653  unsigned int thickness=1) ;
654  static void displayEllipse(const vpImage<unsigned char> &I,
655  const vpImagePoint &center,
656  const double &coef1, const double &coef2, const double &coef3,
657  bool use_centered_moments,
658  const vpColor &color,
659  unsigned int thickness=1);
660  static void displayEllipse(const vpImage<unsigned char> &I,
661  const vpImagePoint &center,
662  const double &coef1, const double &coef2, const double &coef3,
663  const double &theta1, const double &theta2, bool use_centered_moments,
664  const vpColor &color,
665  unsigned int thickness=1);
666  static void displayFrame(const vpImage<unsigned char> &I,
667  const vpHomogeneousMatrix &cMo,
668  const vpCameraParameters &cam,
669  double size, const vpColor &color=vpColor::none,
670  unsigned int thickness=1) ;
671  static void displayLine(const vpImage<unsigned char> &I,
672  const vpImagePoint &ip1,
673  const vpImagePoint &ip2,
674  const vpColor &color,
675  unsigned int thickness=1) ;
676  static void displayLine(const vpImage<unsigned char> &I,
677  int i1, int j1, int i2, int j2,
678  const vpColor &color,
679  unsigned int thickness=1) ;
680  static void displayPoint(const vpImage<unsigned char> &I,
681  const vpImagePoint &ip,
682  const vpColor &color,
683  unsigned int thickness=1) ;
684  static void displayPoint(const vpImage<unsigned char> &I,
685  int i, int j,
686  const vpColor &color,
687  unsigned int thickness=1) ;
688  static void displayPolygon(const vpImage<unsigned char> &I,
689  const std::vector<vpImagePoint> &vip,
690  const vpColor &color,
691  unsigned int thickness=1) ;
692  static void displayRectangle(const vpImage<unsigned char> &I,
693  const vpImagePoint &topLeft,
694  unsigned int width, unsigned int height,
695  const vpColor &color, bool fill = false,
696  unsigned int thickness=1);
697  static void displayRectangle(const vpImage<unsigned char> &I,
698  const vpImagePoint &topLeft,
699  const vpImagePoint &bottomRight,
700  const vpColor &color, bool fill = false,
701  unsigned int thickness=1);
702  static void displayRectangle(const vpImage<unsigned char> &I,
703  const vpRect &rectangle,
704  const vpColor &color, bool fill = false,
705  unsigned int thickness=1);
706  static void displayRectangle(const vpImage<unsigned char> &I,
707  const vpImagePoint &center,
708  float angle,
709  unsigned int width, unsigned int height,
710  const vpColor &color,
711  unsigned int thickness=1);
712  static void displayRectangle(const vpImage<unsigned char> &I,
713  int i, int j,
714  unsigned int width, unsigned int height,
715  const vpColor &color, bool fill = false,
716  unsigned int thickness=1);
717  static void displayRectangle(const vpImage<unsigned char> &I,
718  unsigned int i, unsigned int j, float angle,
719  unsigned int width, unsigned int height,
720  const vpColor &color,
721  unsigned int thickness=1);
722  static void displayROI(const vpImage<unsigned char> &I,const vpRect &roi) ;
723  static void displayText(const vpImage<unsigned char> &I,
724  const vpImagePoint &ip, const std::string &s,
725  const vpColor &color) ;
726  static void displayText(const vpImage<unsigned char> &I,
727  int i, int j, const std::string &s,
728  const vpColor &color) ;
729  static void flush(const vpImage<unsigned char> &I) ;
730  static void flushROI(const vpImage<unsigned char> &I,const vpRect &roi) ;
731 
732  static bool getClick(const vpImage<unsigned char> &I, bool blocking=true) ;
733  static bool getClick(const vpImage<unsigned char> &I,
734  vpImagePoint &ip, bool blocking=true) ;
735  static bool getClick(const vpImage<unsigned char> &I,
736  vpImagePoint &ip,
738  bool blocking=true) ;
739  static bool getClick(const vpImage<unsigned char> &I,
741  bool blocking=true) ;
742  static bool getClickUp(const vpImage<unsigned char> &I,
743  vpImagePoint &ip,
745  bool blocking=true) ;
746  static bool getClickUp(const vpImage<unsigned char> &I,
748  bool blocking=true) ;
749  static void getImage(const vpImage<unsigned char> &Is, vpImage<vpRGBa> &Id) ;
750 
751  static bool getKeyboardEvent(const vpImage<unsigned char> &I,
752  bool blocking=true);
753  static bool getKeyboardEvent(const vpImage<unsigned char> &I,
754  char *string, bool blocking=true);
755  static bool getPointerMotionEvent (const vpImage<unsigned char> &I,
756  vpImagePoint &ip);
757  static bool getPointerPosition (const vpImage<unsigned char> &I,
758  vpImagePoint &ip);
759  static void setBackground(const vpImage<unsigned char> &I, const vpColor &color);
760  static void setFont(const vpImage<unsigned char> &I, const char *font);
761  static void setTitle(const vpImage<unsigned char> &I,
762  const char *windowtitle);
763  static void setWindowPosition(const vpImage<unsigned char> &I,
764  int winx, int winy);
765 
769  static void close(vpImage<vpRGBa> &I) ;
770 
771  static void display(const vpImage<vpRGBa> &I) ;
772  static void displayArrow(const vpImage<vpRGBa> &I,
773  const vpImagePoint &ip1, const vpImagePoint &ip2,
774  const vpColor &color=vpColor::white,
775  unsigned int w=4, unsigned int h=2,
776  unsigned int thickness=1) ;
777  static void displayArrow(const vpImage<vpRGBa> &I,
778  int i1, int j1, int i2, int j2,
779  const vpColor &color=vpColor::white,
780  unsigned int w=4, unsigned int h=2,
781  unsigned int thickness=1) ;
782  static void displayCamera(const vpImage<vpRGBa> &I,
783  const vpHomogeneousMatrix &cMo,
784  const vpCameraParameters &cam,
785  double size, const vpColor &color,
786  unsigned int thickness) ;
787  static void displayCharString(const vpImage<vpRGBa> &I,
788  const vpImagePoint &ip, const char *string,
789  const vpColor &color) ;
790  static void displayCharString(const vpImage<vpRGBa> &I,
791  int i, int j, const char *string,
792  const vpColor &color) ;
793  static void displayCircle(const vpImage<vpRGBa> &I,
794  const vpImagePoint &center, unsigned int radius,
795  const vpColor &color,
796  bool fill = false,
797  unsigned int thickness=1);
798  static void displayCircle(const vpImage<vpRGBa> &I,
799  int i, int j, unsigned int radius,
800  const vpColor &color,
801  bool fill = false,
802  unsigned int thickness=1);
803  static void displayCross(const vpImage<vpRGBa> &I,
804  const vpImagePoint &ip, unsigned int size,
805  const vpColor &color,
806  unsigned int thickness=1) ;
807  static void displayCross(const vpImage<vpRGBa> &I,
808  int i, int j, unsigned int size,
809  const vpColor &color,
810  unsigned int thickness=1) ;
811  static void displayDotLine(const vpImage<vpRGBa> &I,
812  const vpImagePoint &ip1,
813  const vpImagePoint &ip2,
814  const vpColor &color,
815  unsigned int thickness=1) ;
816  static void displayDotLine(const vpImage<vpRGBa> &I,
817  int i1, int j1, int i2, int j2,
818  const vpColor &color,
819  unsigned int thickness=1) ;
820  static void displayFrame(const vpImage<vpRGBa> &I,
821  const vpHomogeneousMatrix &cMo,
822  const vpCameraParameters &cam,
823  double size, const vpColor &color=vpColor::none,
824  unsigned int thickness=1) ;
825  static void displayEllipse(const vpImage<vpRGBa> &I,
826  const vpImagePoint &center,
827  const double &coef1, const double &coef2, const double &coef3,
828  bool use_centered_moments,
829  const vpColor &color,
830  unsigned int thickness=1);
831  static void displayEllipse(const vpImage<vpRGBa> &I,
832  const vpImagePoint &center,
833  const double &coef1, const double &coef2, const double &coef3,
834  const double &angle1, const double &angle2, bool use_centered_moments,
835  const vpColor &color,
836  unsigned int thickness=1);
837  static void displayLine(const vpImage<vpRGBa> &I,
838  const vpImagePoint &ip1,
839  const vpImagePoint &ip2,
840  const vpColor &color,
841  unsigned int thickness=1) ;
842  static void displayLine(const vpImage<vpRGBa> &I,
843  int i1, int j1, int i2, int j2,
844  const vpColor &color,
845  unsigned int thickness=1) ;
846  static void displayPoint(const vpImage<vpRGBa> &I,
847  const vpImagePoint &ip,
848  const vpColor &color,
849  unsigned int thickness=1) ;
850  static void displayPoint(const vpImage<vpRGBa> &I,
851  int i, int j,
852  const vpColor &color,
853  unsigned int thickness=1) ;
854  static void displayPolygon(const vpImage<vpRGBa> &I,
855  const std::vector<vpImagePoint> &vip,
856  const vpColor &color,
857  unsigned int thickness=1) ;
858  static void displayRectangle(const vpImage<vpRGBa> &I,
859  const vpImagePoint &topLeft,
860  unsigned int width, unsigned int height,
861  const vpColor &color, bool fill = false,
862  unsigned int thickness=1);
863  static void displayRectangle(const vpImage<vpRGBa> &I,
864  const vpImagePoint &topLeft,
865  const vpImagePoint &bottomRight,
866  const vpColor &color, bool fill = false,
867  unsigned int thickness=1);
868  static void displayRectangle(const vpImage<vpRGBa> &I,
869  const vpRect &rectangle,
870  const vpColor &color, bool fill = false,
871  unsigned int thickness=1);
872  static void displayRectangle(const vpImage<vpRGBa> &I,
873  const vpImagePoint &center,
874  float angle,
875  unsigned int width, unsigned int height,
876  const vpColor &color,
877  unsigned int thickness=1);
878  static void displayRectangle(const vpImage<vpRGBa> &I,
879  int i, int j,
880  unsigned int width, unsigned int height,
881  const vpColor &color, bool fill = false,
882  unsigned int thickness=1);
883  static void displayRectangle(const vpImage<vpRGBa> &I,
884  unsigned int i, unsigned int j,
885  float angle,
886  unsigned int width, unsigned int height,
887  const vpColor &color,
888  unsigned int thickness=1);
889  static void displayROI(const vpImage<vpRGBa> &I, const vpRect &roi) ;
890  static void displayText(const vpImage<vpRGBa> &I,
891  const vpImagePoint &ip, const std::string &s,
892  const vpColor &color) ;
893  static void displayText(const vpImage<vpRGBa> &I,
894  int i, int j, const std::string &s,
895  const vpColor &color) ;
896 
897  static void flush(const vpImage<vpRGBa> &I) ;
898  static void flushROI(const vpImage<vpRGBa> &I, const vpRect &roi) ;
899  static bool getClick(const vpImage<vpRGBa> &I, bool blocking=true) ;
900  static bool getClick(const vpImage<vpRGBa> &I,
901  vpImagePoint &ip, bool blocking=true) ;
902  static bool getClick(const vpImage<vpRGBa> &I,
903  vpImagePoint &ip,
905  bool blocking=true) ;
906  static bool getClick(const vpImage<vpRGBa> &I,
908  bool blocking=true) ;
909  static bool getClickUp(const vpImage<vpRGBa> &I,
910  vpImagePoint &ip,
912  bool blocking=true) ;
913  static bool getClickUp(const vpImage<vpRGBa> &I,
915  bool blocking=true) ;
916  static void getImage(const vpImage<vpRGBa> &Is, vpImage<vpRGBa> &Id) ;
917 
918  static bool getKeyboardEvent(const vpImage<vpRGBa> &I,
919  bool blocking=true);
920  static bool getKeyboardEvent(const vpImage<vpRGBa> &I,
921  char *string, bool blocking=true);
922  static bool getPointerMotionEvent (const vpImage<vpRGBa> &I, vpImagePoint &ip);
923  static bool getPointerPosition (const vpImage<vpRGBa> &I, vpImagePoint &ip);
924 
925  static void setBackground(const vpImage<vpRGBa> &I, const vpColor &color);
926  static void setFont(const vpImage<vpRGBa> &I, const char *font);
927  static void setTitle(const vpImage<vpRGBa> &I, const char *windowtitle);
928  static void setWindowPosition(const vpImage<vpRGBa> &I, int winx, int winy);
929 
930  private:
932  virtual void getImage(vpImage<vpRGBa> &I) = 0;
933 
934 } ;
935 
936 #endif
bool isInitialised()
Definition: vpDisplay.h:571
Class that defines generic functionnalities for display.
Definition: vpDisplay.h:174
unsigned int width
Definition: vpDisplay.h:183
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
unsigned int getWidth() const
Definition: vpDisplay.h:531
Class to define colors available for display functionnalities.
Definition: vpColor.h:125
static const vpColor none
Definition: vpColor.h:179
bool displayHasBeenInitialized
display has been initialized
Definition: vpDisplay.h:178
static const vpColor green
Definition: vpColor.h:170
std::string title_
Definition: vpDisplay.h:185
unsigned int height
Definition: vpDisplay.h:184
Generic class defining intrinsic camera parameters.
int getWindowYPosition() const
Definition: vpDisplay.h:365
int windowXPosition
display position
Definition: vpDisplay.h:180
Defines a rectangle in the plane.
Definition: vpRect.h:85
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:93
int windowYPosition
display position
Definition: vpDisplay.h:182
static const vpColor white
Definition: vpColor.h:162
unsigned int getHeight() const
Definition: vpDisplay.h:526
int getWindowXPosition() const
Definition: vpDisplay.h:360