Visual Servoing Platform  version 3.2.1 under development (2019-05-26)
vpDisplay_uchar.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<unsigned char> &I) { vp_display_close(I); }
52 
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<unsigned char> &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  const vpCameraParameters &cam, 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<unsigned char> &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<unsigned char> &I, int i, int j, const char *string,
135  const vpColor &color)
136 {
137  vp_display_display_char_string(I, i, j, string, color);
138 }
139 
150 void vpDisplay::displayCircle(const vpImage<unsigned char> &I, const vpImagePoint &center, unsigned int radius,
151  const vpColor &color, bool fill, unsigned int thickness)
152 {
153  vp_display_display_circle(I, center, radius, color, fill, thickness);
154 }
155 
166 void vpDisplay::displayCircle(const vpImage<unsigned char> &I, int i, int j, unsigned int radius, const vpColor &color,
167  bool fill, unsigned int thickness)
168 {
169  vp_display_display_circle(I, i, j, radius, color, fill, thickness);
170 }
171 
180 void vpDisplay::displayCross(const vpImage<unsigned char> &I, const vpImagePoint &ip, unsigned int size,
181  const vpColor &color, unsigned int thickness)
182 {
183  vp_display_display_cross(I, ip, size, color, thickness);
184 }
185 
194 void vpDisplay::displayCross(const vpImage<unsigned char> &I, int i, int j, unsigned int size, const vpColor &color,
195  unsigned int thickness)
196 {
197  vp_display_display_cross(I, i, j, size, color, thickness);
198 }
199 
208  const vpColor &color, unsigned int thickness)
209 {
210  vp_display_display_dot_line(I, ip1, ip2, color, thickness);
211 }
212 
221 void vpDisplay::displayDotLine(const vpImage<unsigned char> &I, int i1, int j1, int i2, int j2, const vpColor &color,
222  unsigned int thickness)
223 {
224  vp_display_display_dot_line(I, i1, j1, i2, j2, color, thickness);
225 }
226 
235 void vpDisplay::displayDotLine(const vpImage<unsigned char> &I, const std::vector<vpImagePoint> &ips,
236  const bool closeTheShape, const vpColor &color, unsigned int thickness)
237 {
238  if (ips.size() <= 1)
239  return;
240 
241  for (size_t i = 0; i < ips.size() - 1; i++)
242  vp_display_display_dot_line(I, ips[i], ips[i + 1], color, thickness);
243 
244  if (closeTheShape)
245  vp_display_display_dot_line(I, ips.front(), ips.back(), color, thickness);
246 }
247 
296 void vpDisplay::displayEllipse(const vpImage<unsigned char> &I, const vpImagePoint &center, const double &coef1,
297  const double &coef2, const double &coef3, bool use_centered_moments,
298  const vpColor &color, unsigned int thickness)
299 {
300  vpDisplay::displayEllipse(I, center, coef1, coef2, coef3, 0., vpMath::rad(360), use_centered_moments, color,
301  thickness);
302 }
303 
356 void vpDisplay::displayEllipse(const vpImage<unsigned char> &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  const vpCameraParameters &cam, double size, const vpColor &color, unsigned int thickness,
380  const vpImagePoint &offset)
381 {
382  vp_display_display_frame(I, cMo, cam, size, color, thickness, offset);
383 }
384 
393  const vpColor &color, unsigned int thickness)
394 {
395  vp_display_display_line(I, ip1, ip2, color, thickness);
396 }
397 
406 void vpDisplay::displayLine(const vpImage<unsigned char> &I, int i1, int j1, int i2, int j2, const vpColor &color,
407  unsigned int thickness)
408 {
409  vp_display_display_line(I, i1, j1, i2, j2, color, thickness);
410 }
411 
419 void vpDisplay::displayLine(const vpImage<unsigned char> &I, const std::vector<vpImagePoint> &ips,
420  const bool closeTheShape, const vpColor &color, unsigned int thickness)
421 {
422  if (ips.size() <= 1)
423  return;
424 
425  for (size_t i = 0; i < ips.size() - 1; i++)
426  vp_display_display_line(I, ips[i], ips[i + 1], color, thickness);
427 
428  if (closeTheShape)
429  vp_display_display_line(I, ips.front(), ips.back(), color, thickness);
430 }
431 
440  unsigned int thickness)
441 {
442  vp_display_display_point(I, ip, color, thickness);
443 }
444 
452 void vpDisplay::displayPoint(const vpImage<unsigned char> &I, int i, int j, const vpColor &color,
453  unsigned int thickness)
454 {
455  vp_display_display_point(I, i, j, color, thickness);
456 }
457 
465 void vpDisplay::displayPolygon(const vpImage<unsigned char> &I, const std::vector<vpImagePoint> &vip,
466  const vpColor &color, unsigned int thickness)
467 {
468  vp_display_display_polygon(I, vip, color, thickness);
469 }
470 
485 void vpDisplay::displayRectangle(const vpImage<unsigned char> &I, const vpImagePoint &topLeft, unsigned int width,
486  unsigned int height, const vpColor &color, bool fill, unsigned int thickness)
487 {
488  vp_display_display_rectangle(I, topLeft, width, height, color, fill, thickness);
489 }
490 
505 void vpDisplay::displayRectangle(const vpImage<unsigned char> &I, int i, int j, unsigned int width, unsigned int height,
506  const vpColor &color, bool fill, unsigned int thickness)
507 {
508  vp_display_display_rectangle(I, i, j, width, height, color, fill, thickness);
509 }
510 
524 void vpDisplay::displayRectangle(const vpImage<unsigned char> &I, const vpRect &rectangle, const vpColor &color,
525  bool fill, unsigned int thickness)
526 {
527  vp_display_display_rectangle(I, rectangle, color, fill, thickness);
528 }
529 
543 void vpDisplay::displayRectangle(const vpImage<unsigned char> &I, const vpImagePoint &center, float angle,
544  unsigned int width, unsigned int height, const vpColor &color, unsigned int thickness)
545 {
546  vp_display_display_rectangle(I, center, angle, width, height, color, thickness);
547 }
548 
564  const vpImagePoint &bottomRight, const vpColor &color, bool fill,
565  unsigned int thickness)
566 {
567  vp_display_display_rectangle(I, topLeft, bottomRight, color, fill, thickness);
568 }
569 
583 void vpDisplay::displayRectangle(const vpImage<unsigned char> &I, unsigned int i, unsigned int j, float angle,
584  unsigned int width, unsigned int height, const vpColor &color, unsigned int thickness)
585 {
586  vp_display_display_rectangle(I, i, j, angle, width, height, color, thickness);
587 }
588 
601 void vpDisplay::displayText(const vpImage<unsigned char> &I, const vpImagePoint &ip, const std::string &s,
602  const vpColor &color)
603 {
604  vp_display_display_text(I, ip, s, color);
605 }
606 
619 void vpDisplay::displayText(const vpImage<unsigned char> &I, int i, int j, const std::string &s, const vpColor &color)
620 {
621  vp_display_display_text(I, i, j, s, color);
622 }
623 
653 void vpDisplay::flush(const vpImage<unsigned char> &I) { vp_display_flush(I); }
654 
664 void vpDisplay::flushROI(const vpImage<unsigned char> &I, const vpRect &roi) { vp_display_flush_roi(I, roi); }
665 
677 void vpDisplay::display(const vpImage<unsigned char> &I) { vp_display_display(I); }
678 
683 void vpDisplay::displayROI(const vpImage<unsigned char> &I, const vpRect &roi) { vp_display_display_roi(I, roi); }
684 
702 bool vpDisplay::getClick(const vpImage<unsigned char> &I, bool blocking) { return vp_display_get_click(I, blocking); }
703 
722 bool vpDisplay::getClick(const vpImage<unsigned char> &I, vpImagePoint &ip, bool blocking)
723 {
724  return vp_display_get_click(I, ip, blocking);
725 }
726 
748  bool blocking)
749 {
750  return vp_display_get_click(I, ip, button, blocking);
751 }
752 
770 {
771  vpImagePoint ip;
772  return vpDisplay::getClick(I, ip, button, blocking);
773 }
774 
796  bool blocking)
797 {
798  return vp_display_get_click_up(I, ip, button, blocking);
799 }
800 
818 {
819  vpImagePoint ip;
820  return vpDisplay::getClickUp(I, ip, button, blocking);
821 }
822 
907 {
908  return vp_display_get_keyboard_event(I, blocking);
909 }
910 
997 bool vpDisplay::getKeyboardEvent(const vpImage<unsigned char> &I, std::string &key, bool blocking)
998 {
999  return vp_display_get_keyboard_event(I, key, blocking);
1000 }
1001 
1088 bool vpDisplay::getKeyboardEvent(const vpImage<unsigned char> &I, char *key, bool blocking)
1089 {
1090  return vp_display_get_keyboard_event(I, key, blocking);
1091 }
1092 
1103 {
1104  return vp_display_get_pointer_motion_event(I, ip);
1105 }
1106 
1117 {
1118  return vp_display_get_pointer_position(I, ip);
1119 }
1120 
1131 {
1132  vp_display_set_background(I, color);
1133 }
1134 
1148 void vpDisplay::setFont(const vpImage<unsigned char> &I, const std::string &fontname)
1149 {
1150  vp_display_set_font(I, fontname);
1151 }
1152 
1160 void vpDisplay::setTitle(const vpImage<unsigned char> &I, const std::string &windowtitle)
1161 {
1162  vp_display_set_title(I, windowtitle);
1163 }
1164 
1175 void vpDisplay::setWindowPosition(const vpImage<unsigned char> &I, int winx, int winy)
1176 {
1177  vp_display_set_window_position(I, winx, winy);
1178 }
1179 
1190 {
1191  return vp_display_get_down_scaling_factor(I);
1192 }
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:108
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)