Visual Servoing Platform  version 3.0.0
vpDisplay.cpp
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 #include <limits>
40 
41 #include <visp3/core/vpDisplay.h>
42 #include <visp3/core/vpDisplayException.h>
43 #include <visp3/core/vpImageConvert.h>
44 
45 #include <visp3/core/vpPoint.h>
46 #include <visp3/core/vpMeterPixelConversion.h>
47 #include <visp3/core/vpMath.h>
48 
49 
59  : displayHasBeenInitialized(false), windowXPosition(0), windowYPosition(0), width(0), height(0), title_() {}
60 
65  : displayHasBeenInitialized(false), windowXPosition(0), windowYPosition(0), width(0), height(0), title_()
66 {
70 
71  width = d.width;
72  height = d.height;
73 }
74 
79 {
81 }
82 
96 void
98  const char *fontname )
99 {
100 
101  try
102  {
103  if ( I.display != NULL )
104  {
105  ( I.display )->setFont ( fontname ) ;
106  }
107  }
108  catch ( ... )
109  {
110  vpERROR_TRACE ( "Error caught" ) ;
111  throw ;
112  }
113 }
121 void
123  const char *windowtitle )
124 {
125 
126  try
127  {
128  if ( I.display != NULL )
129  {
130  ( I.display )->setTitle ( windowtitle ) ;
131  }
132  }
133  catch ( ... )
134  {
135  vpERROR_TRACE ( "Error caught" ) ;
136  throw ;
137  }
138 }
139 
149 void
151  int winx, int winy )
152 {
153 
154  try
155  {
156  if ( I.display != NULL )
157  {
158  ( I.display )->setWindowPosition ( winx, winy ) ;
159  }
160  }
161  catch ( ... )
162  {
163  vpERROR_TRACE ( "Error caught" ) ;
164  throw ;
165  }
166 }
167 
177 void
179 {
180  try
181  {
182  if ( I.display != NULL )
183  {
184  ( I.display )->clearDisplay ( color ) ;
185  }
186  }
187  catch ( ... )
188  {
189  vpERROR_TRACE ( "Error caught" ) ;
190  throw ;
191  }
192 }
193 
205 void
207 {
208 
209  try
210  {
211  if ( I.display != NULL )
212  {
213  ( I.display )->displayImage ( I ) ;
214  }
215  }
216  catch ( ... )
217  {
218  vpERROR_TRACE ( "Error caught" ) ;
219  throw ;
220  }
221 }
222 
223 
224 void
226 {
227  vpImagePoint topLeft;
228  double top = floor(roi.getTop());
229  double left = floor(roi.getLeft());
230  double roiheight = floor(roi.getHeight());
231  double roiwidth = floor(roi.getWidth());
232  double iheight = (double)(I.getHeight());
233  double iwidth = (double)(I.getWidth());
234 
235  if (top < 0 || top > iheight || left < 0 || left > iwidth || top+roiheight > iheight || left+roiwidth > iwidth)
236  {
237  vpERROR_TRACE ( "Region of interest outside of the image" ) ;
238  throw ( vpException ( vpException::dimensionError,"Region of interest outside of the image" ) ) ;
239  }
240 
241  try
242  {
243  if ( I.display != NULL )
244  {
245  ( I.display )->displayImageROI ( I , vpImagePoint(top,left), (unsigned int)roiwidth,(unsigned int)roiheight ) ;
246  }
247  }
248  catch ( ... )
249  {
250  vpERROR_TRACE ( "Error caught" ) ;
251  throw ;
252  }
253 }
254 
255 
256 
323 void
325  vpImage<vpRGBa> &Idest )
326 {
327 
328  try
329  {
330  if ( Isrc.display != NULL )
331  {
332  ( Isrc.display )->getImage ( Idest ) ;
333  }
334  else
335  {
336  vpImageConvert::convert(Isrc, Idest);
337 // vpERROR_TRACE ( "Display not initialized" ) ;
338 // throw ( vpDisplayException ( vpDisplayException::notInitializedError,
339 // "Display not initialized" ) ) ;
340  }
341  }
342  catch ( ... )
343  {
344  vpERROR_TRACE ( "Error caught" ) ;
345  throw ;
346  }
347 }
348 
349 
372 void
374  const vpHomogeneousMatrix &cMo,
375  const vpCameraParameters &cam,
376  double size, const vpColor &color,
377  unsigned int thickness,
378  vpImagePoint offset)
379 {
380  // used by display
381  vpPoint o( 0.0, 0.0, 0.0);
382  vpPoint x(size, 0.0, 0.0);
383  vpPoint y( 0.0, size, 0.0);
384  vpPoint z( 0.0, 0.0, size);
385 
386  o.track ( cMo ) ;
387  x.track ( cMo ) ;
388  y.track ( cMo ) ;
389  z.track ( cMo ) ;
390 
391  vpImagePoint ipo, ip1;
392 
393  if ( color == vpColor::none )
394  {
395  vpMeterPixelConversion::convertPoint ( cam, o.p[0], o.p[1], ipo) ;
396 
397  vpMeterPixelConversion::convertPoint ( cam, x.p[0], x.p[1], ip1) ;
398  vpDisplay::displayArrow ( I, ipo+offset, ip1+offset, vpColor::red, 4*thickness, 2*thickness, thickness) ;
399 
400  vpMeterPixelConversion::convertPoint ( cam, y.p[0], y.p[1], ip1) ;
401  vpDisplay::displayArrow ( I, ipo+offset, ip1+offset, vpColor::green, 4*thickness, 2*thickness, thickness) ;
402 
403  vpMeterPixelConversion::convertPoint ( cam, z.p[0], z.p[1], ip1) ;
404  vpDisplay::displayArrow ( I, ipo+offset, ip1+offset, vpColor::blue, 4*thickness, 2*thickness, thickness) ;
405  }
406  else
407  {
408  vpMeterPixelConversion::convertPoint ( cam, o.p[0], o.p[1], ipo) ;
409 
410  vpMeterPixelConversion::convertPoint ( cam, x.p[0], x.p[1], ip1) ;
411  vpDisplay::displayArrow ( I, ipo+offset, ip1+offset, color, 4*thickness, 2*thickness, thickness) ;
412 
413  vpMeterPixelConversion::convertPoint ( cam, y.p[0], y.p[1], ip1) ;
414  vpDisplay::displayArrow ( I, ipo+offset, ip1+offset, color, 4*thickness, 2*thickness, thickness) ;
415 
416  vpMeterPixelConversion::convertPoint ( cam, z.p[0], z.p[1], ip1) ;
417  vpDisplay::displayArrow ( I, ipo+offset, ip1+offset, color, 4*thickness, 2*thickness, thickness) ;
418 
419  }
420 }
421 
422 
444 void
446  const vpHomogeneousMatrix &cMo,
447  const vpCameraParameters &cam,
448  double size, const vpColor &color,
449  unsigned int thickness,
450  vpImagePoint offset)
451 {
452  // used by display
453  vpPoint o( 0.0, 0.0, 0.0);
454  vpPoint x(size, 0.0, 0.0);
455  vpPoint y( 0.0, size, 0.0);
456  vpPoint z( 0.0, 0.0, size);
457 
458  o.track ( cMo ) ;
459  x.track ( cMo ) ;
460  y.track ( cMo ) ;
461  z.track ( cMo ) ;
462 
463  vpImagePoint ipo, ip1;
464  if ( color == vpColor::none )
465  {
466  vpMeterPixelConversion::convertPoint ( cam, o.p[0], o.p[1], ipo) ;
467 
468  vpMeterPixelConversion::convertPoint ( cam, x.p[0], x.p[1], ip1) ;
469  vpDisplay::displayArrow ( I, ipo+offset, ip1+offset, vpColor::red, 4, 2, thickness) ;
470 
471  vpMeterPixelConversion::convertPoint ( cam, y.p[0], y.p[1], ip1) ;
472  vpDisplay::displayArrow ( I, ipo+offset, ip1+offset, vpColor::green, 4, 2, thickness) ;
473 
474  vpMeterPixelConversion::convertPoint ( cam, z.p[0], z.p[1], ip1) ;
475  vpDisplay::displayArrow ( I,ipo+offset, ip1+offset, vpColor::blue, 4, 2, thickness) ;
476  }
477  else
478  {
479  vpMeterPixelConversion::convertPoint ( cam, o.p[0], o.p[1], ipo) ;
480 
481  vpMeterPixelConversion::convertPoint ( cam, x.p[0], x.p[1], ip1) ;
482  vpDisplay::displayArrow ( I, ipo+offset, ip1+offset, color, 4*thickness, 2*thickness, thickness) ;
483 
484  vpMeterPixelConversion::convertPoint ( cam, y.p[0], y.p[1], ip1) ;
485  vpDisplay::displayArrow ( I, ipo+offset, ip1+offset, color, 4*thickness, 2*thickness, thickness) ;
486 
487  vpMeterPixelConversion::convertPoint ( cam, z.p[0], z.p[1], ip1) ;
488  vpDisplay::displayArrow ( I, ipo+offset, ip1+offset, color, 4*thickness, 2*thickness, thickness) ;
489 
490  }
491 }
492 
513 void
515  const vpHomogeneousMatrix &cMo,
516  const vpCameraParameters &cam,
517  double size, const vpColor &color,
518  unsigned int thickness)
519 {
520  // used by display
521  double halfSize = size/2.0;
522  vpPoint pt[5];
523  pt[0].setWorldCoordinates ( -halfSize,-halfSize,0.0 );
524  pt[1].setWorldCoordinates ( halfSize,-halfSize,0.0 );
525  pt[2].setWorldCoordinates ( halfSize,halfSize,0.0 );
526  pt[3].setWorldCoordinates ( -halfSize,halfSize,0.0 );
527  pt[4].setWorldCoordinates ( 0.0,0.0,-size );
528 
529  for (int i = 0; i < 5; i++)
530  pt[i].track ( cMo ) ;
531 
532  vpImagePoint ip, ip_1, ip0;
533  vpMeterPixelConversion::convertPoint ( cam, pt[4].p[0], pt[4].p[1], ip0);
534 
535  for (int i = 0; i < 4; i++)
536  {
537  vpMeterPixelConversion::convertPoint ( cam, pt[i].p[0], pt[i].p[1], ip_1);
538  vpMeterPixelConversion::convertPoint ( cam, pt[(i+1)%4].p[0], pt[(i+1)%4].p[1], ip);
539  vpDisplay::displayLine ( I, ip_1, ip, color, thickness);
540  vpDisplay::displayLine ( I, ip0, ip_1, color, thickness);
541  }
542 }
543 
544 
565 void
567  const vpHomogeneousMatrix &cMo,
568  const vpCameraParameters &cam,
569  double size, const vpColor &color,
570  unsigned int thickness)
571 {
572  // used by display
573  double halfSize = size/2.0;
574  vpPoint pt[5];
575  pt[0].setWorldCoordinates ( -halfSize,-halfSize,0.0 );
576  pt[1].setWorldCoordinates ( halfSize,-halfSize,0.0 );
577  pt[2].setWorldCoordinates ( halfSize,halfSize,0.0 );
578  pt[3].setWorldCoordinates ( -halfSize,halfSize,0.0 );
579  pt[4].setWorldCoordinates ( 0.0,0.0,-size );
580 
581  for (int i = 0; i < 5; i++)
582  pt[i].track ( cMo ) ;
583 
584  vpImagePoint ip, ip_1, ip0;
585  vpMeterPixelConversion::convertPoint ( cam, pt[4].p[0], pt[4].p[1], ip0);
586 
587  for (int i = 0; i < 4; i++)
588  {
589  vpMeterPixelConversion::convertPoint ( cam, pt[i].p[0], pt[i].p[1], ip_1);
590  vpMeterPixelConversion::convertPoint ( cam, pt[(i+1)%4].p[0], pt[(i+1)%4].p[1], ip);
591  vpDisplay::displayLine ( I, ip_1, ip, color, thickness);
592  vpDisplay::displayLine ( I, ip0, ip_1, color, thickness);
593  }
594 }
595 
604 void
606  const vpImagePoint &ip1, const vpImagePoint &ip2,
607  const vpColor &color,
608  unsigned int w,unsigned int h,
609  unsigned int thickness )
610 {
611  try
612  {
613  if ( I.display != NULL )
614  {
615  ( I.display )->displayArrow ( ip1, ip2, color, w, h, thickness ) ;
616  }
617  }
618  catch ( ... )
619  {
620  vpERROR_TRACE ( "Error caught" ) ;
621  throw ;
622  }
623 }
624 
634 void
636  const vpImagePoint &ip1, const vpImagePoint &ip2,
637  const vpColor &color,
638  unsigned int w,unsigned int h,
639  unsigned int thickness )
640 {
641  try
642  {
643  if ( I.display != NULL )
644  {
645  ( I.display )->displayArrow ( ip1, ip2, color, w, h, thickness ) ;
646  }
647  }
648  catch ( ... )
649  {
650  vpERROR_TRACE ( "Error caught" ) ;
651  throw ;
652  }
653 }
654 
665 void
667  int i1, int j1, int i2, int j2,
668  const vpColor &color,
669  unsigned int w, unsigned int h,
670  unsigned int thickness)
671 {
672  try
673  {
674  if ( I.display != NULL )
675  {
676  vpImagePoint ip1, ip2;
677  ip1.set_i(i1);
678  ip1.set_j(j1);
679  ip2.set_i(i2);
680  ip2.set_j(j2);
681  ( I.display )->displayArrow ( ip1, ip2, color, w, h, thickness ) ;
682  }
683  }
684  catch ( ... )
685  {
686  vpERROR_TRACE ( "Error caught" ) ;
687  throw ;
688  }
689 }
690 
703 void
705  int i1, int j1, int i2, int j2,
706  const vpColor &color,
707  unsigned int w, unsigned int h,
708  unsigned int thickness)
709 {
710  try
711  {
712  if ( I.display != NULL )
713  {
714  vpImagePoint ip1, ip2;
715  ip1.set_i(i1);
716  ip1.set_j(j1);
717  ip2.set_i(i2);
718  ip2.set_j(j2);
719 
720  ( I.display )->displayArrow ( ip1, ip2, color, w, h, thickness ) ;
721  }
722  }
723  catch ( ... )
724  {
725  vpERROR_TRACE ( "Error caught" ) ;
726  throw ;
727  }
728 }
729 
745 void
747  const vpImagePoint &ip, const char *string,
748  const vpColor &color )
749 {
750  try
751  {
752  if ( I.display != NULL )
753  {
754  ( I.display )->displayCharString ( ip, string, color ) ;
755  }
756  }
757  catch ( ... )
758  {
759  vpERROR_TRACE ( "Error caught" ) ;
760  throw ;
761  }
762 }
763 
779 void
781  const vpImagePoint &ip, const char *string,
782  const vpColor &color )
783 {
784  try
785  {
786  if ( I.display != NULL )
787  {
788  ( I.display )->displayCharString ( ip, string, color ) ;
789  }
790  }
791  catch ( ... )
792  {
793  vpERROR_TRACE ( "Error caught" ) ;
794  throw ;
795  }
796 }
797 
813 void
815  int i, int j, const char *string,
816  const vpColor &color)
817 {
818  try
819  {
820  if ( I.display != NULL )
821  {
822  vpImagePoint ip;
823  ip.set_i( i );
824  ip.set_j( j );
825 
826  ( I.display )->displayCharString ( ip, string, color ) ;
827  }
828  }
829  catch ( ... )
830  {
831  vpERROR_TRACE ( "Error caught" ) ;
832  throw ;
833  }
834 }
835 
851 void
853  int i, int j, const char *string,
854  const vpColor &color)
855 {
856  try
857  {
858  if ( I.display != NULL )
859  {
860  vpImagePoint ip;
861  ip.set_i( i );
862  ip.set_j( j );
863  ( I.display )->displayCharString ( ip, string, color ) ;
864  }
865  }
866  catch ( ... )
867  {
868  vpERROR_TRACE ( "Error caught" ) ;
869  throw ;
870  }
871 }
872 
887 void
889  const vpImagePoint &ip, const std::string &s,
890  const vpColor &color )
891 {
892  try
893  {
894  if ( I.display != NULL )
895  {
896  ( I.display )->displayCharString ( ip, s.c_str(), color ) ;
897  }
898  }
899  catch ( ... )
900  {
901  vpERROR_TRACE ( "Error caught" ) ;
902  throw ;
903  }
904 }
905 
920 void
922  const vpImagePoint &ip, const std::string &s,
923  const vpColor &color )
924 {
925  try
926  {
927  if ( I.display != NULL )
928  {
929  ( I.display )->displayCharString ( ip, s.c_str(), color ) ;
930  }
931  }
932  catch ( ... )
933  {
934  vpERROR_TRACE ( "Error caught" ) ;
935  throw ;
936  }
937 }
938 
953 void
955  int i, int j, const std::string &s,
956  const vpColor &color)
957 {
958  try
959  {
960  if ( I.display != NULL )
961  {
962  vpImagePoint ip;
963  ip.set_i( i );
964  ip.set_j( j );
965 
966  ( I.display )->displayCharString ( ip, s.c_str(), color ) ;
967  }
968  }
969  catch ( ... )
970  {
971  vpERROR_TRACE ( "Error caught" ) ;
972  throw ;
973  }
974 }
975 
990 void
992  int i, int j, const std::string &s,
993  const vpColor &color)
994 {
995  try
996  {
997  if ( I.display != NULL )
998  {
999  vpImagePoint ip;
1000  ip.set_i( i );
1001  ip.set_j( j );
1002  ( I.display )->displayCharString ( ip, s.c_str(), color ) ;
1003  }
1004  }
1005  catch ( ... )
1006  {
1007  vpERROR_TRACE ( "Error caught" ) ;
1008  throw ;
1009  }
1010 }
1011 
1022 void
1024  const vpImagePoint &center, unsigned int radius,
1025  const vpColor &color,
1026  bool fill,
1027  unsigned int thickness)
1028 {
1029  try
1030  {
1031  if ( I.display != NULL )
1032  {
1033  ( I.display )->displayCircle ( center, radius, color, fill, thickness ) ;
1034  }
1035  }
1036  catch ( ... )
1037  {
1038  vpERROR_TRACE ( "Error caught" ) ;
1039  throw ;
1040  }
1041 }
1052 void
1054  const vpImagePoint &center, unsigned int radius,
1055  const vpColor &color,
1056  bool fill,
1057  unsigned int thickness )
1058 {
1059  try
1060  {
1061  if ( I.display != NULL )
1062  {
1063  ( I.display )->displayCircle ( center, radius, color, fill, thickness ) ;
1064  }
1065  }
1066  catch ( ... )
1067  {
1068  vpERROR_TRACE ( "Error caught" ) ;
1069  throw ;
1070  }
1071 }
1084 void
1086  int i, int j, unsigned int radius,
1087  const vpColor &color,
1088  bool fill,
1089  unsigned int thickness)
1090 {
1091  try
1092  {
1093  if ( I.display != NULL )
1094  {
1095  vpImagePoint ip;
1096  ip.set_i( i );
1097  ip.set_j( j );
1098 
1099  ( I.display )->displayCircle ( ip, radius, color, fill, thickness ) ;
1100  }
1101  }
1102  catch ( ... )
1103  {
1104  vpERROR_TRACE ( "Error caught" ) ;
1105  throw ;
1106  }
1107 }
1108 
1109 
1122 void
1124  int i, int j, unsigned int radius,
1125  const vpColor &color,
1126  bool fill,
1127  unsigned int thickness)
1128 {
1129  try
1130  {
1131  if ( I.display != NULL )
1132  {
1133  vpImagePoint ip;
1134  ip.set_i( i );
1135  ip.set_j( j );
1136  ( I.display )->displayCircle ( ip, radius, color, fill, thickness ) ;
1137  }
1138  }
1139  catch ( ... )
1140  {
1141  vpERROR_TRACE ( "Error caught" ) ;
1142  throw ;
1143  }
1144 }
1145 
1155  const vpImagePoint &ip, unsigned int size,
1156  const vpColor &color,
1157  unsigned int thickness )
1158 {
1159  try
1160  {
1161  if ( I.display != NULL )
1162  {
1163  ( I.display )->displayCross ( ip, size, color, thickness ) ;
1164  }
1165  }
1166  catch ( ... )
1167  {
1168  vpERROR_TRACE ( "Error caught" ) ;
1169  throw ;
1170  }
1171 }
1172 
1182  const vpImagePoint &ip, unsigned int size,
1183  const vpColor &color,
1184  unsigned int thickness )
1185 {
1186  try
1187  {
1188  if ( I.display != NULL )
1189  {
1190  ( I.display )->displayCross ( ip, size, color, thickness ) ;
1191  }
1192  }
1193  catch ( ... )
1194  {
1195  vpERROR_TRACE ( "Error caught" ) ;
1196  throw ;
1197  }
1198 }
1208  int i, int j,
1209  unsigned int size, const vpColor &color,
1210  unsigned int thickness )
1211 {
1212  try
1213  {
1214  if ( I.display != NULL )
1215  {
1216  vpImagePoint ip;
1217  ip.set_i( i );
1218  ip.set_j( j );
1219 
1220  ( I.display )->displayCross ( ip, size, color, thickness ) ;
1221  }
1222  }
1223  catch ( ... )
1224  {
1225  vpERROR_TRACE ( "Error caught" ) ;
1226  throw ;
1227  }
1228 }
1229 
1239  int i, int j,
1240  unsigned int size, const vpColor &color,
1241  unsigned int thickness )
1242 {
1243  try
1244  {
1245  if ( I.display != NULL )
1246  {
1247  vpImagePoint ip;
1248  ip.set_i( i );
1249  ip.set_j( j );
1250  ( I.display )->displayCross ( ip, size, color, thickness ) ;
1251  }
1252  }
1253  catch ( ... )
1254  {
1255  vpERROR_TRACE ( "Error caught" ) ;
1256  throw ;
1257  }
1258 }
1259 
1268  const vpImagePoint &ip1,
1269  const vpImagePoint &ip2,
1270  const vpColor &color,
1271  unsigned int thickness )
1272 {
1273  try
1274  {
1275  if ( I.display != NULL )
1276  {
1277  ( I.display )->displayDotLine ( ip1, ip2, color, thickness );
1278  }
1279  }
1280  catch ( ... )
1281  {
1282  vpERROR_TRACE ( "Error caught" ) ;
1283  throw ;
1284  }
1285 }
1286 
1295  const vpImagePoint &ip1,
1296  const vpImagePoint &ip2,
1297  const vpColor &color,
1298  unsigned int thickness )
1299 {
1300  try
1301  {
1302  if ( I.display != NULL )
1303  {
1304  ( I.display )->displayDotLine ( ip1, ip2, color, thickness );
1305  }
1306  }
1307  catch ( ... )
1308  {
1309  vpERROR_TRACE ( "Error caught" ) ;
1310  throw ;
1311  }
1312 }
1323  int i1, int j1, int i2, int j2,
1324  const vpColor &color,
1325  unsigned int thickness )
1326 {
1327  try
1328  {
1329  if ( I.display != NULL )
1330  {
1331  vpImagePoint ip1, ip2;
1332  ip1.set_i( i1 );
1333  ip1.set_j( j1 );
1334  ip2.set_i( i2 );
1335  ip2.set_j( j2 );
1336  ( I.display )->displayDotLine ( ip1, ip2, color, thickness );
1337  }
1338  }
1339  catch ( ... )
1340  {
1341  vpERROR_TRACE ( "Error caught" ) ;
1342  throw ;
1343  }
1344 }
1345 
1355  int i1, int j1,
1356  int i2, int j2,
1357  const vpColor &color,
1358  unsigned int thickness )
1359 {
1360  try
1361  {
1362  if ( I.display != NULL )
1363  {
1364  vpImagePoint ip1, ip2;
1365  ip1.set_i( i1 );
1366  ip1.set_j( j1 );
1367  ip2.set_i( i2 );
1368  ip2.set_j( j2 );
1369  ( I.display )->displayDotLine ( ip1, ip2, color, thickness );
1370  }
1371  }
1372  catch ( ... )
1373  {
1374  vpERROR_TRACE ( "Error caught" ) ;
1375  throw ;
1376  }
1377 }
1378 
1387  const vpImagePoint &ip1,
1388  const vpImagePoint &ip2,
1389  const vpColor &color,
1390  unsigned int thickness )
1391 {
1392 
1393  try
1394  {
1395  if ( I.display != NULL )
1396  {
1397  ( I.display )->displayLine ( ip1, ip2, color, thickness );
1398  }
1399  }
1400  catch ( ... )
1401  {
1402  vpERROR_TRACE ( "Error caught" ) ;
1403  throw ;
1404  }
1405 }
1406 
1417  int i1, int j1, int i2, int j2,
1418  const vpColor &color,
1419  unsigned int thickness )
1420 {
1421 
1422  try
1423  {
1424  if ( I.display != NULL )
1425  {
1426  vpImagePoint ip1, ip2;
1427  ip1.set_i( i1 );
1428  ip1.set_j( j1 );
1429  ip2.set_i( i2 );
1430  ip2.set_j( j2 );
1431  ( I.display )->displayLine ( ip1, ip2, color, thickness );
1432  }
1433  }
1434  catch ( ... )
1435  {
1436  vpERROR_TRACE ( "Error caught" ) ;
1437  throw ;
1438  }
1439 }
1440 
1441 
1452  int i1, int j1,
1453  int i2, int j2,
1454  const vpColor &color,
1455  unsigned int thickness )
1456 {
1457 
1458  try
1459  {
1460  if ( I.display != NULL )
1461  {
1462  vpImagePoint ip1, ip2;
1463  ip1.set_i( i1 );
1464  ip1.set_j( j1 );
1465  ip2.set_i( i2 );
1466  ip2.set_j( j2 );
1467  ( I.display )->displayLine ( ip1, ip2, color, thickness );
1468  }
1469  }
1470  catch ( ... )
1471  {
1472  vpERROR_TRACE ( "Error caught" ) ;
1473  throw ;
1474  }
1475 }
1476 
1485  const vpImagePoint &ip1,
1486  const vpImagePoint &ip2,
1487  const vpColor &color,
1488  unsigned int thickness )
1489 {
1490 
1491  try
1492  {
1493  if ( I.display != NULL )
1494  {
1495  ( I.display )->displayLine ( ip1, ip2, color, thickness );
1496  }
1497  }
1498  catch ( ... )
1499  {
1500  vpERROR_TRACE ( "Error caught" ) ;
1501  throw ;
1502  }
1503 }
1504 
1513  const vpImagePoint &ip,
1514  const vpColor &color,
1515  unsigned int thickness )
1516 {
1517  try
1518  {
1519  if ( I.display != NULL )
1520  {
1521  if (thickness == 1)
1522  ( I.display )->displayPoint ( ip, color ) ;
1523  else {
1524  vpRect rect(0, 0, thickness, thickness);
1525  rect.moveCenter(ip);
1526  ( I.display )->displayRectangle ( rect, color, true ) ;
1527  }
1528  }
1529  }
1530  catch ( ... )
1531  {
1532  vpERROR_TRACE ( "Error caught" ) ;
1533  throw ;
1534  }
1535 }
1544  const vpImagePoint &ip,
1545  const vpColor &color,
1546  unsigned int thickness )
1547 {
1548  try
1549  {
1550  if ( I.display != NULL )
1551  {
1552  if (thickness == 1)
1553  ( I.display )->displayPoint ( ip, color ) ;
1554  else {
1555  vpRect rect(0, 0, thickness, thickness);
1556  rect.moveCenter(ip);
1557  ( I.display )->displayRectangle ( rect, color, true ) ;
1558  }
1559  }
1560  }
1561  catch ( ... )
1562  {
1563  vpERROR_TRACE ( "Error caught" ) ;
1564  throw ;
1565  }
1566 }
1567 
1576  int i, int j,
1577  const vpColor &color,
1578  unsigned int thickness )
1579 {
1580  try
1581  {
1582  if ( I.display != NULL )
1583  {
1584  vpImagePoint ip;
1585  ip.set_i( i );
1586  ip.set_j( j );
1587  if (thickness == 1)
1588  ( I.display )->displayPoint ( ip, color ) ;
1589  else {
1590  vpRect rect(0, 0, thickness, thickness);
1591  rect.moveCenter(ip);
1592  ( I.display )->displayRectangle ( rect, color, true ) ;
1593  }
1594  }
1595  }
1596  catch ( ... )
1597  {
1598  vpERROR_TRACE ( "Error caught" ) ;
1599  throw ;
1600  }
1601 }
1602 
1603 
1613  int i, int j,
1614  const vpColor &color,
1615  unsigned int thickness )
1616 {
1617  try
1618  {
1619  if ( I.display != NULL )
1620  {
1621  vpImagePoint ip;
1622  ip.set_i( i );
1623  ip.set_j( j );
1624  if (thickness == 1)
1625  ( I.display )->displayPoint ( ip, color ) ;
1626  else {
1627  vpRect rect(0, 0, thickness, thickness);
1628  rect.moveCenter(ip);
1629  ( I.display )->displayRectangle ( rect, color, true ) ;
1630  }
1631  }
1632  }
1633  catch ( ... )
1634  {
1635  vpERROR_TRACE ( "Error caught" ) ;
1636  throw ;
1637  }
1638 }
1639 
1648 void
1650  const std::vector<vpImagePoint> &vip,
1651  const vpColor &color,
1652  unsigned int thickness)
1653 {
1654  try
1655  {
1656  if ( I.display != NULL )
1657  {
1658  for (unsigned int i=0; i< vip.size(); i++)
1659  ( I.display )->displayLine ( vip[i], vip[(i+1)%vip.size()], color, thickness );
1660  }
1661  }
1662  catch ( ... )
1663  {
1664  vpERROR_TRACE ( "Error caught" ) ;
1665  throw ;
1666  }
1667 }
1668 
1677 void
1679  const std::vector<vpImagePoint> &vip,
1680  const vpColor &color,
1681  unsigned int thickness)
1682 {
1683  try
1684  {
1685  if ( I.display != NULL )
1686  {
1687  for (unsigned int i=0; i< vip.size(); i++)
1688  ( I.display )->displayLine ( vip[i], vip[(i+1)%vip.size()], color, thickness );
1689  }
1690  }
1691  catch ( ... )
1692  {
1693  vpERROR_TRACE ( "Error caught" ) ;
1694  throw ;
1695  }
1696 }
1697 
1712 void
1714  const vpImagePoint &topLeft,
1715  unsigned int width, unsigned int height,
1716  const vpColor &color, bool fill,
1717  unsigned int thickness)
1718 {
1719  try
1720  {
1721  if ( I.display != NULL )
1722  {
1723  ( I.display )->displayRectangle ( topLeft, width, height, color,
1724  fill, thickness ) ;
1725  }
1726  }
1727  catch ( ... )
1728  {
1729  vpERROR_TRACE ( "Error caught" ) ;
1730  throw ;
1731  }
1732 }
1733 
1734 
1749 void
1751  const vpImagePoint &topLeft,
1752  const vpImagePoint &bottomRight,
1753  const vpColor &color, bool fill,
1754  unsigned int thickness)
1755 {
1756  try
1757  {
1758  if ( I.display != NULL )
1759  {
1760  ( I.display )->displayRectangle ( topLeft, bottomRight, color,
1761  fill, thickness ) ;
1762  }
1763  }
1764  catch ( ... )
1765  {
1766  vpERROR_TRACE ( "Error caught" ) ;
1767  throw ;
1768  }
1769 }
1784 void
1786  const vpRect &rectangle,
1787  const vpColor &color, bool fill,
1788  unsigned int thickness )
1789 {
1790  try
1791  {
1792  if ( I.display != NULL )
1793  {
1794  ( I.display )->displayRectangle ( rectangle, color, fill, thickness ) ;
1795  }
1796  }
1797  catch ( ... )
1798  {
1799  vpERROR_TRACE ( "Error caught" ) ;
1800  throw ;
1801  }
1802 }
1803 
1804 
1820 void
1822  const vpImagePoint &center,
1823  float angle,
1824  unsigned int width, unsigned int height,
1825  const vpColor &color,
1826  unsigned int thickness)
1827 {
1828  try
1829  {
1830  if (I.display != NULL)
1831  {
1832  double i = center.get_i();
1833  double j = center.get_j();
1834 
1835  //A, B, C, D, corners of the rectangle clockwise
1836  vpImagePoint ipa, ipb, ipc, ipd;
1837  double cosinus = cos(angle);
1838  double sinus = sin(angle);
1839  ipa.set_u(j + 0.5*width*cosinus + 0.5*height*sinus);
1840  ipa.set_v(i + 0.5*width*sinus - 0.5*height*cosinus);
1841  ipb.set_u(j + 0.5*width*cosinus - 0.5*height*sinus);
1842  ipb.set_v(i + 0.5*width*sinus + 0.5*height*cosinus);
1843  ipc.set_u(j - 0.5*width*cosinus - 0.5*height*sinus);
1844  ipc.set_v(i - 0.5*width*sinus + 0.5*height*cosinus);
1845  ipd.set_u(j - 0.5*width*cosinus + 0.5*height*sinus);
1846  ipd.set_v(i - 0.5*width*sinus - 0.5*height*cosinus);
1847 
1848  ( I.display )->displayLine(I, ipa, ipb, color, thickness);
1849  ( I.display )->displayLine(I, ipa, ipd, color, thickness);
1850  ( I.display )->displayLine(I, ipc, ipb, color, thickness);
1851  ( I.display )->displayLine(I, ipc, ipd, color, thickness);
1852  }
1853  }
1854  catch(...)
1855  {
1856  vpERROR_TRACE("Error caught in displayRectangle") ;
1857  throw ;
1858  }
1859 }
1860 
1875 void
1877  const vpImagePoint &topLeft,
1878  unsigned int width, unsigned int height,
1879  const vpColor &color, bool fill,
1880  unsigned int thickness)
1881 {
1882  try
1883  {
1884  if ( I.display != NULL )
1885  {
1886  ( I.display )->displayRectangle ( topLeft, width, height, color,
1887  fill, thickness ) ;
1888  }
1889  }
1890  catch ( ... )
1891  {
1892  vpERROR_TRACE ( "Error caught" ) ;
1893  throw ;
1894  }
1895 }
1910 void
1912  const vpImagePoint &topLeft,
1913  const vpImagePoint &bottomRight,
1914  const vpColor &color, bool fill,
1915  unsigned int thickness)
1916 {
1917  try
1918  {
1919  if ( I.display != NULL )
1920  {
1921  ( I.display )->displayRectangle ( topLeft, bottomRight, color,
1922  fill, thickness ) ;
1923  }
1924  }
1925  catch ( ... )
1926  {
1927  vpERROR_TRACE ( "Error caught" ) ;
1928  throw ;
1929  }
1930 }
1945 void
1947  const vpRect &rectangle,
1948  const vpColor &color, bool fill,
1949  unsigned int thickness )
1950 {
1951  try
1952  {
1953  if ( I.display != NULL )
1954  {
1955  ( I.display )->displayRectangle ( rectangle, color, fill, thickness ) ;
1956  }
1957  }
1958  catch ( ... )
1959  {
1960  vpERROR_TRACE ( "Error caught" ) ;
1961  throw ;
1962  }
1963 }
1964 
1965 
1981 void
1983  const vpImagePoint &center,
1984  float angle,
1985  unsigned int width, unsigned int height,
1986  const vpColor &color,
1987  unsigned int thickness)
1988 {
1989  try
1990  {
1991  if (I.display != NULL)
1992  {
1993  double i = center.get_i();
1994  double j = center.get_j();
1995 
1996  //A, B, C, D, corners of the rectangle clockwise
1997  vpImagePoint ipa, ipb, ipc, ipd;
1998  double cosinus = cos(angle);
1999  double sinus = sin(angle);
2000  ipa.set_u(j + 0.5*width*cosinus + 0.5*height*sinus);
2001  ipa.set_v(i + 0.5*width*sinus - 0.5*height*cosinus);
2002  ipb.set_u(j + 0.5*width*cosinus - 0.5*height*sinus);
2003  ipb.set_v(i + 0.5*width*sinus + 0.5*height*cosinus);
2004  ipc.set_u(j - 0.5*width*cosinus - 0.5*height*sinus);
2005  ipc.set_v(i - 0.5*width*sinus + 0.5*height*cosinus);
2006  ipd.set_u(j - 0.5*width*cosinus + 0.5*height*sinus);
2007  ipd.set_v(i - 0.5*width*sinus - 0.5*height*cosinus);
2008 
2009  ( I.display )->displayLine(I, ipa, ipb, color, thickness);
2010  ( I.display )->displayLine(I, ipa, ipd, color, thickness);
2011  ( I.display )->displayLine(I, ipc, ipb, color, thickness);
2012  ( I.display )->displayLine(I, ipc, ipd, color, thickness);
2013  }
2014  }
2015  catch(...)
2016  {
2017  vpERROR_TRACE("Error caught in displayRectangle") ;
2018  throw ;
2019  }
2020 }
2021 
2038 void
2040  int i, int j,
2041  unsigned int width, unsigned int height,
2042  const vpColor &color, bool fill,
2043  unsigned int thickness)
2044 {
2045  try
2046  {
2047  if ( I.display != NULL )
2048  {
2049  vpImagePoint topLeft;
2050  topLeft.set_i( i );
2051  topLeft.set_j( j );
2052 
2053  ( I.display )->displayRectangle ( topLeft, width, height,
2054  color, fill, thickness ) ;
2055  }
2056  }
2057  catch ( ... )
2058  {
2059  vpERROR_TRACE ( "Error caught" ) ;
2060  throw ;
2061  }
2062 }
2078 void
2080  unsigned int i, unsigned int j, float angle,
2081  unsigned int width, unsigned int height,
2082  const vpColor &color,unsigned int thickness)
2083 {
2084  try
2085  {
2086  if (I.display != NULL)
2087  {
2088  //A, B, C, D, corners of the rectangle clockwise
2089  vpImagePoint ipa, ipb, ipc, ipd;
2090  float cosinus = cos(angle);
2091  float sinus = sin(angle);
2092  ipa.set_u(j + 0.5*width*cosinus + 0.5*height*sinus);
2093  ipa.set_v(i + 0.5*width*sinus - 0.5*height*cosinus);
2094  ipb.set_u(j + 0.5*width*cosinus - 0.5*height*sinus);
2095  ipb.set_v(i + 0.5*width*sinus + 0.5*height*cosinus);
2096  ipc.set_u(j - 0.5*width*cosinus - 0.5*height*sinus);
2097  ipc.set_v(i - 0.5*width*sinus + 0.5*height*cosinus);
2098  ipd.set_u(j - 0.5*width*cosinus + 0.5*height*sinus);
2099  ipd.set_v(i - 0.5*width*sinus - 0.5*height*cosinus);
2100 
2101  ( I.display )->displayLine(I, ipa, ipb, color, thickness);
2102  ( I.display )->displayLine(I, ipa, ipd, color, thickness);
2103  ( I.display )->displayLine(I, ipc, ipb, color, thickness);
2104  ( I.display )->displayLine(I, ipc, ipd, color, thickness);
2105  }
2106  }
2107  catch(...)
2108  {
2109  vpERROR_TRACE("Error caught in displayRectangle") ;
2110  throw ;
2111  }
2112 }
2113 
2130 void
2132  int i, int j,
2133  unsigned int width, unsigned int height,
2134  const vpColor &color, bool fill,
2135  unsigned int thickness)
2136 {
2137  try
2138  {
2139  if ( I.display != NULL )
2140  {
2141  vpImagePoint topLeft;
2142  topLeft.set_i( i );
2143  topLeft.set_j( j );
2144 
2145  ( I.display )->displayRectangle ( topLeft, width, height,
2146  color, fill, thickness ) ;
2147  }
2148  }
2149  catch ( ... )
2150  {
2151  vpERROR_TRACE ( "Error caught" ) ;
2152  throw ;
2153  }
2154 }
2169 void
2171  unsigned int i, unsigned int j, float angle,
2172  unsigned int width, unsigned int height,
2173  const vpColor &color, unsigned int thickness)
2174 {
2175  try
2176  {
2177  if (I.display != NULL)
2178  {
2179  //A, B, C, D, corners of the rectangle clockwise
2180  vpImagePoint ipa, ipb, ipc, ipd;
2181  float cosinus = cos(angle);
2182  float sinus = sin(angle);
2183  ipa.set_u(j + 0.5*width*cosinus + 0.5*height*sinus);
2184  ipa.set_v(i + 0.5*width*sinus - 0.5*height*cosinus);
2185  ipb.set_u(j + 0.5*width*cosinus - 0.5*height*sinus);
2186  ipb.set_v(i + 0.5*width*sinus + 0.5*height*cosinus);
2187  ipc.set_u(j - 0.5*width*cosinus - 0.5*height*sinus);
2188  ipc.set_v(i - 0.5*width*sinus + 0.5*height*cosinus);
2189  ipd.set_u(j - 0.5*width*cosinus + 0.5*height*sinus);
2190  ipd.set_v(i - 0.5*width*sinus - 0.5*height*cosinus);
2191 
2192  ( I.display )->displayLine(I, ipa, ipb, color, thickness);
2193  ( I.display )->displayLine(I, ipa, ipd, color, thickness);
2194  ( I.display )->displayLine(I, ipc, ipb, color, thickness);
2195  ( I.display )->displayLine(I, ipc, ipd, color, thickness);
2196  }
2197  }
2198  catch(...)
2199  {
2200  vpERROR_TRACE("Error caught in displayRectangle") ;
2201  throw ;
2202  }
2203 }
2204 
2234 {
2235 
2236  try
2237  {
2238  if ( I.display != NULL )
2239  {
2240  ( I.display )->flushDisplay() ;
2241  }
2242  }
2243  catch ( ... )
2244  {
2245  vpERROR_TRACE ( "Error caught" ) ;
2246  throw ;
2247  }
2248 }
2249 
2251 {
2252 
2253  try
2254  {
2255  if ( I.display != NULL )
2256  {
2257  ( I.display )->flushDisplayROI(roi.getTopLeft(),(unsigned int)roi.getWidth(),(unsigned int)roi.getHeight()) ;
2258  }
2259  }
2260  catch ( ... )
2261  {
2262  vpERROR_TRACE ( "Error caught" ) ;
2263  throw ;
2264  }
2265 }
2266 
2271 {
2272 
2273  try
2274  {
2275  if ( I.display != NULL )
2276  {
2277  ( I.display )->closeDisplay() ;
2278  I.display = NULL;
2279  }
2280  }
2281  catch ( ... )
2282  {
2283  vpERROR_TRACE ( "Error caught" ) ;
2284  throw ;
2285  }
2286 }
2287 
2288 
2296 void
2297 vpDisplay::setTitle ( const vpImage<vpRGBa> &I, const char *windowtitle )
2298 {
2299 
2300  try
2301  {
2302  if ( I.display != NULL )
2303  {
2304  ( I.display )->setTitle ( windowtitle ) ;
2305  }
2306  }
2307  catch ( ... )
2308  {
2309  vpERROR_TRACE ( "Error caught" ) ;
2310  throw ;
2311  }
2312 }
2313 
2323 void
2324 vpDisplay::setWindowPosition ( const vpImage<vpRGBa> &I, int winx, int winy )
2325 {
2326 
2327  try
2328  {
2329  if ( I.display != NULL )
2330  {
2331  ( I.display )->setWindowPosition ( winx, winy ) ;
2332  }
2333  }
2334  catch ( ... )
2335  {
2336  vpERROR_TRACE ( "Error caught" ) ;
2337  throw ;
2338  }
2339 }
2340 
2354 void
2355 vpDisplay::setFont ( const vpImage<vpRGBa> &I, const char *fontname )
2356 {
2357 
2358  try
2359  {
2360  if ( I.display != NULL )
2361  {
2362  ( I.display )->setFont ( fontname ) ;
2363  }
2364  }
2365  catch ( ... )
2366  {
2367  vpERROR_TRACE ( "Error caught" ) ;
2368  throw ;
2369  }
2370 }
2371 
2381 void
2383 {
2384  try
2385  {
2386  if ( I.display != NULL )
2387  {
2388  ( I.display )->clearDisplay ( color ) ;
2389  }
2390  }
2391  catch ( ... )
2392  {
2393  vpERROR_TRACE ( "Error caught" ) ;
2394  throw ;
2395  }
2396 }
2397 
2409 void
2411 {
2412 
2413  try
2414  {
2415  if ( I.display != NULL )
2416  {
2417  ( I.display )->displayImage ( I ) ;
2418  }
2419  }
2420  catch ( ... )
2421  {
2422  vpERROR_TRACE ( "Error caught" ) ;
2423  throw ;
2424  }
2425 }
2426 
2427 void
2429 {
2430  vpImagePoint topLeft;
2431  double top = floor(roi.getTop());
2432  double left = floor(roi.getLeft());
2433  double roiheight = floor(roi.getHeight());
2434  double roiwidth = floor(roi.getWidth());
2435  double iheight = (double)(I.getHeight());
2436  double iwidth = (double)(I.getWidth());
2437 
2438  if (top < 0 || top >= iheight || left < 0 || left >= iwidth || top+roiheight >= iheight || left+roiwidth >= iwidth)
2439  {
2440  vpERROR_TRACE ( "Region of interest outside of the image" ) ;
2442  "Region of interest outside of the image" ) ) ;
2443  }
2444 
2445  try
2446  {
2447  if ( I.display != NULL )
2448  {
2449  ( I.display )->displayImageROI ( I , vpImagePoint(top,left), (unsigned int)roiwidth,(unsigned int)roiheight ) ;
2450  }
2451  }
2452  catch ( ... )
2453  {
2454  vpERROR_TRACE ( "Error caught" ) ;
2455  throw ;
2456  }
2457 }
2458 
2459 
2526 void
2528 {
2529 
2530  try
2531  {
2532  if ( Isrc.display != NULL )
2533  {
2534  ( Isrc.display )->getImage ( Idest ) ;
2535  }
2536  else {
2537  Idest = Isrc;
2538  }
2539  }
2540  catch ( ... )
2541  {
2542  vpERROR_TRACE ( "Error caught" ) ;
2543  throw ;
2544  }
2545 }
2546 
2577 {
2578 
2579  try
2580  {
2581  if ( I.display != NULL )
2582  {
2583  ( I.display )->flushDisplay() ;
2584  }
2585  }
2586  catch ( ... )
2587  {
2588  vpERROR_TRACE ( "Error caught" ) ;
2589  throw ;
2590  }
2591 }
2592 
2593 void vpDisplay::flushROI ( const vpImage<vpRGBa> &I, const vpRect &roi )
2594 {
2595 
2596  try
2597  {
2598  if ( I.display != NULL )
2599  {
2600  ( I.display )->flushDisplayROI(roi.getTopLeft(),(unsigned int)roi.getWidth(),(unsigned int)roi.getHeight()) ;
2601  }
2602  }
2603  catch ( ... )
2604  {
2605  vpERROR_TRACE ( "Error caught" ) ;
2606  throw ;
2607  }
2608 }
2609 
2614 {
2615 
2616  try
2617  {
2618  if ( I.display != NULL )
2619  {
2620  ( I.display )->closeDisplay() ;
2621  I.display = NULL;
2622  }
2623  }
2624  catch ( ... )
2625  {
2626  vpERROR_TRACE ( "Error caught" ) ;
2627  throw ;
2628  }
2629 }
2630 
2648 bool vpDisplay::getClick ( const vpImage<unsigned char> &I, bool blocking )
2649 {
2650  try
2651  {
2652  if ( I.display != NULL )
2653  {
2654  return ( I.display )->getClick(blocking) ;
2655  }
2656  }
2657  catch ( ... )
2658  {
2659  vpERROR_TRACE ( "Error caught" ) ;
2660  throw ;
2661  }
2662  return false ;
2663 }
2664 
2686  vpImagePoint &ip, bool blocking )
2687 {
2688  try
2689  {
2690  if ( I.display != NULL )
2691  {
2692  return ( I.display )->getClick ( ip, blocking ) ;
2693  }
2694  }
2695  catch ( ... )
2696  {
2697  vpERROR_TRACE ( "Error caught" ) ;
2698  throw ;
2699  }
2700  return false ;
2701 }
2702 
2725  vpImagePoint &ip,
2727  bool blocking)
2728 {
2729  try
2730  {
2731  if ( I.display != NULL )
2732  {
2733  return ( I.display )->getClick ( ip, button, blocking ) ;
2734  }
2735  }
2736  catch ( ... )
2737  {
2738  vpERROR_TRACE ( "Error caught" ) ;
2739  throw ;
2740  }
2741  return false ;
2742 }
2743 
2763  bool blocking)
2764 {
2765  vpImagePoint ip;
2766  return vpDisplay::getClick(I, ip, button, blocking);
2767 }
2768 
2788  bool blocking)
2789 {
2790  vpImagePoint ip;
2791  return vpDisplay::getClick(I, ip, button, blocking);
2792 }
2793 
2815 bool
2817  vpImagePoint &ip,
2819  bool blocking )
2820 {
2821  try
2822  {
2823  if ( I.display != NULL )
2824  {
2825  return ( I.display )->getClickUp ( ip, button, blocking ) ;
2826  }
2827  }
2828  catch ( ... )
2829  {
2830  vpERROR_TRACE ( "Error caught" ) ;
2831  throw ;
2832  }
2833  return false ;
2834 }
2835 
2855  bool blocking)
2856 {
2857  vpImagePoint ip;
2858  return vpDisplay::getClickUp(I, ip, button, blocking);
2859 }
2860 
2880  bool blocking)
2881 {
2882  vpImagePoint ip;
2883  return vpDisplay::getClickUp(I, ip, button, blocking);
2884 }
2885 
2971 bool
2973 {
2974  try
2975  {
2976  if ( I.display != NULL )
2977  {
2978  return ( I.display )->getKeyboardEvent ( blocking ) ;
2979  }
2980  }
2981  catch ( ... )
2982  {
2983  vpERROR_TRACE ( "Error caught" ) ;
2984  throw ;
2985  }
2986  return false ;
2987 }
2988 
3078 bool
3080  char *string, bool blocking)
3081 {
3082  try
3083  {
3084  if ( I.display != NULL )
3085  {
3086  return ( I.display )->getKeyboardEvent ( string, blocking ) ;
3087  }
3088  }
3089  catch ( ... )
3090  {
3091  vpERROR_TRACE ( "Error caught" ) ;
3092  throw ;
3093  }
3094  return false ;
3095 }
3106 bool
3108  vpImagePoint &ip)
3109 {
3110  try
3111  {
3112  if ( I.display != NULL )
3113  {
3114  return ( I.display )->getPointerMotionEvent ( ip ) ;
3115  }
3116  }
3117  catch ( ... )
3118  {
3119  vpERROR_TRACE ( "Error caught" ) ;
3120  throw ;
3121  }
3122  return false;
3123 }
3124 
3135 bool
3137  vpImagePoint &ip)
3138 {
3139  try
3140  {
3141  if ( I.display != NULL )
3142  {
3143  return ( I.display )->getPointerPosition ( ip ) ;
3144  }
3145  }
3146  catch ( ... )
3147  {
3148  vpERROR_TRACE ( "Error caught" ) ;
3149  throw ;
3150  }
3151  return false;
3152 }
3153 
3167 bool vpDisplay::getClick ( const vpImage<vpRGBa> &I, bool blocking )
3168 {
3169  try
3170  {
3171  if ( I.display != NULL )
3172  {
3173  return ( I.display )->getClick(blocking) ;
3174  }
3175  }
3176  catch ( ... )
3177  {
3178  vpERROR_TRACE ( "Error caught" ) ;
3179  throw ;
3180  }
3181  return false;
3182 }
3183 
3184 
3204  vpImagePoint &ip, bool blocking )
3205 {
3206  try
3207  {
3208  if ( I.display != NULL )
3209  {
3210  return ( I.display )->getClick ( ip, blocking ) ;
3211  }
3212  }
3213  catch ( ... )
3214  {
3215  vpERROR_TRACE ( "Error caught" ) ;
3216  throw ;
3217  }
3218  return false ;
3219 }
3220 
3242  vpImagePoint &ip,
3244  bool blocking )
3245 {
3246  try
3247  {
3248  if ( I.display != NULL )
3249  {
3250  return ( I.display )->getClick ( ip, button, blocking ) ;
3251  }
3252  }
3253  catch ( ... )
3254  {
3255  vpERROR_TRACE ( "Error caught" ) ;
3256  throw ;
3257  }
3258  return false ;
3259 }
3260 
3281 bool
3283  vpImagePoint &ip,
3285  bool blocking )
3286 {
3287  try
3288  {
3289  if ( I.display != NULL )
3290  {
3291  return ( I.display )->getClickUp ( ip, button, blocking ) ;
3292  }
3293  }
3294  catch ( ... )
3295  {
3296  vpERROR_TRACE ( "Error caught" ) ;
3297  throw ;
3298  }
3299  return false ;
3300 }
3301 
3386 bool
3388 {
3389  try
3390  {
3391  if ( I.display != NULL )
3392  {
3393  return ( I.display )->getKeyboardEvent ( blocking ) ;
3394  }
3395  }
3396  catch ( ... )
3397  {
3398  vpERROR_TRACE ( "Error caught" ) ;
3399  throw ;
3400  }
3401  return false ;
3402 }
3403 
3491 bool
3493  char *string, bool blocking)
3494 {
3495  try
3496  {
3497  if ( I.display != NULL )
3498  {
3499  return ( I.display )->getKeyboardEvent ( string, blocking ) ;
3500  }
3501  }
3502  catch ( ... )
3503  {
3504  vpERROR_TRACE ( "Error caught" ) ;
3505  throw ;
3506  }
3507  return false ;
3508 }
3519 bool
3521 {
3522  try
3523  {
3524  if ( I.display != NULL )
3525  {
3526  return ( I.display )->getPointerMotionEvent ( ip ) ;
3527  }
3528  }
3529  catch ( ... )
3530  {
3531  vpERROR_TRACE ( "Error caught" ) ;
3532  throw ;
3533  }
3534  return false;
3535 }
3536 
3546 bool
3548 {
3549  try
3550  {
3551  if ( I.display != NULL )
3552  {
3553  return ( I.display )->getPointerPosition ( ip ) ;
3554  }
3555  }
3556  catch ( ... )
3557  {
3558  vpERROR_TRACE ( "Error caught" ) ;
3559  throw ;
3560  }
3561  return false;
3562 }
3563 
3610  const vpImagePoint &center,
3611  const double &coef1, const double &coef2, const double &coef3,
3612  bool use_centered_moments,
3613  const vpColor &color,
3614  unsigned int thickness)
3615 {
3616  vpDisplay::displayEllipse(I, center, coef1, coef2, coef3, 0., vpMath::rad(360), use_centered_moments, color, thickness);
3617 }
3618 
3669  const vpImagePoint &center,
3670  const double &coef1, const double &coef2, const double &coef3,
3671  const double &theta1, const double &theta2, bool use_centered_moments,
3672  const vpColor &color,
3673  unsigned int thickness)
3674 {
3675  try
3676  {
3677  if ( I.display != NULL )
3678  {
3679  double j1, i1;
3680  vpImagePoint iP11;
3681  double j2, i2;
3682  vpImagePoint iP22;
3683  j1 = j2 = i1 = i2 = 0 ;
3684  double a=0., b=0., e=0.;
3685 
3686  double mu20_p = coef1;
3687  double mu11_p = coef2;
3688  double mu02_p = coef3;
3689 
3690  if (use_centered_moments) {
3691  if (std::fabs(mu11_p) > std::numeric_limits<double>::epsilon()) {
3692 
3693  double val_p = sqrt(vpMath::sqr(mu20_p-mu02_p) + 4*vpMath::sqr(mu11_p));
3694  a = sqrt((mu20_p + mu02_p + val_p)/2);
3695  b = sqrt((mu20_p + mu02_p - val_p)/2);
3696 
3697  e = (mu02_p - mu20_p + val_p)/(2*mu11_p);
3698  e = atan(e);
3699  }
3700  else {
3701  a = sqrt(mu20_p);
3702  b = sqrt(mu02_p);
3703  e = 0.;
3704  }
3705  }
3706  else {
3707  a = coef1;
3708  b = coef2;
3709  e = coef3;
3710  }
3711 
3712  // Approximation of the circumference of an ellipse:
3713  // [Ramanujan, S., "Modular Equations and Approximations to ,"
3714  // Quart. J. Pure. Appl. Math., vol. 45 (1913-1914), pp. 350-372]
3715  double t = (a-b)/(a+b);
3716  double circumference = M_PI*(a+b)*(1 + 3*vpMath::sqr(t)/(10 + sqrt(4 - 3*vpMath::sqr(t))));
3717 
3718  int nbpoints = (int)(floor(circumference/5));
3719  if (nbpoints < 10)
3720  nbpoints = 10;
3721  double incr = 2*M_PI / nbpoints ; // angle increment
3722 
3723  double smallalpha = theta1;
3724  double highalpha = theta2;
3725  double ce = cos(e);
3726  double se = sin(e);
3727 
3728  double k = smallalpha ;
3729  j1 = a *cos(k) ; // equation of an ellipse
3730  i1 = b *sin(k) ; // equation of an ellipse
3731 
3732  // (i1,j1) are the coordinates on the origin centered ellipse ;
3733  // a rotation by "e" and a translation by (xci,jc) are done
3734  // to get the coordinates of the point on the shifted ellipse
3735  iP11.set_j ( center.get_j() + ce *j1 - se *i1 );
3736  iP11.set_i ( center.get_i() + se *j1 + ce *i1 );
3737 
3738  while (k+incr<highalpha+incr)
3739  {
3740  j2 = a *cos(k+incr) ; // equation of an ellipse
3741  i2 = b *sin(k+incr) ; // equation of an ellipse
3742 
3743  // to get the coordinates of the point on the shifted ellipse
3744  iP22.set_j ( center.get_j() + ce *j2 - se *i2 );
3745  iP22.set_i ( center.get_i() + se *j2 + ce *i2 );
3746 
3747  ( I.display )->displayLine(iP11, iP22, color, thickness) ;
3748 
3749  i1 = i2;
3750  j1 = j2;
3751  iP11 = iP22;
3752 
3753  k += incr ;
3754  }
3755  }
3756  }
3757  catch ( vpException &e )
3758  {
3759  throw(e) ;
3760  }
3761 }
3762 
3809  const vpImagePoint &center,
3810  const double &coef1, const double &coef2, const double &coef3,
3811  bool use_centered_moments,
3812  const vpColor &color,
3813  unsigned int thickness)
3814 {
3815  vpDisplay::displayEllipse(I, center, coef1, coef2, coef3, 0., vpMath::rad(360), use_centered_moments, color, thickness);
3816 }
3817 
3868  const vpImagePoint &center,
3869  const double &coef1, const double &coef2, const double &coef3,
3870  const double &theta1, const double &theta2, bool use_centered_moments,
3871  const vpColor &color,
3872  unsigned int thickness)
3873 {
3874  try
3875  {
3876  if ( I.display != NULL )
3877  {
3878  double j1, i1;
3879  vpImagePoint iP11;
3880  double j2, i2;
3881  vpImagePoint iP22;
3882  j1 = j2 = i1 = i2 = 0 ;
3883  double a=0., b=0., e=0.;
3884 
3885  double mu20_p = coef1;
3886  double mu11_p = coef2;
3887  double mu02_p = coef3;
3888 
3889  if (use_centered_moments) {
3890  if (std::fabs(mu11_p) > std::numeric_limits<double>::epsilon()) {
3891 
3892  double val_p = sqrt(vpMath::sqr(mu20_p-mu02_p) + 4*vpMath::sqr(mu11_p));
3893  a = sqrt((mu20_p + mu02_p + val_p)/2);
3894  b = sqrt((mu20_p + mu02_p - val_p)/2);
3895 
3896  e = (mu02_p - mu20_p + val_p)/(2*mu11_p);
3897  e = atan(e);
3898  }
3899  else {
3900  a = sqrt(mu20_p);
3901  b = sqrt(mu02_p);
3902  e = 0.;
3903  }
3904  }
3905  else {
3906  a = coef1;
3907  b = coef2;
3908  e = coef3;
3909  }
3910 
3911  // Approximation of the circumference of an ellipse:
3912  // [Ramanujan, S., "Modular Equations and Approximations to ,"
3913  // Quart. J. Pure. Appl. Math., vol. 45 (1913-1914), pp. 350-372]
3914  double t = (a-b)/(a+b);
3915  double circumference = M_PI*(a+b)*(1 + 3*vpMath::sqr(t)/(10 + sqrt(4 - 3*vpMath::sqr(t))));
3916 
3917  int nbpoints = (int)(floor(circumference/5));
3918  if (nbpoints < 10)
3919  nbpoints = 10;
3920  double incr = 2*M_PI / nbpoints ; // angle increment
3921 
3922  double smallalpha = theta1;
3923  double highalpha = theta2;
3924  double ce = cos(e);
3925  double se = sin(e);
3926 
3927  double k = smallalpha ;
3928  j1 = a *cos(k) ; // equation of an ellipse
3929  i1 = b *sin(k) ; // equation of an ellipse
3930 
3931  // (i1,j1) are the coordinates on the origin centered ellipse ;
3932  // a rotation by "e" and a translation by (xci,jc) are done
3933  // to get the coordinates of the point on the shifted ellipse
3934  iP11.set_j ( center.get_j() + ce *j1 - se *i1 );
3935  iP11.set_i ( center.get_i() + se *j1 + ce *i1 );
3936 
3937  while (k+incr<highalpha+incr)
3938  {
3939  j2 = a *cos(k+incr) ; // equation of an ellipse
3940  i2 = b *sin(k+incr) ; // equation of an ellipse
3941 
3942  // to get the coordinates of the point on the shifted ellipse
3943  iP22.set_j ( center.get_j() + ce *j2 - se *i2 );
3944  iP22.set_i ( center.get_i() + se *j2 + ce *i2 );
3945 
3946  ( I.display )->displayLine(iP11, iP22, color, thickness) ;
3947 
3948  i1 = i2;
3949  j1 = j2;
3950  iP11 = iP22;
3951 
3952  k += incr ;
3953  }
3954  }
3955  }
3956  catch ( vpException &e )
3957  {
3958  throw(e) ;
3959  }
3960 }
3961 
static void displayCamera(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, const vpColor &color, unsigned int thickness)
Definition: vpDisplay.cpp:514
virtual void displayCircle(const vpImagePoint &center, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1)=0
vpDisplay * display
Definition: vpImage.h:117
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)
Definition: vpDisplay.cpp:3609
double getTop() const
Definition: vpRect.h:176
virtual void displayImage(const vpImage< unsigned char > &I)=0
Class that defines generic functionnalities for display.
Definition: vpDisplay.h:170
virtual void displayArrow(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1)=0
unsigned int width
Definition: vpDisplay.h:179
static void close(vpImage< unsigned char > &I)
Definition: vpDisplay.cpp:2270
double get_i() const
Definition: vpImagePoint.h:190
unsigned int getWidth() const
Definition: vpImage.h:161
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
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)
Definition: vpDisplay.cpp:1649
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
Point coordinates conversion from normalized coordinates in meter to pixel coordinates ...
#define vpERROR_TRACE
Definition: vpDebug.h:391
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
virtual void clearDisplay(const vpColor &color=vpColor::white)=0
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Definition: vpDisplay.cpp:888
static const vpColor none
Definition: vpColor.h:175
virtual bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)=0
error that can be emited by ViSP classes.
Definition: vpException.h:73
void track(const vpHomogeneousMatrix &cMo)
double getHeight() const
Definition: vpRect.h:151
virtual bool getPointerMotionEvent(vpImagePoint &ip)=0
bool displayHasBeenInitialized
display has been initialized
Definition: vpDisplay.h:174
static const vpColor green
Definition: vpColor.h:166
static void flush(const vpImage< unsigned char > &I)
Definition: vpDisplay.cpp:2233
double get_j() const
Definition: vpImagePoint.h:201
vpImagePoint getTopLeft() const
Definition: vpRect.h:182
static const vpColor red
Definition: vpColor.h:163
Class that defines what is a point.
Definition: vpPoint.h:59
virtual void flushDisplay()=0
void set_i(const double ii)
Definition: vpImagePoint.h:154
double getWidth() const
Definition: vpRect.h:195
virtual bool getPointerPosition(vpImagePoint &ip)=0
virtual bool getKeyboardEvent(bool blocking=true)=0
void set_u(const double u)
Definition: vpImagePoint.h:212
virtual void setWindowPosition(int winx, int winy)=0
static double sqr(double x)
Definition: vpMath.h:110
static void display(const vpImage< unsigned char > &I)
Definition: vpDisplay.cpp:206
unsigned int height
Definition: vpDisplay.h:180
virtual void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)=0
void set_v(const double v)
Definition: vpImagePoint.h:223
Generic class defining intrinsic camera parameters.
virtual void displayImageROI(const vpImage< unsigned char > &I, const vpImagePoint &iP, const unsigned int width, const unsigned int height)=0
virtual void setTitle(const char *title)=0
void moveCenter(double x, double y)
Definition: vpRect.h:306
virtual void setFont(const char *font)=0
virtual void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)=0
virtual ~vpDisplay()
Definition: vpDisplay.cpp:78
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
Definition: vpDisplay.cpp:324
static double rad(double deg)
Definition: vpMath.h:104
virtual void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
void set_j(const double jj)
Definition: vpImagePoint.h:165
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, vpImagePoint offset=vpImagePoint(0, 0))
Definition: vpDisplay.cpp:373
void setWorldCoordinates(const double oX, const double oY, const double oZ)
Definition: vpPoint.cpp:111
virtual void closeDisplay()=0
virtual void displayCharString(const vpImagePoint &ip, const char *text, const vpColor &color=vpColor::green)=0
int windowXPosition
display position
Definition: vpDisplay.h:176
static void setBackground(const vpImage< unsigned char > &I, const vpColor &color)
Definition: vpDisplay.cpp:178
unsigned int getHeight() const
Definition: vpImage.h:152
Defines a rectangle in the plane.
Definition: vpRect.h:81
static void flushROI(const vpImage< unsigned char > &I, const vpRect &roi)
Definition: vpDisplay.cpp:2250
static void displayROI(const vpImage< unsigned char > &I, const vpRect &roi)
Definition: vpDisplay.cpp:225
virtual bool getClick(bool blocking=true)=0
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88
virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
virtual void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height)=0
int windowYPosition
display position
Definition: vpDisplay.h:178
double getLeft() const
Definition: vpRect.h:157
virtual void displayPoint(const vpImagePoint &ip, const vpColor &color)=0
vpColVector p
Definition: vpTracker.h:73
static const vpColor blue
Definition: vpColor.h:169