1 /**************************************************************************** 2 * 3 * ViSP, open source Visual Servoing Platform software. 4 * Copyright (C) 2005 - 2019 by Inria. All rights reserved. 5 * 6 * This software is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * See the file LICENSE.txt at the root directory of this source 11 * distribution for additional information about the GNU GPL. 12 * 13 * For using ViSP with software that can not be combined with the GNU 14 * GPL, please contact Inria about acquiring a ViSP Professional 15 * Edition License. 16 * 17 * See http://visp.inria.fr for more information. 18 * 19 * This software was developed at: 20 * Inria Rennes - Bretagne Atlantique 21 * Campus Universitaire de Beaulieu 22 * 35042 Rennes Cedex 23 * France 24 * 25 * If you have questions regarding the use of this file, please contact 26 * Inria at visp@inria.fr 27 * 28 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 29 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 30 * 31 * Description: 32 * Image display. 33 * 34 * Authors: 35 * Eric Marchand 36 * Fabien Spindler 37 * 38 *****************************************************************************/ 39 40 #ifndef vpDisplay_h 41 #define vpDisplay_h 42 43 #include <sstream> 44 #include <string> 45 #include <list> 46 47 #include <visp3/core/vpCameraParameters.h> 48 #include <visp3/core/vpColor.h> 49 #include <visp3/core/vpHomogeneousMatrix.h> 50 #include <visp3/core/vpImage.h> 51 #include <visp3/core/vpImagePoint.h> 52 #include <visp3/core/vpMouseButton.h> 53 #include <visp3/core/vpRect.h> 54 55 /*! 56 \file vpDisplay.h 57 \brief Generic class for image display, also provide the interface 58 with the image. 59 */ 60 61 /*! 62 63 \class vpDisplay 64 65 \ingroup group_core_gui 66 67 \brief Class that defines generic functionnalities for display. 68 69 The \ref tutorial-getting-started is a good starting point to know 70 how to use this class to display an image in a window. 71 72 \warning Since ViSP 3.3.1 or higher we introduce the alpha channel support for color 73 transparency. This new feature is only supported yet using vpDisplayOpenCV. See vpColor 74 header documentation and displayOpenCV.cpp example for usage when displaying filled 75 transparent circles and rectangles. 76 77 The example below shows how to use this class. 78 79 \code 80 #include <visp3/core/vpConfig.h> 81 #include <visp3/gui/vpDisplayD3D.h> 82 #include <visp3/gui/vpDisplayGDI.h> 83 #include <visp3/gui/vpDisplayGTK.h> 84 #include <visp3/gui/vpDisplayOpenCV.h> 85 #include <visp3/gui/vpDisplayX.h> 86 #include <visp3/io/vpImageIo.h> 87 88 int main() 89 { 90 vpImage<unsigned char> I; // Grey level image 91 92 // Read an image in PGM P5 format 93 #ifdef _WIN32 94 vpImageIo::read(I, "C:/temp/ViSP-images/Klimt/Klimt.pgm"); 95 #else 96 vpImageIo::read(I, "/local/soft/ViSP/ViSP-images/Klimt/Klimt.pgm"); 97 #endif 98 99 vpDisplay *d; 100 101 // Depending on the detected third party libraries, we instantiate here the 102 // first video device which is available 103 #if defined(VISP_HAVE_X11) 104 d = new vpDisplayX; 105 #elif defined(VISP_HAVE_GTK) 106 d = new vpDisplayGTK; 107 #elif defined(VISP_HAVE_GDI) 108 d = new vpDisplayGDI; 109 #elif defined(VISP_HAVE_D3D9) 110 d = new vpDisplayD3D; 111 #elif defined(VISP_HAVE_OPENCV) 112 d = new vpDisplayOpenCV; 113 #endif 114 115 // Initialize the display with the image I. Display and image are 116 // now link together. 117 #ifdef VISP_HAVE_DISPLAY 118 d->init(I); 119 #endif 120 121 // Specify the window location 122 vpDisplay::setWindowPosition(I, 400, 100); 123 124 // Set the display window title 125 vpDisplay::setTitle(I, "My image"); 126 127 // To initialize the video device, it is also possible to replace 128 // the 3 previous lines by: 129 // d->init(I, 400, 100, "My image"); 130 131 // Set the display background with image I content 132 vpDisplay::display(I); 133 134 // Draw a red rectangle in the display overlay (foreground) 135 vpDisplay::displayRectangle(I, 10, 10, 100, 20, vpColor::red, true); 136 137 // Draw a red rectangle in the display overlay (foreground) 138 vpImagePoint topLeftCorner; 139 topLeftCorner.set_i(50); 140 topLeftCorner.set_j(10); 141 vpDisplay::displayRectangle(I, topLeftCorner, 100, 20, vpColor::green, 142 true); 143 144 // Flush the foreground and background display 145 vpDisplay::flush(I); 146 147 // Get non blocking keyboard events 148 std::cout << "Check keyboard events..." << std::endl; 149 char key[10]; sprintf(key, "\0"); 150 bool ret; 151 for (int i=0; i< 200; i++) { 152 bool ret = vpDisplay::getKeyboardEvent(I, key, false); 153 if (ret) 154 std::cout << "keyboard event: key: " << "\"" << key 155 << "\"" << std::endl; 156 vpTime::wait(40); 157 } 158 159 // Get a blocking keyboard event 160 std::cout << "Wait for a keyboard event..." << std::endl; 161 ret = vpDisplay::getKeyboardEvent(I, key, true); 162 std::cout << "keyboard event: " << ret << std::endl; 163 if (ret) 164 std::cout << "key: " << "\"" << key << "\"" << std::endl; 165 166 // Wait for a click in the display window 167 std::cout << "Wait for a button click..." << std::endl; 168 vpDisplay::getClick(I); 169 170 delete d; 171 } 172 \endcode 173 174 Other examples are available in tutorial-image-viewer.cpp and 175 tutorial-viewer.cpp. 176 */ 177 class VISP_EXPORT vpDisplay 178 { 179 public: 180 //! Values that could be applied to a display to down scale the size of the 181 //! display. 182 typedef enum { 183 SCALE_AUTO, /*!< Auto down scaling factor computed fom the screen 184 resolution. */ 185 SCALE_1, /*!< Display and image have the same size. */ 186 SCALE_2, /*!< Display width and height is down scaled by 2 wrt the image 187 size. */ 188 SCALE_3, /*!< Display width and height is down scaled by 3 wrt the image 189 size. */ 190 SCALE_4, /*!< Display width and height is down scaled by 4 wrt the image 191 size. */ 192 SCALE_5, /*!< Display width and height is down scaled by 5 wrt the image 193 size. */ 194 SCALE_6, /*!< Display width and height is down scaled by 6 wrt the image 195 size. */ 196 SCALE_7, /*!< Display width and height is down scaled by 7 wrt the image 197 size. */ 198 SCALE_8, /*!< Display width and height is down scaled by 8 wrt the image 199 size. */ 200 SCALE_9, /*!< Display width and height is down scaled by 9 wrt the image 201 size. */ 202 SCALE_10, /*!< Display width and height is down scaled by 10 wrt the image 203 size. */ 204 SCALE_DEFAULT /*!< Display and image have the same size. Similar to 205 vpDisplay::SCALE_1. */ 206 } vpScaleType; 207 208 protected: 209 //! display has been initialized 210 bool m_displayHasBeenInitialized; 211 //! display position 212 int m_windowXPosition; 213 //! display position 214 int m_windowYPosition; 215 unsigned int m_width; 216 unsigned int m_height; 217 std::string m_title; 218 unsigned int m_scale; 219 vpScaleType m_scaleType; 220 221 void setScale(vpScaleType scaleType, unsigned int width, unsigned int height); 222 223 public: 224 vpDisplay(); 225 vpDisplay(const vpDisplay &d); 226 virtual ~vpDisplay(); 227 228 /** @name Inherited functionalities from vpDisplay */ 229 //@{ 230 unsigned int computeAutoScale(unsigned int width, unsigned int height); 231 /*! 232 Return the value of the down scale factor applied to the image in order to 233 reduce the size of the window used to display the image. 234 */ getDownScalingFactor()235 unsigned int getDownScalingFactor() { return m_scale; } 236 /*! 237 Return the display height. 238 \sa getWidth() 239 */ getHeight()240 inline unsigned int getHeight() const { return m_height; } 241 /*! 242 Return the display width. 243 \sa getHeight() 244 */ getWidth()245 inline unsigned int getWidth() const { return m_width; } 246 247 /*! 248 Return the position (along the horizontal axis) on the screen of the 249 display window. \sa getWindowYPosition() 250 */ getWindowXPosition()251 int getWindowXPosition() const { return m_windowXPosition; } 252 /*! 253 Return the position (along the vertical axis) on the screen of the display 254 window. \sa getWindowXPosition() 255 */ getWindowYPosition()256 int getWindowYPosition() const { return m_windowYPosition; } 257 258 /*! 259 Check if the display has been initialised 260 261 \return True if the display has been initialised, otherwise False 262 */ isInitialised()263 inline bool isInitialised() { return m_displayHasBeenInitialized; } 264 virtual void setDownScalingFactor(unsigned int scale); 265 virtual void setDownScalingFactor(vpScaleType scaleType); 266 //@} 267 268 #ifndef DOXYGEN_SHOULD_SKIP_THIS 269 /** @name vpDisplay pure virtual functions */ 270 //@{ 271 /*! 272 Set the window backgroud to \e color. 273 \param color : Background color. 274 */ 275 virtual void clearDisplay(const vpColor &color = vpColor::white) = 0; 276 /*! 277 Close the window. 278 */ 279 virtual void closeDisplay() = 0; 280 281 /*! 282 Display an arrow from image point \e ip1 to image point \e ip2. 283 \param ip1 : Initial image point. 284 \param ip2 : Final image point. 285 \param color : Arrow color. 286 \param w : Arrow width. 287 \param h : Arrow height. 288 \param thickness : Thickness of the lines used to display the arrow. 289 */ 290 virtual void displayArrow(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color = vpColor::white, 291 unsigned int w = 4, unsigned int h = 2, unsigned int thickness = 1) = 0; 292 /*! 293 Display a string at the image point \e ip location. 294 295 To select the font used to display the string, use setFont(). 296 297 \param ip : Upper left image point location of the string in the display. 298 \param text : String to display in overlay. 299 \param color : String color. 300 301 \sa setFont() 302 */ 303 virtual void displayCharString(const vpImagePoint &ip, const char *text, const vpColor &color = vpColor::green) = 0; 304 /*! 305 Display a circle. 306 \param center : Circle center position. 307 \param radius : Circle radius. 308 \param color : Circle color. 309 \param fill : When set to true fill the circle. 310 \param thickness : Thickness of the circle. This parameter is only useful 311 when \e fill is set to false. 312 */ 313 virtual void displayCircle(const vpImagePoint ¢er, unsigned int radius, const vpColor &color, bool fill = false, 314 unsigned int thickness = 1) = 0; 315 /*! 316 Display a cross at the image point \e ip location. 317 \param ip : Cross location. 318 \param size : Size (width and height) of the cross. 319 \param color : Cross color. 320 \param thickness : Thickness of the lines used to display the cross. 321 */ 322 virtual void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, 323 unsigned int thickness = 1) = 0; 324 /*! 325 Display a dashed line from image point \e ip1 to image point \e ip2. 326 \param ip1 : Initial image point. 327 \param ip2 : Final image point. 328 \param color : Line color. 329 \param thickness : Dashed line thickness. 330 */ 331 virtual void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, 332 unsigned int thickness = 1) = 0; 333 /*! 334 Display a line from image point \e ip1 to image point \e ip2. 335 \param ip1 : Initial image point. 336 \param ip2 : Final image point. 337 \param color : Line color. 338 \param thickness : Line thickness. 339 */ 340 virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, 341 unsigned int thickness = 1) = 0; 342 343 /*! 344 Display the gray level image \e I (8bits). 345 346 \warning Display has to be initialized. 347 348 \warning Suppress the overlay drawing. 349 350 \param I : Image to display. 351 352 \sa init(), closeDisplay() 353 */ 354 virtual void displayImage(const vpImage<unsigned char> &I) = 0; 355 356 /*! 357 Display the color image \e I in RGBa format (32bits). 358 359 \warning Display has to be initialized. 360 361 \warning Suppress the overlay drawing. 362 363 \param I : Image to display. 364 365 \sa init(), closeDisplay() 366 */ 367 virtual void displayImage(const vpImage<vpRGBa> &I) = 0; 368 369 virtual void displayImageROI(const vpImage<unsigned char> &I, const vpImagePoint &iP, unsigned int width, 370 unsigned int height) = 0; 371 virtual void displayImageROI(const vpImage<vpRGBa> &I, const vpImagePoint &iP, unsigned int width, 372 unsigned int height) = 0; 373 374 /*! 375 Display a point at the image point \e ip location. 376 \param ip : Point location. 377 \param color : Point color. 378 \param thickness : Point thickness. 379 */ 380 virtual void displayPoint(const vpImagePoint &ip, const vpColor &color, unsigned int thickness = 1) = 0; 381 382 /*! 383 Display a rectangle with \e topLeft as the top-left corner and \e 384 width and \e height the rectangle size. 385 386 \param topLeft : Top-left corner of the rectangle. 387 \param width : Rectangle width. 388 \param height : Rectangle height. 389 \param color : Rectangle color. 390 \param fill : When set to true fill the rectangle. 391 392 \param thickness : Thickness of the four lines used to display the 393 rectangle. This parameter is only useful when \e fill is set to 394 false. 395 */ 396 virtual void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, 397 const vpColor &color, bool fill = false, unsigned int thickness = 1) = 0; 398 /*! 399 Display a rectangle with \e topLeft as the top-left corner and \e 400 width and \e height the rectangle size. 401 402 \param topLeft : Top-left corner of the rectangle. 403 \param bottomRight : Bottom-right corner of the rectangle. 404 \param color : Rectangle color. 405 \param fill : When set to true fill the rectangle. 406 407 \param thickness : Thickness of the four lines used to display the 408 rectangle. This parameter is only useful when \e fill is set to 409 false. 410 */ 411 virtual void displayRectangle(const vpImagePoint &topLeft, const vpImagePoint &bottomRight, const vpColor &color, 412 bool fill = false, unsigned int thickness = 1) = 0; 413 /*! 414 Display a rectangle with \e topLeft as the top-left corner and \e 415 width and \e height the rectangle size. 416 417 \param rectangle : Rectangle characteristics. 418 \param color : Rectangle color. 419 \param fill : When set to true fill the rectangle. 420 421 \param thickness : Thickness of the four lines used to display the 422 rectangle. This parameter is only useful when \e fill is set to 423 false. 424 425 */ 426 virtual void displayRectangle(const vpRect &rectangle, const vpColor &color, bool fill = false, 427 unsigned int thickness = 1) = 0; 428 429 /*! 430 Flushes the display. 431 It's necessary to use this function to see the results of any drawing. 432 */ 433 virtual void flushDisplay() = 0; 434 435 /*! 436 Flushes the display. 437 It's necessary to use this function to see the results of any drawing. 438 */ 439 virtual void flushDisplayROI(const vpImagePoint &iP, unsigned int width, unsigned int height) = 0; 440 441 /* Simple interface with the mouse event */ 442 443 /*! 444 Wait for a click from one of the mouse button. 445 446 \param blocking [in] : Blocking behavior. 447 - When set to true, this method waits until a mouse button is 448 pressed and then returns always true. 449 - When set to false, returns true only if a mouse button is 450 pressed, otherwise returns false. 451 452 \return 453 - true if a button was clicked. This is always the case if blocking is set 454 to \e true. 455 - false if no button was clicked. This can occur if blocking is set 456 to \e false. 457 */ 458 virtual bool getClick(bool blocking = true) = 0; 459 460 /*! 461 Wait for a click from one of the mouse button and get the position 462 of the clicked image point. 463 464 \param ip [out] : The coordinates of the clicked image point. 465 466 \param blocking [in] : true for a blocking behaviour waiting a mouse 467 button click, false for a non blocking behaviour. 468 469 \return 470 - true if a button was clicked. This is always the case if blocking is set 471 to \e true. 472 - false if no button was clicked. This can occur if blocking is set 473 to \e false. 474 */ 475 virtual bool getClick(vpImagePoint &ip, bool blocking = true) = 0; 476 /*! 477 Wait for a mouse button click and get the position of the clicked 478 pixel. The button used to click is also set. 479 480 \param ip [out] : The coordinates of the clicked image point. 481 482 \param button [out] : The button used to click. 483 484 \param blocking [in] : 485 - When set to true, this method waits until a mouse button is 486 pressed and then returns always true. 487 - When set to false, returns true only if a mouse button is 488 pressed, otherwise returns false. 489 490 \return true if a mouse button is pressed, false otherwise. If a 491 button is pressed, the location of the mouse pointer is updated in 492 \e ip. 493 */ 494 virtual bool getClick(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking = true) = 0; 495 /*! 496 Wait for a mouse button click release and get the position of the 497 image point were the click release occurs. The button used to click is 498 also set. Same method as getClick(unsigned int&, unsigned int&, 499 vpMouseButton::vpMouseButtonType &, bool). 500 501 \param ip [out] : Position of the clicked image point. 502 503 \param button [in] : Button used to click. 504 505 \param blocking [in] : true for a blocking behaviour waiting a mouse 506 button click, false for a non blocking behaviour. 507 508 \return 509 - true if a button was clicked. This is always the case if blocking is set 510 to \e true. 511 - false if no button was clicked. This can occur if blocking is set 512 to \e false. 513 514 \sa getClick(vpImagePoint &, vpMouseButton::vpMouseButtonType &, bool) 515 516 */ 517 virtual bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking = true) = 0; 518 519 /*! 520 Get a keyboard event. 521 522 \param blocking [in] : Blocking behavior. 523 - When set to true, this method waits until a key is 524 pressed and then returns always true. 525 - When set to false, returns true only if a key is 526 pressed, otherwise returns false. 527 528 \return 529 - true if a key was pressed. This is always the case if blocking is set 530 to \e true. 531 - false if no key was pressed. This can occur if blocking is set 532 to \e false. 533 */ 534 virtual bool getKeyboardEvent(bool blocking = true) = 0; 535 /*! 536 537 Get a keyboard event. 538 539 \param blocking [in] : Blocking behavior. 540 - When set to true, this method waits until a key is 541 pressed and then returns always true. 542 - When set to false, returns true only if a key is 543 pressed, otherwise returns false. 544 545 \param key [out]: If possible, an ISO Latin-1 character 546 corresponding to the keyboard key. 547 548 \return 549 - true if a key was pressed. This is always the case if blocking is set 550 to \e true. 551 - false if no key was pressed. This can occur if blocking is set 552 to \e false. 553 */ 554 virtual bool getKeyboardEvent(std::string &key, bool blocking = true) = 0; 555 /*! 556 Get the coordinates of the mouse pointer. 557 558 \param ip [out] : The coordinates of the mouse pointer. 559 560 \return true if a pointer motion event was received, false otherwise. 561 562 \exception vpDisplayException::notInitializedError : If the display 563 was not initialized. 564 */ 565 virtual bool getPointerMotionEvent(vpImagePoint &ip) = 0; 566 567 /*! 568 Get the coordinates of the mouse pointer. 569 570 \param ip [out] : The coordinates of the mouse pointer. 571 572 \return true. 573 574 \exception vpDisplayException::notInitializedError : If the display 575 was not initialized. 576 */ 577 virtual bool getPointerPosition(vpImagePoint &ip) = 0; 578 579 /*! 580 Gets the screen vertical resolution in pixel. 581 */ 582 virtual unsigned int getScreenHeight() = 0; 583 /*! 584 Gets the screen resolution in pixel. 585 \param width, height : Screen resolution in pixels. 586 */ 587 virtual void getScreenSize(unsigned int &width, unsigned int &height) = 0; 588 /*! 589 Gets the screen horizontal resolution in pixel. 590 */ 591 virtual unsigned int getScreenWidth() = 0; 592 593 /*! 594 Initialize the display (size, position and title) of a gray level image. 595 596 \param I : Image to be displayed (not that image has to be initialized). 597 \param x : Horizontal position of the upper/left window corner. 598 \param y : Vertical position of the upper/left window corner. 599 \param title : Window title. 600 */ 601 virtual void init(vpImage<unsigned char> &I, int x = -1, int y = -1, const std::string &title = "") = 0; 602 /*! 603 Initialize the display (size, position and title) of a color 604 image in RGBa format. 605 606 \param I : Image to be displayed (not that image has to be initialized). 607 \param x : Horizontal position of the upper/left window corner. 608 \param y : Vertical position of the upper/left window corner. 609 \param title : Window title. 610 */ 611 virtual void init(vpImage<vpRGBa> &I, int x = -1, int y = -1, const std::string &title = "") = 0; 612 613 /*! 614 Initialize the display size, position and title. 615 616 \param width : Window width. 617 \param height : Window height. 618 \param x : Horizontal position of the upper/left window corner. 619 \param y : Vertical position of the upper/left window corner. 620 \param title : Window title. 621 622 The following example shows how to use this function 623 \code 624 #include <visp3/gui/vpDisplayD3D.h> 625 #include <visp3/gui/vpDisplayGDI.h> 626 #include <visp3/gui/vpDisplayGTK.h> 627 #include <visp3/gui/vpDisplayOpenCV.h> 628 #include <visp3/gui/vpDisplayX.h> 629 #include <visp3/io/vpImageIo.h> 630 631 int main() 632 { 633 #ifdef VISP_HAVE_DISPLAY 634 vpImage<unsigned char> I; 635 vpImageIo::read(I, "lena.pgm"); 636 637 vpDisplay *d; 638 639 #if defined(VISP_HAVE_X11) 640 d = new vpDisplayX; 641 #elif defined(VISP_HAVE_GTK) 642 d = new vpDisplayGTK; 643 #elif defined(VISP_HAVE_GDI) 644 d = new vpDisplayGDI; 645 #elif defined(VISP_HAVE_D3D9) 646 d = new vpDisplayD3D; 647 #elif defined(VISP_HAVE_OPENCV) 648 d = new vpDisplayOpenCV; 649 #else 650 std::cout << "Sorry, no video device is available" << std::endl; 651 return -1; 652 #endif 653 654 d->init(I.getWidth(), I.getHeight(), 10, 20, "viewer"); 655 656 // Now associate the display to the image 657 I.display = d; 658 659 // Set the display background with image I content 660 vpDisplay::display(I); 661 662 // Flush the foreground and background display 663 vpDisplay::flush(I); 664 665 // wait for a mouse clink in the display to exit 666 vpDisplay::getClick(I); 667 668 delete d; 669 #endif 670 } 671 \endcode 672 */ 673 virtual void init(unsigned int width, unsigned int height, int x = -1, int y = -1, const std::string &title = "") = 0; 674 675 /*! 676 Set the font used to display a text in overlay. The display is 677 performed using displayCharString(). 678 679 \param font : The expected font name. The available fonts are given by 680 the "xlsfonts" binary. To choose a font you can also use the 681 "xfontsel" binary. 682 683 \note Under UNIX, to know all the available fonts, use the 684 "xlsfonts" binary in a terminal. You can also use the "xfontsel" binary. 685 686 \sa displayCharString() 687 */ 688 virtual void setFont(const std::string &font) = 0; 689 /*! 690 Set the window title. 691 \param title : Window title. 692 */ 693 virtual void setTitle(const std::string &title) = 0; 694 /*! 695 Set the window position in the screen. 696 697 \param x : Horizontal position of the upper/left window corner. 698 \param y : Vertical position of the upper/left window corner. 699 700 */ 701 virtual void setWindowPosition(int x, int y) = 0; 702 //@} 703 #endif // ifndef DOXYGEN_SHOULD_SKIP_THIS 704 705 /*! 706 @name Static public vpDisplay functionalities on gray level images. 707 */ 708 //@{ 709 static void close(vpImage<unsigned char> &I); 710 static void display(const vpImage<unsigned char> &I); 711 static void displayArrow(const vpImage<unsigned char> &I, const vpImagePoint &ip1, const vpImagePoint &ip2, 712 const vpColor &color = vpColor::white, unsigned int w = 4, unsigned int h = 2, 713 unsigned int thickness = 1); 714 static void displayArrow(const vpImage<unsigned char> &I, int i1, int j1, int i2, int j2, 715 const vpColor &color = vpColor::white, unsigned int w = 4, unsigned int h = 2, 716 unsigned int thickness = 1); 717 static void displayCamera(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, 718 const vpCameraParameters &cam, double size, const vpColor &color, unsigned int thickness); 719 static void displayCharString(const vpImage<unsigned char> &I, const vpImagePoint &ip, const char *string, 720 const vpColor &color); 721 static void displayCharString(const vpImage<unsigned char> &I, int i, int j, const char *string, 722 const vpColor &color); 723 static void displayCircle(const vpImage<unsigned char> &I, const vpImagePoint ¢er, unsigned int radius, 724 const vpColor &color, bool fill = false, unsigned int thickness = 1); 725 static void displayCircle(const vpImage<unsigned char> &I, int i, int j, unsigned int radius, const vpColor &color, 726 bool fill = false, unsigned int thickness = 1); 727 static void displayCross(const vpImage<unsigned char> &I, const vpImagePoint &ip, unsigned int size, 728 const vpColor &color, unsigned int thickness = 1); 729 static void displayCross(const vpImage<unsigned char> &I, int i, int j, unsigned int size, const vpColor &color, 730 unsigned int thickness = 1); 731 static void displayDotLine(const vpImage<unsigned char> &I, const vpImagePoint &ip1, const vpImagePoint &ip2, 732 const vpColor &color, unsigned int thickness = 1); 733 static void displayDotLine(const vpImage<unsigned char> &I, int i1, int j1, int i2, int j2, const vpColor &color, 734 unsigned int thickness = 1); 735 static void displayDotLine(const vpImage<unsigned char> &I, const std::vector<vpImagePoint> &ips, 736 bool closeTheShape, const vpColor &color, unsigned int thickness = 1); 737 static void displayDotLine(const vpImage<unsigned char> &I, const std::list<vpImagePoint> &ips, 738 bool closeTheShape, const vpColor &color, unsigned int thickness = 1); 739 static void displayEllipse(const vpImage<unsigned char> &I, const vpImagePoint ¢er, const double &coef1, 740 const double &coef2, const double &coef3, bool use_normalized_centered_moments, const vpColor &color, 741 unsigned int thickness = 1, bool display_center = false, bool display_arc = false); 742 static void displayEllipse(const vpImage<unsigned char> &I, const vpImagePoint ¢er, const double &coef1, 743 const double &coef2, const double &coef3, const double &smallalpha, const double &highalpha, 744 bool use_normalized_centered_moments, const vpColor &color, unsigned int thickness = 1, 745 bool display_center = false, bool display_arc = false); 746 static void displayFrame(const vpImage<unsigned char> &I, const vpHomogeneousMatrix &cMo, 747 const vpCameraParameters &cam, double size, const vpColor &color = vpColor::none, 748 unsigned int thickness = 1, const vpImagePoint &offset = vpImagePoint(0, 0)); 749 static void displayLine(const vpImage<unsigned char> &I, const vpImagePoint &ip1, const vpImagePoint &ip2, 750 const vpColor &color, unsigned int thickness = 1, bool segment = true); 751 static void displayLine(const vpImage<unsigned char> &I, int i1, int j1, int i2, int j2, const vpColor &color, 752 unsigned int thickness = 1, bool segment = true); 753 static void displayLine(const vpImage<unsigned char> &I, const std::vector<vpImagePoint> &ips, 754 bool closeTheShape, const vpColor &color, unsigned int thickness = 1); 755 static void displayLine(const vpImage<unsigned char> &I, const std::list<vpImagePoint> &ips, 756 bool closeTheShape, const vpColor &color, unsigned int thickness = 1); 757 static void displayPoint(const vpImage<unsigned char> &I, const vpImagePoint &ip, const vpColor &color, 758 unsigned int thickness = 1); 759 static void displayPoint(const vpImage<unsigned char> &I, int i, int j, const vpColor &color, 760 unsigned int thickness = 1); 761 static void displayPolygon(const vpImage<unsigned char> &I, const std::vector<vpImagePoint> &vip, 762 const vpColor &color, unsigned int thickness = 1, bool closed = true); 763 static void displayRectangle(const vpImage<unsigned char> &I, const vpImagePoint &topLeft, unsigned int width, 764 unsigned int height, const vpColor &color, bool fill = false, 765 unsigned int thickness = 1); 766 static void displayRectangle(const vpImage<unsigned char> &I, const vpImagePoint &topLeft, 767 const vpImagePoint &bottomRight, const vpColor &color, bool fill = false, 768 unsigned int thickness = 1); 769 static void displayRectangle(const vpImage<unsigned char> &I, const vpRect &rectangle, const vpColor &color, 770 bool fill = false, unsigned int thickness = 1); 771 static void displayRectangle(const vpImage<unsigned char> &I, const vpImagePoint ¢er, float angle, 772 unsigned int width, unsigned int height, const vpColor &color, 773 unsigned int thickness = 1); 774 static void displayRectangle(const vpImage<unsigned char> &I, int i, int j, unsigned int width, unsigned int height, 775 const vpColor &color, bool fill = false, unsigned int thickness = 1); 776 static void displayRectangle(const vpImage<unsigned char> &I, unsigned int i, unsigned int j, float angle, 777 unsigned int width, unsigned int height, const vpColor &color, 778 unsigned int thickness = 1); 779 static void displayROI(const vpImage<unsigned char> &I, const vpRect &roi); 780 static void displayText(const vpImage<unsigned char> &I, const vpImagePoint &ip, const std::string &s, 781 const vpColor &color); 782 static void displayText(const vpImage<unsigned char> &I, int i, int j, const std::string &s, const vpColor &color); 783 784 static void flush(const vpImage<unsigned char> &I); 785 static void flushROI(const vpImage<unsigned char> &I, const vpRect &roi); 786 787 static bool getClick(const vpImage<unsigned char> &I, bool blocking = true); 788 static bool getClick(const vpImage<unsigned char> &I, vpImagePoint &ip, bool blocking = true); 789 static bool getClick(const vpImage<unsigned char> &I, vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, 790 bool blocking = true); 791 static bool getClick(const vpImage<unsigned char> &I, vpMouseButton::vpMouseButtonType &button, bool blocking = true); 792 static bool getClickUp(const vpImage<unsigned char> &I, vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, 793 bool blocking = true); 794 static bool getClickUp(const vpImage<unsigned char> &I, vpMouseButton::vpMouseButtonType &button, 795 bool blocking = true); 796 static unsigned int getDownScalingFactor(const vpImage<unsigned char> &I); 797 static void getImage(const vpImage<unsigned char> &Is, vpImage<vpRGBa> &Id); 798 static bool getKeyboardEvent(const vpImage<unsigned char> &I, bool blocking = true); 799 static bool getKeyboardEvent(const vpImage<unsigned char> &I, std::string &key, bool blocking = true); 800 static bool getKeyboardEvent(const vpImage<unsigned char> &I, char *key, bool blocking = true); 801 static bool getPointerMotionEvent(const vpImage<unsigned char> &I, vpImagePoint &ip); 802 static bool getPointerPosition(const vpImage<unsigned char> &I, vpImagePoint &ip); 803 804 static void setBackground(const vpImage<unsigned char> &I, const vpColor &color); 805 static void setFont(const vpImage<unsigned char> &I, const std::string &font); 806 static void setTitle(const vpImage<unsigned char> &I, const std::string &windowtitle); 807 static void setWindowPosition(const vpImage<unsigned char> &I, int winx, int winy); 808 //@} 809 810 /*! 811 @name Static public vpDisplay functionalities on 32 bits color images. 812 */ 813 //@{ 814 static void close(vpImage<vpRGBa> &I); 815 static void display(const vpImage<vpRGBa> &I); 816 static void displayArrow(const vpImage<vpRGBa> &I, const vpImagePoint &ip1, const vpImagePoint &ip2, 817 const vpColor &color = vpColor::white, unsigned int w = 4, unsigned int h = 2, 818 unsigned int thickness = 1); 819 static void displayArrow(const vpImage<vpRGBa> &I, int i1, int j1, int i2, int j2, 820 const vpColor &color = vpColor::white, unsigned int w = 4, unsigned int h = 2, 821 unsigned int thickness = 1); 822 static void displayCamera(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, 823 double size, const vpColor &color, unsigned int thickness); 824 static void displayCharString(const vpImage<vpRGBa> &I, const vpImagePoint &ip, const char *string, 825 const vpColor &color); 826 static void displayCharString(const vpImage<vpRGBa> &I, int i, int j, const char *string, const vpColor &color); 827 static void displayCircle(const vpImage<vpRGBa> &I, const vpImagePoint ¢er, unsigned int radius, 828 const vpColor &color, bool fill = false, unsigned int thickness = 1); 829 static void displayCircle(const vpImage<vpRGBa> &I, int i, int j, unsigned int radius, const vpColor &color, 830 bool fill = false, unsigned int thickness = 1); 831 static void displayCross(const vpImage<vpRGBa> &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, 832 unsigned int thickness = 1); 833 static void displayCross(const vpImage<vpRGBa> &I, int i, int j, unsigned int size, const vpColor &color, 834 unsigned int thickness = 1); 835 static void displayDotLine(const vpImage<vpRGBa> &I, const vpImagePoint &ip1, const vpImagePoint &ip2, 836 const vpColor &color, unsigned int thickness = 1); 837 static void displayDotLine(const vpImage<vpRGBa> &I, int i1, int j1, int i2, int j2, const vpColor &color, 838 unsigned int thickness = 1); 839 static void displayDotLine(const vpImage<vpRGBa> &I, const std::vector<vpImagePoint> &ips, bool closeTheShape, 840 const vpColor &color, unsigned int thickness = 1); 841 static void displayDotLine(const vpImage<vpRGBa> &I, const std::list<vpImagePoint> &ips, bool closeTheShape, 842 const vpColor &color, unsigned int thickness = 1); 843 static void displayEllipse(const vpImage<vpRGBa> &I, const vpImagePoint ¢er, const double &coef1, 844 const double &coef2, const double &coef3, bool use_centered_moments, const vpColor &color, 845 unsigned int thickness = 1, bool display_center = false, bool display_arc = false); 846 static void displayEllipse(const vpImage<vpRGBa> &I, const vpImagePoint ¢er, const double &coef1, 847 const double &coef2, const double &coef3, const double &theta1, const double &theta2, 848 bool use_centered_moments, const vpColor &color, unsigned int thickness = 1, 849 bool display_center = false, bool display_arc = false); 850 static void displayFrame(const vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, 851 double size, const vpColor &color = vpColor::none, unsigned int thickness = 1, 852 const vpImagePoint &offset = vpImagePoint(0, 0)); 853 static void displayLine(const vpImage<vpRGBa> &I, const vpImagePoint &ip1, const vpImagePoint &ip2, 854 const vpColor &color, unsigned int thickness = 1, bool segment = true); 855 static void displayLine(const vpImage<vpRGBa> &I, int i1, int j1, int i2, int j2, const vpColor &color, 856 unsigned int thickness = 1, bool segment = true); 857 static void displayLine(const vpImage<vpRGBa> &I, const std::vector<vpImagePoint> &ips, bool closeTheShape, 858 const vpColor &color, unsigned int thickness = 1); 859 static void displayLine(const vpImage<vpRGBa> &I, const std::list<vpImagePoint> &ips, bool closeTheShape, 860 const vpColor &color, unsigned int thickness = 1); 861 static void displayPoint(const vpImage<vpRGBa> &I, const vpImagePoint &ip, const vpColor &color, 862 unsigned int thickness = 1); 863 static void displayPoint(const vpImage<vpRGBa> &I, int i, int j, const vpColor &color, unsigned int thickness = 1); 864 static void displayPolygon(const vpImage<vpRGBa> &I, const std::vector<vpImagePoint> &vip, const vpColor &color, 865 unsigned int thickness = 1, bool closed = true); 866 static void displayRectangle(const vpImage<vpRGBa> &I, const vpImagePoint &topLeft, unsigned int width, 867 unsigned int height, const vpColor &color, bool fill = false, 868 unsigned int thickness = 1); 869 static void displayRectangle(const vpImage<vpRGBa> &I, const vpImagePoint &topLeft, const vpImagePoint &bottomRight, 870 const vpColor &color, bool fill = false, unsigned int thickness = 1); 871 static void displayRectangle(const vpImage<vpRGBa> &I, const vpRect &rectangle, const vpColor &color, 872 bool fill = false, unsigned int thickness = 1); 873 static void displayRectangle(const vpImage<vpRGBa> &I, const vpImagePoint ¢er, float angle, unsigned int width, 874 unsigned int height, const vpColor &color, unsigned int thickness = 1); 875 static void displayRectangle(const vpImage<vpRGBa> &I, int i, int j, unsigned int width, unsigned int height, 876 const vpColor &color, bool fill = false, unsigned int thickness = 1); 877 static void displayRectangle(const vpImage<vpRGBa> &I, unsigned int i, unsigned int j, float angle, 878 unsigned int width, unsigned int height, const vpColor &color, 879 unsigned int thickness = 1); 880 static void displayROI(const vpImage<vpRGBa> &I, const vpRect &roi); 881 static void displayText(const vpImage<vpRGBa> &I, const vpImagePoint &ip, const std::string &s, const vpColor &color); 882 static void displayText(const vpImage<vpRGBa> &I, int i, int j, const std::string &s, const vpColor &color); 883 884 static void flush(const vpImage<vpRGBa> &I); 885 static void flushROI(const vpImage<vpRGBa> &I, const vpRect &roi); 886 887 static bool getClick(const vpImage<vpRGBa> &I, bool blocking = true); 888 static bool getClick(const vpImage<vpRGBa> &I, vpImagePoint &ip, bool blocking = true); 889 static bool getClick(const vpImage<vpRGBa> &I, vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, 890 bool blocking = true); 891 static bool getClick(const vpImage<vpRGBa> &I, vpMouseButton::vpMouseButtonType &button, bool blocking = true); 892 static bool getClickUp(const vpImage<vpRGBa> &I, vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, 893 bool blocking = true); 894 static bool getClickUp(const vpImage<vpRGBa> &I, vpMouseButton::vpMouseButtonType &button, bool blocking = true); 895 static unsigned int getDownScalingFactor(const vpImage<vpRGBa> &I); 896 static void getImage(const vpImage<vpRGBa> &Is, vpImage<vpRGBa> &Id); 897 static bool getKeyboardEvent(const vpImage<vpRGBa> &I, bool blocking = true); 898 static bool getKeyboardEvent(const vpImage<vpRGBa> &I, std::string &key, bool blocking = true); 899 static bool getKeyboardEvent(const vpImage<vpRGBa> &I, char *key, bool blocking = true); 900 static bool getPointerMotionEvent(const vpImage<vpRGBa> &I, vpImagePoint &ip); 901 static bool getPointerPosition(const vpImage<vpRGBa> &I, vpImagePoint &ip); 902 903 static void setBackground(const vpImage<vpRGBa> &I, const vpColor &color); 904 static void setFont(const vpImage<vpRGBa> &I, const std::string &font); 905 static void setTitle(const vpImage<vpRGBa> &I, const std::string &windowtitle); 906 static void setWindowPosition(const vpImage<vpRGBa> &I, int winx, int winy); 907 //@} 908 909 private: 910 //! get the window pixmap and put it in vpRGBa image 911 virtual void getImage(vpImage<vpRGBa> &I) = 0; 912 }; 913 914 #endif 915