Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
vpDisplay_rgba.cpp
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  * Display implementation.
33  *
34  * Authors:
35  * Fabien Spindler
36  *
37  *****************************************************************************/
38 
39 #include <visp3/core/vpDisplay.h>
40 
41 #include "vpDisplay_impl.h"
42 
43 //************************************************************************
44 // Modifications done in this file should be reported in all vpDisplay_*.cpp
45 // files that implement other types (unsigned char, vpRGB, vpRGBa)
46 //************************************************************************
47 
51 void vpDisplay::close(vpImage<vpRGBa> &I) { vp_display_close(I); }
52 
61 void vpDisplay::displayArrow(const vpImage<vpRGBa> &I, const vpImagePoint &ip1, const vpImagePoint &ip2,
62  const vpColor &color, unsigned int w, unsigned int h, unsigned int thickness)
63 {
64  vp_display_display_arrow(I, ip1, ip2, color, w, h, thickness);
65 }
66 
77 void vpDisplay::displayArrow(const vpImage<vpRGBa> &I, int i1, int j1, int i2, int j2, const vpColor &color,
78  unsigned int w, unsigned int h, unsigned int thickness)
79 {
80  vp_display_display_arrow(I, i1, j1, i2, j2, color, w, h, thickness);
81 }
82 
97  double size, const vpColor &color, unsigned int thickness)
98 {
99  vp_display_display_camera(I, cMo, cam, size, color, thickness);
100 }
101 
115 void vpDisplay::displayCharString(const vpImage<vpRGBa> &I, const vpImagePoint &ip, const char *string,
116  const vpColor &color)
117 {
118  vp_display_display_char_string(I, ip, string, color);
119 }
120 
134 void vpDisplay::displayCharString(const vpImage<vpRGBa> &I, int i, int j, const char *string, const vpColor &color)
135 {
136  vp_display_display_char_string(I, i, j, string, color);
137 }
138 
149 void vpDisplay::displayCircle(const vpImage<vpRGBa> &I, const vpImagePoint &center, unsigned int radius,
150  const vpColor &color, bool fill, unsigned int thickness)
151 {
152  vp_display_display_circle(I, center, radius, color, fill, thickness);
153 }
154 
165 void vpDisplay::displayCircle(const vpImage<vpRGBa> &I, int i, int j, unsigned int radius, const vpColor &color,
166  bool fill, unsigned int thickness)
167 {
168  vp_display_display_circle(I, i, j, radius, color, fill, thickness);
169 }
170 
179 void vpDisplay::displayCross(const vpImage<vpRGBa> &I, const vpImagePoint &ip, unsigned int size, const vpColor &color,
180  unsigned int thickness)
181 {
182  vp_display_display_cross(I, ip, size, color, thickness);
183 }
184 
193 void vpDisplay::displayCross(const vpImage<vpRGBa> &I, int i, int j, unsigned int size, const vpColor &color,
194  unsigned int thickness)
195 {
196  vp_display_display_cross(I, i, j, size, color, thickness);
197 }
198 
207  const vpColor &color, unsigned int thickness)
208 {
209  vp_display_display_dot_line(I, ip1, ip2, color, thickness);
210 }
211 
220 void vpDisplay::displayDotLine(const vpImage<vpRGBa> &I, int i1, int j1, int i2, int j2, const vpColor &color,
221  unsigned int thickness)
222 {
223  vp_display_display_dot_line(I, i1, j1, i2, j2, color, thickness);
224 }
225 
234 void vpDisplay::displayDotLine(const vpImage<vpRGBa> &I, const std::vector<vpImagePoint> &ips, const bool closeTheShape,
235  const vpColor &color, unsigned int thickness)
236 {
237  if (ips.size() <= 1)
238  return;
239 
240  for (size_t i = 0; i < ips.size() - 1; i++)
241  vp_display_display_dot_line(I, ips[i], ips[i + 1], color, thickness);
242 
243  if (closeTheShape)
244  vp_display_display_dot_line(I, ips.front(), ips.back(), color, thickness);
245 }
246 
295 void vpDisplay::displayEllipse(const vpImage<vpRGBa> &I, const vpImagePoint &center, const double &coef1,
296  const double &coef2, const double &coef3, bool use_centered_moments,
297  const vpColor &color, unsigned int thickness)
298 {
299  vpDisplay::displayEllipse(I, center, coef1, coef2, coef3, 0., vpMath::rad(360), use_centered_moments, color,
300  thickness);
301 }
302 
356 void vpDisplay::displayEllipse(const vpImage<vpRGBa> &I, const vpImagePoint &center, const double &coef1,
357  const double &coef2, const double &coef3, const double &theta1, const double &theta2,
358  bool use_centered_moments, const vpColor &color, unsigned int thickness)
359 {
360  vp_display_display_ellipse(I, center, coef1, coef2, coef3, theta1, theta2, use_centered_moments, color, thickness);
361 }
362 
379  double size, const vpColor &color, unsigned int thickness, const vpImagePoint &offset)
380 {
381  vp_display_display_frame(I, cMo, cam, size, color, thickness, offset);
382 }
383 
391 void vpDisplay::displayLine(const vpImage<vpRGBa> &I, const vpImagePoint &ip1, const vpImagePoint &ip2,
392  const vpColor &color, unsigned int thickness)
393 {
394  vp_display_display_line(I, ip1, ip2, color, thickness);
395 }
396 
405 void vpDisplay::displayLine(const vpImage<vpRGBa> &I, int i1, int j1, int i2, int j2, const vpColor &color,
406  unsigned int thickness)
407 {
408  vp_display_display_line(I, i1, j1, i2, j2, color, thickness);
409 }
410 
418 void vpDisplay::displayLine(const vpImage<vpRGBa> &I, const std::vector<vpImagePoint> &ips, const bool closeTheShape,
419  const vpColor &color, unsigned int thickness)
420 {
421  if (ips.size() <= 1)
422  return;
423 
424  for (size_t i = 0; i < ips.size() - 1; i++)
425  vp_display_display_line(I, ips[i], ips[i + 1], color, thickness);
426 
427  if (closeTheShape)
428  vp_display_display_line(I, ips.front(), ips.back(), color, thickness);
429 }
430 
438 void vpDisplay::displayPoint(const vpImage<vpRGBa> &I, const vpImagePoint &ip, const vpColor &color,
439  unsigned int thickness)
440 {
441  vp_display_display_point(I, ip, color, thickness);
442 }
443 
451 void vpDisplay::displayPoint(const vpImage<vpRGBa> &I, int i, int j, const vpColor &color, unsigned int thickness)
452 {
453  vp_display_display_point(I, i, j, color, thickness);
454 }
455 
463 void vpDisplay::displayPolygon(const vpImage<vpRGBa> &I, const std::vector<vpImagePoint> &vip, const vpColor &color,
464  unsigned int thickness)
465 {
466  vp_display_display_polygon(I, vip, color, thickness);
467 }
468 
483 void vpDisplay::displayRectangle(const vpImage<vpRGBa> &I, const vpImagePoint &topLeft, unsigned int width,
484  unsigned int height, const vpColor &color, bool fill, unsigned int thickness)
485 {
486  vp_display_display_rectangle(I, topLeft, width, height, color, fill, thickness);
487 }
488 
503 void vpDisplay::displayRectangle(const vpImage<vpRGBa> &I, int i, int j, unsigned int width, unsigned int height,
504  const vpColor &color, bool fill, unsigned int thickness)
505 {
506  vp_display_display_rectangle(I, i, j, width, height, color, fill, thickness);
507 }
508 
522 void vpDisplay::displayRectangle(const vpImage<vpRGBa> &I, const vpRect &rectangle, const vpColor &color, bool fill,
523  unsigned int thickness)
524 {
525  vp_display_display_rectangle(I, rectangle, color, fill, thickness);
526 }
527 
541 void vpDisplay::displayRectangle(const vpImage<vpRGBa> &I, const vpImagePoint &center, float angle, unsigned int width,
542  unsigned int height, const vpColor &color, unsigned int thickness)
543 {
544  vp_display_display_rectangle(I, center, angle, width, height, color, thickness);
545 }
546 
561 void vpDisplay::displayRectangle(const vpImage<vpRGBa> &I, const vpImagePoint &topLeft, const vpImagePoint &bottomRight,
562  const vpColor &color, bool fill, unsigned int thickness)
563 {
564  vp_display_display_rectangle(I, topLeft, bottomRight, color, fill, thickness);
565 }
566 
580 void vpDisplay::displayRectangle(const vpImage<vpRGBa> &I, unsigned int i, unsigned int j, float angle,
581  unsigned int width, unsigned int height, const vpColor &color, unsigned int thickness)
582 {
583  vp_display_display_rectangle(I, i, j, angle, width, height, color, thickness);
584 }
585 
598 void vpDisplay::displayText(const vpImage<vpRGBa> &I, const vpImagePoint &ip, const std::string &s,
599  const vpColor &color)
600 {
601  vp_display_display_text(I, ip, s, color);
602 }
603 
616 void vpDisplay::displayText(const vpImage<vpRGBa> &I, int i, int j, const std::string &s, const vpColor &color)
617 {
618  vp_display_display_text(I, i, j, s, color);
619 }
620 
650 void vpDisplay::flush(const vpImage<vpRGBa> &I) { vp_display_flush(I); }
651 
661 void vpDisplay::flushROI(const vpImage<vpRGBa> &I, const vpRect &roi) { vp_display_flush_roi(I, roi); }
662 
674 void vpDisplay::display(const vpImage<vpRGBa> &I) { vp_display_display(I); }
675 
680 void vpDisplay::displayROI(const vpImage<vpRGBa> &I, const vpRect &roi) { vp_display_display_roi(I, roi); }
681 
699 bool vpDisplay::getClick(const vpImage<vpRGBa> &I, bool blocking) { return vp_display_get_click(I, blocking); }
700 
719 bool vpDisplay::getClick(const vpImage<vpRGBa> &I, vpImagePoint &ip, bool blocking)
720 {
721  return vp_display_get_click(I, ip, blocking);
722 }
723 
745  bool blocking)
746 {
747  return vp_display_get_click(I, ip, button, blocking);
748 }
749 
767 {
768  vpImagePoint ip;
769  return vpDisplay::getClick(I, ip, button, blocking);
770 }
771 
793  bool blocking)
794 {
795  return vp_display_get_click_up(I, ip, button, blocking);
796 }
797 
815 {
816  vpImagePoint ip;
817  return vpDisplay::getClickUp(I, ip, button, blocking);
818 }
819 
902 bool vpDisplay::getKeyboardEvent(const vpImage<vpRGBa> &I, bool blocking)
903 {
904  return vp_display_get_keyboard_event(I, blocking);
905 }
906 
993 bool vpDisplay::getKeyboardEvent(const vpImage<vpRGBa> &I, std::string &key, bool blocking)
994 {
995  return vp_display_get_keyboard_event(I, key, blocking);
996 }
997 
1084 bool vpDisplay::getKeyboardEvent(const vpImage<vpRGBa> &I, char *key, bool blocking)
1085 {
1086  return vp_display_get_keyboard_event(I, key, blocking);
1087 }
1088 
1099 {
1100  return vp_display_get_pointer_motion_event(I, ip);
1101 }
1102 
1113 {
1114  return vp_display_get_pointer_position(I, ip);
1115 }
1116 
1126 void vpDisplay::setBackground(const vpImage<vpRGBa> &I, const vpColor &color) { vp_display_set_background(I, color); }
1127 
1141 void vpDisplay::setFont(const vpImage<vpRGBa> &I, const std::string &fontname) { vp_display_set_font(I, fontname); }
1142 
1150 void vpDisplay::setTitle(const vpImage<vpRGBa> &I, const std::string &windowtitle)
1151 {
1152  vp_display_set_title(I, windowtitle);
1153 }
1154 
1165 void vpDisplay::setWindowPosition(const vpImage<vpRGBa> &I, int winx, int winy)
1166 {
1167  vp_display_set_window_position(I, winx, winy);
1168 }
1169 
1179 unsigned int vpDisplay::getDownScalingFactor(const vpImage<vpRGBa> &I) { return vp_display_get_down_scaling_factor(I); }
static void displayCamera(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, const vpColor &color, unsigned int thickness)
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)
static bool getPointerPosition(const vpImage< unsigned char > &I, vpImagePoint &ip)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void close(vpImage< unsigned char > &I)
static bool getPointerMotionEvent(const vpImage< unsigned char > &I, vpImagePoint &ip)
Implementation of an homogeneous matrix and operations on such kind of matrices.
static void displayPolygon(const vpImage< unsigned char > &I, const std::vector< vpImagePoint > &vip, const vpColor &color, unsigned int thickness=1)
Class to define colors available for display functionnalities.
Definition: vpColor.h:120
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
static bool getClickUp(const vpImage< unsigned char > &I, vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)
static void displayPoint(const vpImage< unsigned char > &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
static void flush(const vpImage< unsigned char > &I)
static void setFont(const vpImage< unsigned char > &I, const std::string &font)
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)
static void display(const vpImage< unsigned char > &I)
Generic class defining intrinsic camera parameters.
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)
static double rad(double deg)
Definition: vpMath.h:102
static void displayCircle(const vpImage< unsigned char > &I, const vpImagePoint &center, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static void setWindowPosition(const vpImage< unsigned char > &I, int winx, int winy)
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, const vpImagePoint &offset=vpImagePoint(0, 0))
unsigned int getDownScalingFactor()
Definition: vpDisplay.h:229
static void setBackground(const vpImage< unsigned char > &I, const vpColor &color)
Defines a rectangle in the plane.
Definition: vpRect.h:78
static void flushROI(const vpImage< unsigned char > &I, const vpRect &roi)
static void displayROI(const vpImage< unsigned char > &I, const vpRect &roi)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
static bool getKeyboardEvent(const vpImage< unsigned char > &I, bool blocking=true)
static void displayCharString(const vpImage< unsigned char > &I, const vpImagePoint &ip, const char *string, const vpColor &color)
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)
static void displayDotLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)