ViSP  2.6.2
vpImageSimulator.cpp
1 /****************************************************************************
2  *
3  * $Id: vpPose.h 2453 2010-01-07 10:01:10Z nmelchio $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2012 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description: Class which enables to project an image in the 3D space
35  * and get the view of a virtual camera.
36  *
37  *
38  * Authors:
39  * Amaury Dame
40  * Nicolas Melchior
41  *
42  *****************************************************************************/
43 
44 #include <visp/vpImageSimulator.h>
45 #include <visp/vpRotationMatrix.h>
46 #include <visp/vpImageIo.h>
47 #include <visp/vpImageConvert.h>
48 #include <visp/vpPixelMeterConversion.h>
49 #include <visp/vpMeterPixelConversion.h>
50 #include <visp/vpMatrixException.h>
51 
62 {
63  for(int i=0;i<4;i++)
64  X[i].resize(3);
65 
66  for(int i=0;i<4;i++)
67  X2[i].resize(3);
68 
69  normal_obj.resize(3);
70  visible=false;
71  normal_Cam.resize(3);
72 
73  //Xinter.resize(3);
74 
75  vbase_u.resize(3);
76  vbase_v.resize(3);
77 
78  focal.resize(3);
79  focal=0;
80  focal[2]=1;
81 
82  normal_Cam_optim = new double[3];
83  X0_2_optim = new double[3];
84  vbase_u_optim = new double[3];
85  vbase_v_optim = new double[3];
86  Xinter_optim = new double[3];
87 
88  colorI = col;
89  interp = SIMPLE;
90  bgColor = vpColor::white;
91  cleanPrevImage = false;
92 }
93 
94 
99 {
100  for(int i=0;i<4;i++)
101  {
102  X[i] = text.X[i];
103  pt[i] = text.pt[i];
104  }
105 
106  for(int i=0;i<4;i++)
107  X2[i].resize(3);
108 
109  Ic = text.Ic;
110  Ig = text.Ig;
111 
112  focal.resize(3);
113  focal=0;
114  focal[2]=1;
115 
116  normal_obj = text.normal_obj;
117  euclideanNorm_u = text.euclideanNorm_u;
118  euclideanNorm_v = text.euclideanNorm_v;
119 
120  normal_Cam.resize(3);
121  vbase_u.resize(3);
122  vbase_v.resize(3);
123 
124 
125  normal_Cam_optim = new double[3];
126  X0_2_optim = new double[3];
127  vbase_u_optim = new double[3];
128  vbase_v_optim = new double[3];
129  Xinter_optim = new double[3];
130 
131  colorI = text.colorI;
132  interp = text.interp;
133  bgColor = text.bgColor;
134  cleanPrevImage = text.cleanPrevImage;
135 
136  setCameraPosition(text.cMt);
137 }
138 
143 {
144  delete[] normal_Cam_optim;
145  delete[] X0_2_optim;
146  delete[] vbase_u_optim;
147  delete[] vbase_v_optim;
148  delete[] Xinter_optim;
149 }
150 
151 
154 {
155  for(int i=0;i<4;i++)
156  {
157  X[i] = sim.X[i];
158  pt[i] = sim.pt[i];
159  }
160 
161  Ic = sim.Ic;
162  Ig = sim.Ig;
163 
164  bgColor = sim.bgColor;
165  cleanPrevImage = sim.cleanPrevImage;
166 
167  focal = sim.focal;
168 
169  normal_obj = sim.normal_obj;
170  euclideanNorm_u = sim.euclideanNorm_u;
171  euclideanNorm_v = sim.euclideanNorm_v;
172 
173  colorI = sim.colorI;
174  interp = sim.interp;
175 
176  setCameraPosition(sim.cMt);
177 
178  return *this;
179 }
180 
187 void
189  const vpCameraParameters &cam)
190 {
191  int nb_point_dessine = 0;
192  if (cleanPrevImage)
193  {
194  unsigned char col = (unsigned char)(0.2126 * bgColor.R + 0.7152 * bgColor.G + 0.0722 * bgColor.B);
195  for (unsigned int i = 0; i < I.getHeight(); i++)
196  {
197  for (unsigned int j = 0; j < I.getWidth(); j++)
198  {
199  I[i][j] = col;
200  }
201  }
202  }
203  if(visible)
204  {
205  getRoi(I.getWidth(),I.getHeight(),cam,pt,rect);
206 
207  double top = rect.getTop();
208  double bottom = rect.getBottom();
209  double left = rect.getLeft();
210  double right= rect.getRight();
211 
212  unsigned char *bitmap = I.bitmap;
213  unsigned int width = I.getWidth();
214  vpImagePoint ip;
215 
216  for (unsigned int i = (unsigned int)top; i < (unsigned int)bottom; i++)
217  {
218  for (unsigned int j = (unsigned int)left; j < (unsigned int)right; j++)
219  {
220  double x=0,y=0;
221  ip.set_ij(i,j);
223  ip.set_ij(y,x);
224  if (colorI == GRAY_SCALED)
225  {
226  unsigned char Ipixelplan = 0;
227  if(getPixel(ip,Ipixelplan))
228  {
229  *(bitmap+i*width+j)=Ipixelplan;
230  nb_point_dessine++;
231  }
232  }
233  else if (colorI == COLORED)
234  {
235  vpRGBa Ipixelplan;
236  if(getPixel(ip,Ipixelplan))
237  {
238  unsigned char pixelgrey = (unsigned char)(0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B);
239  *(bitmap+i*width+j)=pixelgrey;
240  nb_point_dessine++;
241  }
242  }
243  }
244  }
245  }
246 }
247 
248 
256 void
258  vpImage<unsigned char> &Isrc,
259  const vpCameraParameters &cam)
260 {
261  int nb_point_dessine = 0;
262  if (cleanPrevImage)
263  {
264  unsigned char col = (unsigned char)(0.2126 * bgColor.R + 0.7152 * bgColor.G + 0.0722 * bgColor.B);
265  for (unsigned int i = 0; i < I.getHeight(); i++)
266  {
267  for (unsigned int j = 0; j < I.getWidth(); j++)
268  {
269  I[i][j] = col;
270  }
271  }
272  }
273  if(visible)
274  {
275  getRoi(I.getWidth(),I.getHeight(),cam,pt,rect);
276 
277  double top = rect.getTop();
278  double bottom = rect.getBottom();
279  double left = rect.getLeft();
280  double right= rect.getRight();
281 
282  unsigned char *bitmap = I.bitmap;
283  unsigned int width = I.getWidth();
284  vpImagePoint ip;
285 
286  for (unsigned int i = (unsigned int)top; i < (unsigned int)bottom; i++)
287  {
288  for (unsigned int j = (unsigned int)left; j < (unsigned int)right; j++)
289  {
290  double x=0,y=0;
291  ip.set_ij(i,j);
293  ip.set_ij(y,x);
294  unsigned char Ipixelplan = 0;
295  if(getPixel(Isrc,ip,Ipixelplan))
296  {
297  *(bitmap+i*width+j)=Ipixelplan;
298  nb_point_dessine++;
299  }
300  }
301  }
302  }
303 }
304 
314 void
316  const vpCameraParameters &cam, vpMatrix &zBuffer)
317 {
318  if (I.getWidth() != (unsigned int)zBuffer.getCols() || I.getHeight() != (unsigned int)zBuffer.getRows())
319  throw (vpMatrixException(vpMatrixException::incorrectMatrixSizeError, " zBuffer must have the same size as the image I ! "));
320 
321  int nb_point_dessine = 0;
322  if (cleanPrevImage)
323  {
324  unsigned char col = (unsigned char)(0.2126 * bgColor.R + 0.7152 * bgColor.G + 0.0722 * bgColor.B);
325  for (unsigned int i = 0; i < I.getHeight(); i++)
326  {
327  for (unsigned int j = 0; j < I.getWidth(); j++)
328  {
329  I[i][j] = col;
330  }
331  }
332  }
333  if(visible)
334  {
335  getRoi(I.getWidth(),I.getHeight(),cam,pt,rect);
336 
337  double top = rect.getTop();
338  double bottom = rect.getBottom();
339  double left = rect.getLeft();
340  double right= rect.getRight();
341 
342  unsigned char *bitmap = I.bitmap;
343  unsigned int width = I.getWidth();
344  vpImagePoint ip;
345 
346  for (unsigned int i = (unsigned int)top; i < (unsigned int)bottom; i++)
347  {
348  for (unsigned int j = (unsigned int)left; j < (unsigned int)right; j++)
349  {
350  double x=0,y=0;
351  ip.set_ij(i,j);
353  ip.set_ij(y,x);
354  if (colorI == GRAY_SCALED)
355  {
356  unsigned char Ipixelplan;
357  if(getPixel(ip,Ipixelplan))
358  {
359  if (Xinter_optim[2] < zBuffer[i][j] || zBuffer[i][j] < 0)
360  {
361  *(bitmap+i*width+j)=Ipixelplan;
362  nb_point_dessine++;
363  zBuffer[i][j] = Xinter_optim[2];
364  }
365  }
366  }
367  else if (colorI == COLORED)
368  {
369  vpRGBa Ipixelplan;
370  if(getPixel(ip,Ipixelplan))
371  {
372  if (Xinter_optim[2] < zBuffer[i][j] || zBuffer[i][j] < 0)
373  {
374  unsigned char pixelgrey = (unsigned char)(0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B);
375  *(bitmap+i*width+j)=pixelgrey;
376  nb_point_dessine++;
377  zBuffer[i][j] = Xinter_optim[2];
378  }
379  }
380  }
381  }
382  }
383  }
384 }
385 
392 void
394 {
395  int nb_point_dessine = 0;
396  if (cleanPrevImage)
397  {
398  for (unsigned int i = 0; i < I.getHeight(); i++)
399  {
400  for (unsigned int j = 0; j < I.getWidth(); j++)
401  {
402  I[i][j] = bgColor;
403  }
404  }
405  }
406 
407  if(visible)
408  {
409  getRoi(I.getWidth(),I.getHeight(),cam,pt,rect);
410 
411  double top = rect.getTop();
412  double bottom = rect.getBottom();
413  double left = rect.getLeft();
414  double right= rect.getRight();
415 
416  vpRGBa *bitmap = I.bitmap;
417  unsigned int width = I.getWidth();
418  vpImagePoint ip;
419 
420  for (unsigned int i = (unsigned int)top; i < (unsigned int)bottom; i++)
421  {
422  for (unsigned int j = (unsigned int)left; j < (unsigned int)right; j++)
423  {
424  double x=0,y=0;
425  ip.set_ij(i,j);
427  ip.set_ij(y,x);
428  if (colorI == GRAY_SCALED)
429  {
430  unsigned char Ipixelplan;
431  if(getPixel(ip,Ipixelplan))
432  {
433  vpRGBa pixelcolor;
434  pixelcolor.R = Ipixelplan;
435  pixelcolor.G = Ipixelplan;
436  pixelcolor.B = Ipixelplan;
437  *(bitmap+i*width+j) = pixelcolor;
438  nb_point_dessine++;
439  }
440  }
441  else if (colorI == COLORED)
442  {
443  vpRGBa Ipixelplan;
444  if(getPixel(ip,Ipixelplan))
445  {
446  *(bitmap+i*width+j) = Ipixelplan;
447  nb_point_dessine++;
448  }
449  }
450  }
451  }
452  }
453 }
454 
455 
463 void
465  const vpCameraParameters &cam)
466 {
467  int nb_point_dessine = 0;
468  if (cleanPrevImage)
469  {
470  for (unsigned int i = 0; i < I.getHeight(); i++)
471  {
472  for (unsigned int j = 0; j < I.getWidth(); j++)
473  {
474  I[i][j] = bgColor;
475  }
476  }
477  }
478 
479  if(visible)
480  {
481  getRoi(I.getWidth(),I.getHeight(),cam,pt,rect);
482 
483  double top = rect.getTop();
484  double bottom = rect.getBottom();
485  double left = rect.getLeft();
486  double right= rect.getRight();
487 
488  vpRGBa *bitmap = I.bitmap;
489  unsigned int width = I.getWidth();
490  vpImagePoint ip;
491 
492  for (unsigned int i = (unsigned int)top; i < (unsigned int)bottom; i++)
493  {
494  for (unsigned int j = (unsigned int)left; j < (unsigned int)right; j++)
495  {
496  double x=0,y=0;
497  ip.set_ij(i,j);
499  ip.set_ij(y,x);
500  vpRGBa Ipixelplan;
501  if(getPixel(Isrc,ip,Ipixelplan))
502  {
503  *(bitmap+i*width+j) = Ipixelplan;
504  nb_point_dessine++;
505  }
506  }
507  }
508  }
509 }
510 
520 void
522  vpMatrix &zBuffer)
523 {
524  if (I.getWidth() != (unsigned int)zBuffer.getCols() || I.getHeight() != (unsigned int)zBuffer.getRows())
525  throw (vpMatrixException(vpMatrixException::incorrectMatrixSizeError, " zBuffer must have the same size as the image I ! "));
526 
527  int nb_point_dessine = 0;
528  if (cleanPrevImage)
529  {
530  for (unsigned int i = 0; i < I.getHeight(); i++)
531  {
532  for (unsigned int j = 0; j < I.getWidth(); j++)
533  {
534  I[i][j] = bgColor;
535  }
536  }
537  }
538  if(visible)
539  {
540  getRoi(I.getWidth(),I.getHeight(),cam,pt,rect);
541 
542  double top = rect.getTop();
543  double bottom = rect.getBottom();
544  double left = rect.getLeft();
545  double right= rect.getRight();
546 
547  vpRGBa *bitmap = I.bitmap;
548  unsigned int width = I.getWidth();
549  vpImagePoint ip;
550 
551  for (unsigned int i = (unsigned int)top; i < (unsigned int)bottom; i++)
552  {
553  for (unsigned int j = (unsigned int)left; j < (unsigned int)right; j++)
554  {
555  double x=0,y=0;
556  ip.set_ij(i,j);
558  ip.set_ij(y,x);
559  if (colorI == GRAY_SCALED)
560  {
561  unsigned char Ipixelplan;
562  if(getPixel(ip,Ipixelplan))
563  {
564  if (Xinter_optim[2] < zBuffer[i][j] || zBuffer[i][j] < 0)
565  {
566  vpRGBa pixelcolor;
567  pixelcolor.R = Ipixelplan;
568  pixelcolor.G = Ipixelplan;
569  pixelcolor.B = Ipixelplan;
570  *(bitmap+i*width+j) = pixelcolor;
571  nb_point_dessine++;
572  zBuffer[i][j] = Xinter_optim[2];
573  }
574  }
575  }
576  else if (colorI == COLORED)
577  {
578  vpRGBa Ipixelplan;
579  if(getPixel(ip,Ipixelplan))
580  {
581  if (Xinter_optim[2] < zBuffer[i][j] || zBuffer[i][j] < 0)
582  {
583  *(bitmap+i*width+j) = Ipixelplan;
584  nb_point_dessine++;
585  zBuffer[i][j] = Xinter_optim[2];
586  }
587  }
588  }
589  }
590  }
591  }
592 }
593 
594 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
595 
701 void
704  const vpCameraParameters &cam)
705 {
706 
707  unsigned int width = I.getWidth();
708  unsigned int height = I.getHeight();
709 
710  unsigned int nbsimList = list.nbElements();
711 
712  if (nbsimList < 1)
713  return;
714 
715  vpImageSimulator** simList = new vpImageSimulator* [nbsimList];
716 
717  double topFinal = height+1;;
718  double bottomFinal = -1;
719  double leftFinal = width+1;
720  double rightFinal = -1;
721 
722  list.front();
723 
724  unsigned int unvisible = 0;
725  for (unsigned int i = 0; i < nbsimList; i++)
726  {
727  vpImageSimulator* sim = &(list.value());
728  list.next();
729  if (sim->visible)
730  simList[i] = sim;
731  else
732  unvisible++;
733  }
734  nbsimList = nbsimList - unvisible;
735 
736  if (nbsimList < 1)
737  {
738  delete[] simList;
739  return;
740  }
741 
742 
743  for (unsigned int i = 0; i < nbsimList; i++)
744  {
745 
746  simList[i]->getRoi(width,height,cam,simList[i]->pt,simList[i]->rect);
747 
748  if (topFinal > simList[i]->rect.getTop()) topFinal = simList[i]->rect.getTop();
749  if (bottomFinal < simList[i]->rect.getBottom()) bottomFinal = simList[i]->rect.getBottom();
750  if (leftFinal > simList[i]->rect.getLeft()) leftFinal = simList[i]->rect.getLeft();
751  if (rightFinal < simList[i]->rect.getRight()) rightFinal = simList[i]->rect.getRight();
752  }
753 
754  double zmin = -1;
755  int indice = -1;
756  unsigned char *bitmap = I.bitmap;
757  vpImagePoint ip;
758 
759  for (unsigned int i = (unsigned int)topFinal; i < (unsigned int)bottomFinal; i++)
760  {
761  for (unsigned int j = (unsigned int)leftFinal; j < (unsigned int)rightFinal; j++)
762  {
763  zmin = -1;
764  double x=0,y=0;
765  ip.set_ij(i,j);
767  ip.set_ij(y,x);
768  for (int k = 0; k < (int)nbsimList; k++)
769  {
770  double z = 0;
771  if(simList[k]->getPixelDepth(ip,z))
772  {
773  if (z < zmin || zmin < 0)
774  {
775  zmin = z;
776  indice = k;
777  }
778  }
779  }
780  if (indice >= 0)
781  {
782  if (simList[indice]->colorI == GRAY_SCALED)
783  {
784  unsigned char Ipixelplan = 255;
785  simList[indice]->getPixel(ip,Ipixelplan);
786  *(bitmap+i*width+j)=Ipixelplan;
787  }
788  else if (simList[indice]->colorI == COLORED)
789  {
790  vpRGBa Ipixelplan(255,255,255);
791  simList[indice]->getPixel(ip,Ipixelplan);
792  unsigned char pixelgrey = (unsigned char)(0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B);
793  *(bitmap+i*width+j)=pixelgrey;
794  }
795  }
796  }
797  }
798 
799  delete[] simList;
800 }
801 
802 
908 void
910  const vpCameraParameters &cam)
911 {
912 
913  unsigned int width = I.getWidth();
914  unsigned int height = I.getHeight();
915 
916  unsigned int nbsimList = list.nbElements();
917 
918  if (nbsimList < 1)
919  return;
920 
921  vpImageSimulator** simList = new vpImageSimulator* [nbsimList];
922 
923  double topFinal = height+1;;
924  double bottomFinal = -1;
925  double leftFinal = width+1;
926  double rightFinal = -1;
927 
928  list.front();
929 
930  unsigned int unvisible = 0;
931  for (unsigned int i = 0; i < nbsimList; i++)
932  {
933  vpImageSimulator* sim = &(list.value());
934  list.next();
935  if (sim->visible)
936  simList[i] = sim;
937  else
938  unvisible++;
939  }
940  nbsimList = nbsimList - unvisible;
941 
942  if (nbsimList < 1)
943  {
944  delete[] simList;
945  return;
946  }
947 
948  for (unsigned int i = 0; i < nbsimList; i++)
949  {
950 
951  simList[i]->getRoi(width,height,cam,simList[i]->pt,simList[i]->rect);
952 
953  if (topFinal > simList[i]->rect.getTop()) topFinal = simList[i]->rect.getTop();
954  if (bottomFinal < simList[i]->rect.getBottom()) bottomFinal = simList[i]->rect.getBottom();
955  if (leftFinal > simList[i]->rect.getLeft()) leftFinal = simList[i]->rect.getLeft();
956  if (rightFinal < simList[i]->rect.getRight()) rightFinal = simList[i]->rect.getRight();
957  }
958 
959  double zmin = -1;
960  int indice = -1;
961  vpRGBa *bitmap = I.bitmap;
962  vpImagePoint ip;
963 
964  for (unsigned int i = (unsigned int)topFinal; i < (unsigned int)bottomFinal; i++)
965  {
966  for (unsigned int j = (unsigned int)leftFinal; j < (unsigned int)rightFinal; j++)
967  {
968  zmin = -1;
969  double x=0,y=0;
970  ip.set_ij(i,j);
972  ip.set_ij(y,x);
973  for (int k = 0; k < (int)nbsimList; k++)
974  {
975  double z = 0;
976  if(simList[k]->getPixelDepth(ip,z))
977  {
978  if (z < zmin || zmin < 0)
979  {
980  zmin = z;
981  indice = k;
982  }
983  }
984  }
985  if (indice >= 0)
986  {
987  if (simList[indice]->colorI == GRAY_SCALED)
988  {
989  unsigned char Ipixelplan = 255;
990  simList[indice]->getPixel(ip,Ipixelplan);
991  vpRGBa pixelcolor;
992  pixelcolor.R = Ipixelplan;
993  pixelcolor.G = Ipixelplan;
994  pixelcolor.B = Ipixelplan;
995  *(bitmap+i*width+j) = pixelcolor;
996  }
997  else if (simList[indice]->colorI == COLORED)
998  {
999  vpRGBa Ipixelplan(255,255,255);
1000  simList[indice]->getPixel(ip,Ipixelplan);
1001  //unsigned char pixelgrey = 0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B;
1002  *(bitmap+i*width+j)=Ipixelplan;
1003  }
1004  }
1005  }
1006  }
1007 
1008  delete[] simList;
1009 }
1010 #endif
1011 
1113 void
1115  std::list<vpImageSimulator> &list,
1116  const vpCameraParameters &cam)
1117 {
1118 
1119  unsigned int width = I.getWidth();
1120  unsigned int height = I.getHeight();
1121 
1122  unsigned int nbsimList = list.size();
1123 
1124  if (nbsimList < 1)
1125  return;
1126 
1127  vpImageSimulator** simList = new vpImageSimulator* [nbsimList];
1128 
1129  double topFinal = height+1;;
1130  double bottomFinal = -1;
1131  double leftFinal = width+1;
1132  double rightFinal = -1;
1133 
1134  unsigned int unvisible = 0;
1135  unsigned int indexSimu=0;
1136  for(std::list<vpImageSimulator>::iterator it=list.begin(); it!=list.end(); ++it, ++indexSimu){
1137  vpImageSimulator* sim = &(*it);
1138  if (sim->visible)
1139  simList[indexSimu] = sim;
1140  else
1141  unvisible++;
1142  }
1143  nbsimList = nbsimList - unvisible;
1144 
1145  if (nbsimList < 1)
1146  {
1147  delete[] simList;
1148  return;
1149  }
1150 
1151 
1152  for (unsigned int i = 0; i < nbsimList; i++)
1153  {
1154 
1155  simList[i]->getRoi(width,height,cam,simList[i]->pt,simList[i]->rect);
1156 
1157  if (topFinal > simList[i]->rect.getTop()) topFinal = simList[i]->rect.getTop();
1158  if (bottomFinal < simList[i]->rect.getBottom()) bottomFinal = simList[i]->rect.getBottom();
1159  if (leftFinal > simList[i]->rect.getLeft()) leftFinal = simList[i]->rect.getLeft();
1160  if (rightFinal < simList[i]->rect.getRight()) rightFinal = simList[i]->rect.getRight();
1161  }
1162 
1163  double zmin = -1;
1164  int indice = -1;
1165  unsigned char *bitmap = I.bitmap;
1166  vpImagePoint ip;
1167 
1168  for (unsigned int i = (unsigned int)topFinal; i < (unsigned int)bottomFinal; i++)
1169  {
1170  for (unsigned int j = (unsigned int)leftFinal; j < (unsigned int)rightFinal; j++)
1171  {
1172  zmin = -1;
1173  double x=0,y=0;
1174  ip.set_ij(i,j);
1176  ip.set_ij(y,x);
1177  for (int k = 0; k < (int)nbsimList; k++)
1178  {
1179  double z = 0;
1180  if(simList[k]->getPixelDepth(ip,z))
1181  {
1182  if (z < zmin || zmin < 0)
1183  {
1184  zmin = z;
1185  indice = k;
1186  }
1187  }
1188  }
1189  if (indice >= 0)
1190  {
1191  if (simList[indice]->colorI == GRAY_SCALED)
1192  {
1193  unsigned char Ipixelplan = 255;
1194  simList[indice]->getPixel(ip,Ipixelplan);
1195  *(bitmap+i*width+j)=Ipixelplan;
1196  }
1197  else if (simList[indice]->colorI == COLORED)
1198  {
1199  vpRGBa Ipixelplan(255,255,255);
1200  simList[indice]->getPixel(ip,Ipixelplan);
1201  unsigned char pixelgrey = (unsigned char)(0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B);
1202  *(bitmap+i*width+j)=pixelgrey;
1203  }
1204  }
1205  }
1206  }
1207 
1208  delete[] simList;
1209 }
1210 
1211 
1313 void
1315  std::list<vpImageSimulator> &list,
1316  const vpCameraParameters &cam)
1317 {
1318 
1319  unsigned int width = I.getWidth();
1320  unsigned int height = I.getHeight();
1321 
1322  unsigned int nbsimList = list.size();
1323 
1324  if (nbsimList < 1)
1325  return;
1326 
1327  vpImageSimulator** simList = new vpImageSimulator* [nbsimList];
1328 
1329  double topFinal = height+1;;
1330  double bottomFinal = -1;
1331  double leftFinal = width+1;
1332  double rightFinal = -1;
1333 
1334  unsigned int unvisible = 0;
1335  unsigned int indexSimu = 0;
1336  for(std::list<vpImageSimulator>::iterator it=list.begin(); it!=list.end(); ++it, ++indexSimu){
1337  vpImageSimulator* sim = &(*it);
1338  if (sim->visible)
1339  simList[indexSimu] = sim;
1340  else
1341  unvisible++;
1342  }
1343 
1344  nbsimList = nbsimList - unvisible;
1345 
1346  if (nbsimList < 1)
1347  {
1348  delete[] simList;
1349  return;
1350  }
1351 
1352  for (unsigned int i = 0; i < nbsimList; i++)
1353  {
1354 
1355  simList[i]->getRoi(width,height,cam,simList[i]->pt,simList[i]->rect);
1356 
1357  if (topFinal > simList[i]->rect.getTop()) topFinal = simList[i]->rect.getTop();
1358  if (bottomFinal < simList[i]->rect.getBottom()) bottomFinal = simList[i]->rect.getBottom();
1359  if (leftFinal > simList[i]->rect.getLeft()) leftFinal = simList[i]->rect.getLeft();
1360  if (rightFinal < simList[i]->rect.getRight()) rightFinal = simList[i]->rect.getRight();
1361  }
1362 
1363  double zmin = -1;
1364  int indice = -1;
1365  vpRGBa *bitmap = I.bitmap;
1366  vpImagePoint ip;
1367 
1368  for (unsigned int i = (unsigned int)topFinal; i < (unsigned int)bottomFinal; i++)
1369  {
1370  for (unsigned int j = (unsigned int)leftFinal; j < (unsigned int)rightFinal; j++)
1371  {
1372  zmin = -1;
1373  double x=0,y=0;
1374  ip.set_ij(i,j);
1376  ip.set_ij(y,x);
1377  for (int k = 0; k < (int)nbsimList; k++)
1378  {
1379  double z = 0;
1380  if(simList[k]->getPixelDepth(ip,z))
1381  {
1382  if (z < zmin || zmin < 0)
1383  {
1384  zmin = z;
1385  indice = k;
1386  }
1387  }
1388  }
1389  if (indice >= 0)
1390  {
1391  if (simList[indice]->colorI == GRAY_SCALED)
1392  {
1393  unsigned char Ipixelplan = 255;
1394  simList[indice]->getPixel(ip,Ipixelplan);
1395  vpRGBa pixelcolor;
1396  pixelcolor.R = Ipixelplan;
1397  pixelcolor.G = Ipixelplan;
1398  pixelcolor.B = Ipixelplan;
1399  *(bitmap+i*width+j) = pixelcolor;
1400  }
1401  else if (simList[indice]->colorI == COLORED)
1402  {
1403  vpRGBa Ipixelplan(255,255,255);
1404  simList[indice]->getPixel(ip,Ipixelplan);
1405  //unsigned char pixelgrey = 0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B;
1406  *(bitmap+i*width+j)=Ipixelplan;
1407  }
1408  }
1409  }
1410  }
1411 
1412  delete[] simList;
1413 }
1414 
1420 void
1422 {
1423  cMt = _cMt;
1424  vpRotationMatrix R;
1425  cMt.extract(R);
1426 
1427  normal_Cam = R * normal_obj;
1428 
1429  visible_result = vpColVector::dotProd(normal_Cam,focal);
1430 
1431  for(int i = 0; i < 4; i++)
1432  pt[i].track(cMt);
1433 
1434  vpColVector e1(3) ;
1435  vpColVector e2(3) ;
1436  vpColVector facenormal(3) ;
1437 
1438  e1[0] = pt[1].get_X() - pt[0].get_X() ;
1439  e1[1] = pt[1].get_Y() - pt[0].get_Y() ;
1440  e1[2] = pt[1].get_Z() - pt[0].get_Z() ;
1441 
1442  e2[0] = pt[2].get_X() - pt[1].get_X() ;
1443  e2[1] = pt[2].get_Y() - pt[1].get_Y() ;
1444  e2[2] = pt[2].get_Z() - pt[1].get_Z() ;
1445 
1446  facenormal = vpColVector::crossProd(e1,e2) ;
1447 
1448  double angle = pt[0].get_X()*facenormal[0] + pt[0].get_Y()*facenormal[1] + pt[0].get_Z()*facenormal[2] ;
1449 
1450  if (angle > 0)
1451  visible=true;
1452  else
1453  visible=false;
1454 
1455  if(visible)
1456  {
1457  for(int i = 0; i < 4; i++)
1458  {
1459  project(X[i],cMt,X2[i]);
1460  pt[i].track(cMt);
1461  }
1462 
1463  vbase_u = X2[1]-X2[0];
1464  vbase_v = X2[3]-X2[0];
1465 
1466  distance = vpColVector::dotProd(normal_Cam,X2[1]);
1467 
1468  if(distance < 0)
1469  {
1470  visible = false;
1471  return;
1472  }
1473 
1474  for(unsigned int i = 0; i < 3; i++)
1475  {
1476  normal_Cam_optim[i] = normal_Cam[i];
1477  X0_2_optim[i] = X2[0][i];
1478  vbase_u_optim[i] = vbase_u[i];
1479  vbase_v_optim[i] = vbase_v[i];
1480  }
1481 
1482  vpImagePoint iPa[4];
1483  for(unsigned int i = 0; i < 4; i++)
1484  {
1485  iPa[i].set_j(X2[i][0]/X2[i][2]);
1486  iPa[i].set_i(X2[i][1]/X2[i][2]);
1487  }
1488 
1489  T1.buildFrom(iPa[0],iPa[1],iPa[3]);
1490  T2.buildFrom(iPa[2],iPa[1],iPa[3]);
1491  }
1492 }
1493 
1494 void
1495 vpImageSimulator::initPlan(vpColVector* _X)
1496 {
1497  for (unsigned int i = 0; i < 4; i++)
1498  {
1499  X[i]=_X[i];
1500  pt[i].setWorldCoordinates(_X[i][0],_X[i][1],_X[i][2]);
1501  }
1502 
1503  normal_obj=vpColVector::crossProd(X[1]-X[0],X[3]-X[0]);
1504  normal_obj=normal_obj/normal_obj.euclideanNorm();
1505 
1506  euclideanNorm_u=(X[1]-X[0]).euclideanNorm();
1507  euclideanNorm_v=(X[3]-X[0]).euclideanNorm();
1508 }
1509 
1523 void
1525 {
1526  Ig = I;
1528  initPlan(_X);
1529 }
1530 
1544 void
1546 {
1547  Ic = I;
1549  initPlan(_X);
1550 }
1551 
1565 void
1566 vpImageSimulator::init(const char* file_image,vpColVector* _X)
1567 {
1568  vpImageIo::read(Ig,file_image);
1569  vpImageIo::read(Ic,file_image);
1570  initPlan(_X);
1571 }
1572 
1587 void
1588 vpImageSimulator::init(const vpImage<unsigned char> &I, const std::vector<vpPoint>& _X)
1589 {
1590  if(_X.size() != 4){
1591  throw vpException(vpException::dimensionError, "the vector must contains 4 points to initialise the simulator");
1592  }
1593  vpColVector Xvec[4];
1594  for(unsigned int i=0; i<4; ++i){
1595  Xvec[i].resize(3);
1596  Xvec[i][0] = _X[i].get_oX();
1597  Xvec[i][1] = _X[i].get_oY();
1598  Xvec[i][2] = _X[i].get_oZ();
1599  }
1600 
1601  Ig = I;
1603  initPlan(Xvec);
1604 }
1619 void
1620 vpImageSimulator::init(const vpImage<vpRGBa> &I, const std::vector<vpPoint>& _X)
1621 {
1622  if(_X.size() != 4){
1623  throw vpException(vpException::dimensionError, "the vector must contains 4 points to initialise the simulator");
1624  }
1625  vpColVector Xvec[4];
1626  for(unsigned int i=0; i<4; ++i){
1627  Xvec[i].resize(3);
1628  Xvec[i][0] = _X[i].get_oX();
1629  Xvec[i][1] = _X[i].get_oY();
1630  Xvec[i][2] = _X[i].get_oZ();
1631  }
1632 
1633  Ic = I;
1635  initPlan(Xvec);
1636 }
1651 void
1652 vpImageSimulator::init(const char* file_image, const std::vector<vpPoint>& _X)
1653 {
1654  if(_X.size() != 4){
1655  throw vpException(vpException::dimensionError, "the vector must contains 4 points to initialise the simulator");
1656  }
1657  vpColVector Xvec[4];
1658  for(unsigned int i=0; i<4; ++i){
1659  Xvec[i].resize(3);
1660  Xvec[i][0] = _X[i].get_oX();
1661  Xvec[i][1] = _X[i].get_oY();
1662  Xvec[i][2] = _X[i].get_oZ();
1663  }
1664 
1665  vpImageIo::read(Ig,file_image);
1666  vpImageIo::read(Ic,file_image);
1667  initPlan(Xvec);
1668 }
1669 
1670 bool
1671 vpImageSimulator::getPixel(const vpImagePoint &iP, unsigned char &Ipixelplan)
1672 {
1673  //test si pixel dans zone projetee
1674  if(!T1.inTriangle(iP) && !T2.inTriangle(iP))
1675  return false;
1676 
1677  //methoed algebrique
1678  double z;
1679 
1680  //calcul de la profondeur de l'intersection
1681  z = distance/(normal_Cam_optim[0]*iP.get_u()+normal_Cam_optim[1]*iP.get_v()+normal_Cam_optim[2]);
1682  //calcul coordonnees 3D intersection
1683  Xinter_optim[0]=iP.get_u()*z;
1684  Xinter_optim[1]=iP.get_v()*z;
1685  Xinter_optim[2]=z;
1686 
1687  //recuperation des coordonnes de l'intersection dans le plan objet
1688  //repere plan object :
1689  // centre = X0_2_optim[i] (premier point definissant le plan)
1690  // base = u:(X[1]-X[0]) et v:(X[3]-X[0])
1691  //ici j'ai considere que le plan est un rectangle => coordonnees sont simplement obtenu par un produit scalaire
1692  double u = 0, v = 0;
1693  double diff = 0;
1694  for(unsigned int i = 0; i < 3; i++)
1695  {
1696  diff = (Xinter_optim[i]-X0_2_optim[i]);
1697  u += diff*vbase_u_optim[i];
1698  v += diff*vbase_v_optim[i];
1699  }
1700  u = u/(euclideanNorm_u*euclideanNorm_u);
1701  v = v/(euclideanNorm_v*euclideanNorm_v);
1702 
1703  if( u > 0 && v > 0 && u < 1. && v < 1.)
1704  {
1705  double i2,j2;
1706  i2=v*(Ig.getHeight()-1);
1707  j2=u*(Ig.getWidth()-1);
1708  if (interp == BILINEAR_INTERPOLATION)
1709  Ipixelplan = Ig.getValue(i2,j2);
1710  else if (interp == SIMPLE)
1711  Ipixelplan = Ig[(unsigned int)i2][(unsigned int)j2];
1712  return true;
1713  }
1714  else
1715  return false;
1716 }
1717 
1718 bool
1719 vpImageSimulator::getPixel(vpImage<unsigned char> &Isrc,
1720  const vpImagePoint &iP, unsigned char &Ipixelplan)
1721 {
1722  //test si pixel dans zone projetee
1723  if(!T1.inTriangle(iP) && !T2.inTriangle(iP))
1724  return false;
1725 
1726  //methoed algebrique
1727  double z;
1728 
1729  //calcul de la profondeur de l'intersection
1730  z = distance/(normal_Cam_optim[0]*iP.get_u()+normal_Cam_optim[1]*iP.get_v()+normal_Cam_optim[2]);
1731  //calcul coordonnees 3D intersection
1732  Xinter_optim[0]=iP.get_u()*z;
1733  Xinter_optim[1]=iP.get_v()*z;
1734  Xinter_optim[2]=z;
1735 
1736  //recuperation des coordonnes de l'intersection dans le plan objet
1737  //repere plan object :
1738  // centre = X0_2_optim[i] (premier point definissant le plan)
1739  // base = u:(X[1]-X[0]) et v:(X[3]-X[0])
1740  //ici j'ai considere que le plan est un rectangle => coordonnees sont simplement obtenu par un produit scalaire
1741  double u = 0, v = 0;
1742  double diff = 0;
1743  for(unsigned int i = 0; i < 3; i++)
1744  {
1745  diff = (Xinter_optim[i]-X0_2_optim[i]);
1746  u += diff*vbase_u_optim[i];
1747  v += diff*vbase_v_optim[i];
1748  }
1749  u = u/(euclideanNorm_u*euclideanNorm_u);
1750  v = v/(euclideanNorm_v*euclideanNorm_v);
1751 
1752  if( u > 0 && v > 0 && u < 1. && v < 1.)
1753  {
1754  double i2,j2;
1755  i2=v*(Isrc.getHeight()-1);
1756  j2=u*(Isrc.getWidth()-1);
1757  if (interp == BILINEAR_INTERPOLATION)
1758  Ipixelplan = Isrc.getValue(i2,j2);
1759  else if (interp == SIMPLE)
1760  Ipixelplan = Isrc[(unsigned int)i2][(unsigned int)j2];
1761  return true;
1762  }
1763  else
1764  return false;
1765 }
1766 
1767 
1768 bool
1769 vpImageSimulator::getPixel(const vpImagePoint &iP, vpRGBa &Ipixelplan)
1770 {
1771  //test si pixel dans zone projetee
1772  if(!T1.inTriangle(iP) && !T2.inTriangle(iP))
1773  return false;
1774 
1775  //methoed algebrique
1776  double z;
1777 
1778  //calcul de la profondeur de l'intersection
1779  z = distance/(normal_Cam_optim[0]*iP.get_u()+normal_Cam_optim[1]*iP.get_v()+normal_Cam_optim[2]);
1780  //calcul coordonnees 3D intersection
1781  Xinter_optim[0]=iP.get_u()*z;
1782  Xinter_optim[1]=iP.get_v()*z;
1783  Xinter_optim[2]=z;
1784 
1785  //recuperation des coordonnes de l'intersection dans le plan objet
1786  //repere plan object :
1787  // centre = X0_2_optim[i] (premier point definissant le plan)
1788  // base = u:(X[1]-X[0]) et v:(X[3]-X[0])
1789  //ici j'ai considere que le plan est un rectangle => coordonnees sont simplement obtenu par un produit scalaire
1790  double u = 0, v = 0;
1791  double diff = 0;
1792  for(unsigned int i = 0; i < 3; i++)
1793  {
1794  diff = (Xinter_optim[i]-X0_2_optim[i]);
1795  u += diff*vbase_u_optim[i];
1796  v += diff*vbase_v_optim[i];
1797  }
1798  u = u/(euclideanNorm_u*euclideanNorm_u);
1799  v = v/(euclideanNorm_v*euclideanNorm_v);
1800 
1801  if( u > 0 && v > 0 && u < 1. && v < 1.)
1802  {
1803  double i2,j2;
1804  i2=v*(Ic.getHeight()-1);
1805  j2=u*(Ic.getWidth()-1);
1806  if (interp == BILINEAR_INTERPOLATION)
1807  Ipixelplan = Ic.getValue(i2,j2);
1808  else if (interp == SIMPLE)
1809  Ipixelplan = Ic[(unsigned int)i2][(unsigned int)j2];
1810  return true;
1811  }
1812  else
1813  return false;
1814 }
1815 
1816 bool
1817 vpImageSimulator::getPixel(vpImage<vpRGBa> &Isrc, const vpImagePoint &iP,
1818  vpRGBa &Ipixelplan)
1819 {
1820  //test si pixel dans zone projetee
1821  if(!T1.inTriangle(iP) && !T2.inTriangle(iP))
1822  return false;
1823 
1824  //methoed algebrique
1825  double z;
1826 
1827  //calcul de la profondeur de l'intersection
1828  z = distance/(normal_Cam_optim[0]*iP.get_u()+normal_Cam_optim[1]*iP.get_v()+normal_Cam_optim[2]);
1829  //calcul coordonnees 3D intersection
1830  Xinter_optim[0]=iP.get_u()*z;
1831  Xinter_optim[1]=iP.get_v()*z;
1832  Xinter_optim[2]=z;
1833 
1834  //recuperation des coordonnes de l'intersection dans le plan objet
1835  //repere plan object :
1836  // centre = X0_2_optim[i] (premier point definissant le plan)
1837  // base = u:(X[1]-X[0]) et v:(X[3]-X[0])
1838  //ici j'ai considere que le plan est un rectangle => coordonnees sont simplement obtenu par un produit scalaire
1839  double u = 0, v = 0;
1840  double diff = 0;
1841  for(unsigned int i = 0; i < 3; i++)
1842  {
1843  diff = (Xinter_optim[i]-X0_2_optim[i]);
1844  u += diff*vbase_u_optim[i];
1845  v += diff*vbase_v_optim[i];
1846  }
1847  u = u/(euclideanNorm_u*euclideanNorm_u);
1848  v = v/(euclideanNorm_v*euclideanNorm_v);
1849 
1850  if( u > 0 && v > 0 && u < 1. && v < 1.)
1851  {
1852  double i2,j2;
1853  i2=v*(Isrc.getHeight()-1);
1854  j2=u*(Isrc.getWidth()-1);
1855  if (interp == BILINEAR_INTERPOLATION)
1856  Ipixelplan = Isrc.getValue(i2,j2);
1857  else if (interp == SIMPLE)
1858  Ipixelplan = Isrc[(unsigned int)i2][(unsigned int)j2];
1859  return true;
1860  }
1861  else
1862  return false;
1863 }
1864 
1865 bool
1866 vpImageSimulator::getPixelDepth(const vpImagePoint &iP, double &Zpixelplan)
1867 {
1868  //test si pixel dans zone projetee
1869  if(!T1.inTriangle(iP) && !T2.inTriangle(iP))
1870  return false;
1871 
1872  Zpixelplan = distance/(normal_Cam_optim[0]*iP.get_u()+normal_Cam_optim[1]*iP.get_v()+normal_Cam_optim[2]);
1873  return true;
1874 }
1875 
1876 bool
1877 vpImageSimulator::getPixelVisibility(const vpImagePoint &iP,
1878  double &Visipixelplan)
1879 {
1880  //test si pixel dans zone projetee
1881  if(!T1.inTriangle(iP) && !T2.inTriangle(iP))
1882  return false;
1883 
1884  Visipixelplan = visible_result;
1885  return true;
1886 }
1887 
1888 void
1889 vpImageSimulator::project(const vpColVector &_vin,
1890  const vpHomogeneousMatrix &_cMt, vpColVector &_vout)
1891 {
1892  vpColVector XH(4);
1893  getHomogCoord(_vin,XH);
1894  getCoordFromHomog(_cMt*XH,_vout);
1895 }
1896 
1897 void
1898 vpImageSimulator::getHomogCoord(const vpColVector &_v, vpColVector &_vH)
1899 {
1900  for(unsigned int i=0;i<3;i++)
1901  _vH[i]=_v[i];
1902  _vH[3]=1.;
1903 }
1904 
1905 void
1906 vpImageSimulator::getCoordFromHomog(const vpColVector &_vH, vpColVector &_v)
1907 {
1908  for(unsigned int i=0;i<3;i++)
1909  _v[i]=_vH[i]/_vH[3];
1910 }
1911 
1912 
1913 void
1914 vpImageSimulator::getRoi(const unsigned int &Iwidth,
1915  const unsigned int &Iheight,
1916  const vpCameraParameters &cam,
1917  vpPoint* point, vpRect &rectangle)
1918 {
1919  double top = Iheight+1;
1920  double bottom = -1;
1921  double right = -1;
1922  double left= Iwidth+1;
1923  for( int i = 0; i < 4; i++)
1924  {
1925  double u=0,v=0;
1926  vpMeterPixelConversion::convertPoint(cam,point[i].get_x(),point[i].get_y(),u,v);
1927  if (v < top) top = v;
1928  if (v > bottom) bottom = v;
1929  if (u < left) left = u;
1930  if (u > right) right = u;
1931  }
1932  if (top < 0) top = 0;
1933  if(top >= Iheight) top = Iheight-1;
1934  if (bottom < 0) bottom = 0;
1935  if(bottom >= Iheight) bottom = Iheight-1;
1936  if(left < 0) left = 0;
1937  if(left >= Iwidth) left = Iwidth-1;
1938  if(right < 0) right = 0;
1939  if(right >= Iwidth) right = Iwidth-1;
1940 
1941  rectangle.setTop(top);
1942  rectangle.setBottom(bottom);
1943  rectangle.setLeft(left);
1944  rectangle.setRight(right);
1945 }
void set_j(const double j)
Definition: vpImagePoint.h:156
Definition of the vpMatrix class.
Definition: vpMatrix.h:96
double getTop() const
Definition: vpRect.h:169
double get_v() const
Definition: vpImagePoint.h:250
unsigned int nbElements(void)
return the number of element in the list
Definition: vpList.h:261
unsigned int getWidth() const
Definition: vpImage.h:154
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
unsigned char B
Blue component.
Definition: vpRGBa.h:155
Provide simple list management.
Definition: vpList.h:112
Type * bitmap
points toward the bitmap
Definition: vpImage.h:115
void getImage(vpImage< unsigned char > &I, const vpCameraParameters &cam)
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 ...
void setLeft(double pos)
Definition: vpRect.h:227
double get_u() const
Definition: vpImagePoint.h:239
void set_i(const double i)
Definition: vpImagePoint.h:145
Type getValue(double i, double j) const
Definition: vpImage.h:1034
void track(const vpHomogeneousMatrix &cMo)
bool inTriangle(const vpImagePoint &iP, double threshold=0.00001)
Definition: vpTriangle.cpp:171
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Point coordinates conversion from pixel coordinates to normalized coordinates in meter...
unsigned char G
Green component.
Definition: vpRGBa.h:154
double getRight() const
Definition: vpRect.h:162
Class that defines a RGB 32 bits structure.
Definition: vpRGBa.h:68
void next(void)
position the current element on the next one
Definition: vpList.h:275
Class that defines what is a point.
Definition: vpPoint.h:65
The vpRotationMatrix considers the particular case of a rotation matrix.
double getBottom() const
Definition: vpRect.h:98
void setTop(double pos)
Definition: vpRect.h:258
void set_ij(const double i, const double j)
Definition: vpImagePoint.h:167
void front(void)
Position the current element on the first element of the list.
Definition: vpList.h:386
type & value(void)
return the value of the current element
Definition: vpList.h:303
vpImageSimulator & operator=(const vpImageSimulator &sim)
Generic class defining intrinsic camera parameters.
void init(const vpImage< unsigned char > &I, vpColVector *_X)
Class which enables to project an image in the 3D space and get the view of a virtual camera...
void extract(vpRotationMatrix &R) const
double get_Y() const
Get the point Y coordinate in the camera frame.
Definition: vpPoint.h:127
vpImageSimulator(const vpColorPlan &col=COLORED)
double get_Z() const
Get the point Z coordinate in the camera frame.
Definition: vpPoint.h:129
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
void setRight(double pos)
Definition: vpRect.h:249
double euclideanNorm() const
Definition: vpMatrix.cpp:2785
unsigned char R
Red component.
Definition: vpRGBa.h:153
unsigned int getCols() const
Return the number of columns of the matrix.
Definition: vpMatrix.h:159
static double dotProd(const vpColVector &a, const vpColVector &b)
Dot Product.
void buildFrom(const vpImagePoint &iP1, const vpImagePoint &iP2, const vpImagePoint &iP3)
Definition: vpTriangle.cpp:122
error that can be emited by the vpMatrix class and its derivates
unsigned int getHeight() const
Definition: vpImage.h:145
Defines a rectangle in the plane.
Definition: vpRect.h:82
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:92
static vpColVector crossProd(const vpColVector &a, const vpColVector &b)
normalise the vector
void setCameraPosition(const vpHomogeneousMatrix &_cMt)
static void read(vpImage< unsigned char > &I, const char *filename)
Definition: vpImageIo.cpp:239
unsigned int getRows() const
Return the number of rows of the matrix.
Definition: vpMatrix.h:157
static const vpColor white
Definition: vpColor.h:160
double get_X() const
Get the point X coordinate in the camera frame.
Definition: vpPoint.h:125
double getLeft() const
Definition: vpRect.h:156
void setBottom(double pos)
Definition: vpRect.h:198
void setWorldCoordinates(const double ox, const double oy, const double oz)
Set the point world coordinates. We mean here the coordinates of the point in the object frame...
Definition: vpPoint.cpp:74
void resize(const unsigned int i, const bool flagNullify=true)
Definition: vpColVector.h:94