ViSP  2.8.0
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 - 2013 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  setBackgroundTexture = false;
93 }
94 
95 
100 {
101  for(int i=0;i<4;i++)
102  {
103  X[i] = text.X[i];
104  pt[i] = text.pt[i];
105  }
106 
107  for(int i=0;i<4;i++)
108  X2[i].resize(3);
109 
110  Ic = text.Ic;
111  Ig = text.Ig;
112 
113  focal.resize(3);
114  focal=0;
115  focal[2]=1;
116 
117  normal_obj = text.normal_obj;
118  euclideanNorm_u = text.euclideanNorm_u;
119  euclideanNorm_v = text.euclideanNorm_v;
120 
121  normal_Cam.resize(3);
122  vbase_u.resize(3);
123  vbase_v.resize(3);
124 
125 
126  normal_Cam_optim = new double[3];
127  X0_2_optim = new double[3];
128  vbase_u_optim = new double[3];
129  vbase_v_optim = new double[3];
130  Xinter_optim = new double[3];
131 
132  colorI = text.colorI;
133  interp = text.interp;
134  bgColor = text.bgColor;
135  cleanPrevImage = text.cleanPrevImage;
136  setBackgroundTexture = false;
137 
138  setCameraPosition(text.cMt);
139 }
140 
145 {
146  delete[] normal_Cam_optim;
147  delete[] X0_2_optim;
148  delete[] vbase_u_optim;
149  delete[] vbase_v_optim;
150  delete[] Xinter_optim;
151 }
152 
153 
156 {
157  for(int i=0;i<4;i++)
158  {
159  X[i] = sim.X[i];
160  pt[i] = sim.pt[i];
161  }
162 
163  Ic = sim.Ic;
164  Ig = sim.Ig;
165 
166  bgColor = sim.bgColor;
167  cleanPrevImage = sim.cleanPrevImage;
168 
169  focal = sim.focal;
170 
171  normal_obj = sim.normal_obj;
172  euclideanNorm_u = sim.euclideanNorm_u;
173  euclideanNorm_v = sim.euclideanNorm_v;
174 
175  colorI = sim.colorI;
176  interp = sim.interp;
177 
178  setCameraPosition(sim.cMt);
179 
180  return *this;
181 }
182 
188 void
190  const vpCameraParameters &cam)
191 {
192  int nb_point_dessine = 0;
193  if (setBackgroundTexture)
194  // The Ig has been set to a previously defined background texture
195  I = Ig;
196  else
197  {
198  if (cleanPrevImage)
199  {
200  unsigned char col = (unsigned char) (0.2126 * bgColor.R
201  + 0.7152 * bgColor.G + 0.0722 * bgColor.B);
202  for (unsigned int i = 0; i < I.getHeight(); i++)
203  {
204  for (unsigned int j = 0; j < I.getWidth(); j++)
205  {
206  I[i][j] = col;
207  }
208  }
209  }
210  }
211 
212  if(visible)
213  {
214  getRoi(I.getWidth(),I.getHeight(),cam,pt,rect);
215 
216  double top = rect.getTop();
217  double bottom = rect.getBottom();
218  double left = rect.getLeft();
219  double right= rect.getRight();
220 
221  unsigned char *bitmap = I.bitmap;
222  unsigned int width = I.getWidth();
223  vpImagePoint ip;
224 
225  for (unsigned int i = (unsigned int)top; i < (unsigned int)bottom; i++)
226  {
227  for (unsigned int j = (unsigned int)left; j < (unsigned int)right; j++)
228  {
229  double x=0,y=0;
230  ip.set_ij(i,j);
232  ip.set_ij(y,x);
233  if (colorI == GRAY_SCALED)
234  {
235  unsigned char Ipixelplan = 0;
236  if(getPixel(ip,Ipixelplan))
237  {
238  *(bitmap+i*width+j)=Ipixelplan;
239  nb_point_dessine++;
240  }
241  }
242  else if (colorI == COLORED)
243  {
244  vpRGBa Ipixelplan;
245  if(getPixel(ip,Ipixelplan))
246  {
247  unsigned char pixelgrey = (unsigned char)(0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B);
248  *(bitmap+i*width+j)=pixelgrey;
249  nb_point_dessine++;
250  }
251  }
252  }
253  }
254  }
255 }
256 
257 
265 void
268  const vpCameraParameters &cam)
269 {
270  int nb_point_dessine = 0;
271  if (cleanPrevImage)
272  {
273  unsigned char col = (unsigned char)(0.2126 * bgColor.R + 0.7152 * bgColor.G + 0.0722 * bgColor.B);
274  for (unsigned int i = 0; i < I.getHeight(); i++)
275  {
276  for (unsigned int j = 0; j < I.getWidth(); j++)
277  {
278  I[i][j] = col;
279  }
280  }
281  }
282  if(visible)
283  {
284  getRoi(I.getWidth(),I.getHeight(),cam,pt,rect);
285 
286  double top = rect.getTop();
287  double bottom = rect.getBottom();
288  double left = rect.getLeft();
289  double right= rect.getRight();
290 
291  unsigned char *bitmap = I.bitmap;
292  unsigned int width = I.getWidth();
293  vpImagePoint ip;
294 
295  for (unsigned int i = (unsigned int)top; i < (unsigned int)bottom; i++)
296  {
297  for (unsigned int j = (unsigned int)left; j < (unsigned int)right; j++)
298  {
299  double x=0,y=0;
300  ip.set_ij(i,j);
302  ip.set_ij(y,x);
303  unsigned char Ipixelplan = 0;
304  if(getPixel(Isrc,ip,Ipixelplan))
305  {
306  *(bitmap+i*width+j)=Ipixelplan;
307  nb_point_dessine++;
308  }
309  }
310  }
311  }
312 }
313 
323 void
325  const vpCameraParameters &cam, vpMatrix &zBuffer)
326 {
327  if (I.getWidth() != (unsigned int)zBuffer.getCols() || I.getHeight() != (unsigned int)zBuffer.getRows())
328  throw (vpMatrixException(vpMatrixException::incorrectMatrixSizeError, " zBuffer must have the same size as the image I ! "));
329 
330  int nb_point_dessine = 0;
331  if (cleanPrevImage)
332  {
333  unsigned char col = (unsigned char)(0.2126 * bgColor.R + 0.7152 * bgColor.G + 0.0722 * bgColor.B);
334  for (unsigned int i = 0; i < I.getHeight(); i++)
335  {
336  for (unsigned int j = 0; j < I.getWidth(); j++)
337  {
338  I[i][j] = col;
339  }
340  }
341  }
342  if(visible)
343  {
344  getRoi(I.getWidth(),I.getHeight(),cam,pt,rect);
345 
346  double top = rect.getTop();
347  double bottom = rect.getBottom();
348  double left = rect.getLeft();
349  double right= rect.getRight();
350 
351  unsigned char *bitmap = I.bitmap;
352  unsigned int width = I.getWidth();
353  vpImagePoint ip;
354 
355  for (unsigned int i = (unsigned int)top; i < (unsigned int)bottom; i++)
356  {
357  for (unsigned int j = (unsigned int)left; j < (unsigned int)right; j++)
358  {
359  double x=0,y=0;
360  ip.set_ij(i,j);
362  ip.set_ij(y,x);
363  if (colorI == GRAY_SCALED)
364  {
365  unsigned char Ipixelplan;
366  if(getPixel(ip,Ipixelplan))
367  {
368  if (Xinter_optim[2] < zBuffer[i][j] || zBuffer[i][j] < 0)
369  {
370  *(bitmap+i*width+j)=Ipixelplan;
371  nb_point_dessine++;
372  zBuffer[i][j] = Xinter_optim[2];
373  }
374  }
375  }
376  else if (colorI == COLORED)
377  {
378  vpRGBa Ipixelplan;
379  if(getPixel(ip,Ipixelplan))
380  {
381  if (Xinter_optim[2] < zBuffer[i][j] || zBuffer[i][j] < 0)
382  {
383  unsigned char pixelgrey = (unsigned char)(0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B);
384  *(bitmap+i*width+j)=pixelgrey;
385  nb_point_dessine++;
386  zBuffer[i][j] = Xinter_optim[2];
387  }
388  }
389  }
390  }
391  }
392  }
393 }
394 
401 void
403 {
404  int nb_point_dessine = 0;
405  if (cleanPrevImage)
406  {
407  for (unsigned int i = 0; i < I.getHeight(); i++)
408  {
409  for (unsigned int j = 0; j < I.getWidth(); j++)
410  {
411  I[i][j] = bgColor;
412  }
413  }
414  }
415 
416  if(visible)
417  {
418  getRoi(I.getWidth(),I.getHeight(),cam,pt,rect);
419 
420  double top = rect.getTop();
421  double bottom = rect.getBottom();
422  double left = rect.getLeft();
423  double right= rect.getRight();
424 
425  vpRGBa *bitmap = I.bitmap;
426  unsigned int width = I.getWidth();
427  vpImagePoint ip;
428 
429  for (unsigned int i = (unsigned int)top; i < (unsigned int)bottom; i++)
430  {
431  for (unsigned int j = (unsigned int)left; j < (unsigned int)right; j++)
432  {
433  double x=0,y=0;
434  ip.set_ij(i,j);
436  ip.set_ij(y,x);
437  if (colorI == GRAY_SCALED)
438  {
439  unsigned char Ipixelplan;
440  if(getPixel(ip,Ipixelplan))
441  {
442  vpRGBa pixelcolor;
443  pixelcolor.R = Ipixelplan;
444  pixelcolor.G = Ipixelplan;
445  pixelcolor.B = Ipixelplan;
446  *(bitmap+i*width+j) = pixelcolor;
447  nb_point_dessine++;
448  }
449  }
450  else if (colorI == COLORED)
451  {
452  vpRGBa Ipixelplan;
453  if(getPixel(ip,Ipixelplan))
454  {
455  *(bitmap+i*width+j) = Ipixelplan;
456  nb_point_dessine++;
457  }
458  }
459  }
460  }
461  }
462 }
463 
464 
472 void
474  const vpCameraParameters &cam)
475 {
476  int nb_point_dessine = 0;
477  if (cleanPrevImage)
478  {
479  for (unsigned int i = 0; i < I.getHeight(); i++)
480  {
481  for (unsigned int j = 0; j < I.getWidth(); j++)
482  {
483  I[i][j] = bgColor;
484  }
485  }
486  }
487 
488  if(visible)
489  {
490  getRoi(I.getWidth(),I.getHeight(),cam,pt,rect);
491 
492  double top = rect.getTop();
493  double bottom = rect.getBottom();
494  double left = rect.getLeft();
495  double right= rect.getRight();
496 
497  vpRGBa *bitmap = I.bitmap;
498  unsigned int width = I.getWidth();
499  vpImagePoint ip;
500 
501  for (unsigned int i = (unsigned int)top; i < (unsigned int)bottom; i++)
502  {
503  for (unsigned int j = (unsigned int)left; j < (unsigned int)right; j++)
504  {
505  double x=0,y=0;
506  ip.set_ij(i,j);
508  ip.set_ij(y,x);
509  vpRGBa Ipixelplan;
510  if(getPixel(Isrc,ip,Ipixelplan))
511  {
512  *(bitmap+i*width+j) = Ipixelplan;
513  nb_point_dessine++;
514  }
515  }
516  }
517  }
518 }
519 
529 void
531  vpMatrix &zBuffer)
532 {
533  if (I.getWidth() != (unsigned int)zBuffer.getCols() || I.getHeight() != (unsigned int)zBuffer.getRows())
534  throw (vpMatrixException(vpMatrixException::incorrectMatrixSizeError, " zBuffer must have the same size as the image I ! "));
535 
536  int nb_point_dessine = 0;
537  if (cleanPrevImage)
538  {
539  for (unsigned int i = 0; i < I.getHeight(); i++)
540  {
541  for (unsigned int j = 0; j < I.getWidth(); j++)
542  {
543  I[i][j] = bgColor;
544  }
545  }
546  }
547  if(visible)
548  {
549  getRoi(I.getWidth(),I.getHeight(),cam,pt,rect);
550 
551  double top = rect.getTop();
552  double bottom = rect.getBottom();
553  double left = rect.getLeft();
554  double right= rect.getRight();
555 
556  vpRGBa *bitmap = I.bitmap;
557  unsigned int width = I.getWidth();
558  vpImagePoint ip;
559 
560  for (unsigned int i = (unsigned int)top; i < (unsigned int)bottom; i++)
561  {
562  for (unsigned int j = (unsigned int)left; j < (unsigned int)right; j++)
563  {
564  double x=0,y=0;
565  ip.set_ij(i,j);
567  ip.set_ij(y,x);
568  if (colorI == GRAY_SCALED)
569  {
570  unsigned char Ipixelplan;
571  if(getPixel(ip,Ipixelplan))
572  {
573  if (Xinter_optim[2] < zBuffer[i][j] || zBuffer[i][j] < 0)
574  {
575  vpRGBa pixelcolor;
576  pixelcolor.R = Ipixelplan;
577  pixelcolor.G = Ipixelplan;
578  pixelcolor.B = Ipixelplan;
579  *(bitmap+i*width+j) = pixelcolor;
580  nb_point_dessine++;
581  zBuffer[i][j] = Xinter_optim[2];
582  }
583  }
584  }
585  else if (colorI == COLORED)
586  {
587  vpRGBa Ipixelplan;
588  if(getPixel(ip,Ipixelplan))
589  {
590  if (Xinter_optim[2] < zBuffer[i][j] || zBuffer[i][j] < 0)
591  {
592  *(bitmap+i*width+j) = Ipixelplan;
593  nb_point_dessine++;
594  zBuffer[i][j] = Xinter_optim[2];
595  }
596  }
597  }
598  }
599  }
600  }
601 }
602 
603 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
604 
710 void
713  const vpCameraParameters &cam)
714 {
715 
716  unsigned int width = I.getWidth();
717  unsigned int height = I.getHeight();
718 
719  unsigned int nbsimList = list.nbElements();
720 
721  if (nbsimList < 1)
722  return;
723 
724  vpImageSimulator** simList = new vpImageSimulator* [nbsimList];
725 
726  double topFinal = height+1;;
727  double bottomFinal = -1;
728  double leftFinal = width+1;
729  double rightFinal = -1;
730 
731  list.front();
732 
733  unsigned int unvisible = 0;
734  for (unsigned int i = 0; i < nbsimList; i++)
735  {
736  vpImageSimulator* sim = &(list.value());
737  list.next();
738  if (sim->visible)
739  simList[i] = sim;
740  else
741  unvisible++;
742  }
743  nbsimList = nbsimList - unvisible;
744 
745  if (nbsimList < 1)
746  {
747  delete[] simList;
748  return;
749  }
750 
751 
752  for (unsigned int i = 0; i < nbsimList; i++)
753  {
754 
755  simList[i]->getRoi(width,height,cam,simList[i]->pt,simList[i]->rect);
756 
757  if (topFinal > simList[i]->rect.getTop()) topFinal = simList[i]->rect.getTop();
758  if (bottomFinal < simList[i]->rect.getBottom()) bottomFinal = simList[i]->rect.getBottom();
759  if (leftFinal > simList[i]->rect.getLeft()) leftFinal = simList[i]->rect.getLeft();
760  if (rightFinal < simList[i]->rect.getRight()) rightFinal = simList[i]->rect.getRight();
761  }
762 
763  double zmin = -1;
764  int indice = -1;
765  unsigned char *bitmap = I.bitmap;
766  vpImagePoint ip;
767 
768  for (unsigned int i = (unsigned int)topFinal; i < (unsigned int)bottomFinal; i++)
769  {
770  for (unsigned int j = (unsigned int)leftFinal; j < (unsigned int)rightFinal; j++)
771  {
772  zmin = -1;
773  double x=0,y=0;
774  ip.set_ij(i,j);
776  ip.set_ij(y,x);
777  for (int k = 0; k < (int)nbsimList; k++)
778  {
779  double z = 0;
780  if(simList[k]->getPixelDepth(ip,z))
781  {
782  if (z < zmin || zmin < 0)
783  {
784  zmin = z;
785  indice = k;
786  }
787  }
788  }
789  if (indice >= 0)
790  {
791  if (simList[indice]->colorI == GRAY_SCALED)
792  {
793  unsigned char Ipixelplan = 255;
794  simList[indice]->getPixel(ip,Ipixelplan);
795  *(bitmap+i*width+j)=Ipixelplan;
796  }
797  else if (simList[indice]->colorI == COLORED)
798  {
799  vpRGBa Ipixelplan(255,255,255);
800  simList[indice]->getPixel(ip,Ipixelplan);
801  unsigned char pixelgrey = (unsigned char)(0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B);
802  *(bitmap+i*width+j)=pixelgrey;
803  }
804  }
805  }
806  }
807 
808  delete[] simList;
809 }
810 
811 
917 void
919  const vpCameraParameters &cam)
920 {
921 
922  unsigned int width = I.getWidth();
923  unsigned int height = I.getHeight();
924 
925  unsigned int nbsimList = list.nbElements();
926 
927  if (nbsimList < 1)
928  return;
929 
930  vpImageSimulator** simList = new vpImageSimulator* [nbsimList];
931 
932  double topFinal = height+1;;
933  double bottomFinal = -1;
934  double leftFinal = width+1;
935  double rightFinal = -1;
936 
937  list.front();
938 
939  unsigned int unvisible = 0;
940  for (unsigned int i = 0; i < nbsimList; i++)
941  {
942  vpImageSimulator* sim = &(list.value());
943  list.next();
944  if (sim->visible)
945  simList[i] = sim;
946  else
947  unvisible++;
948  }
949  nbsimList = nbsimList - unvisible;
950 
951  if (nbsimList < 1)
952  {
953  delete[] simList;
954  return;
955  }
956 
957  for (unsigned int i = 0; i < nbsimList; i++)
958  {
959 
960  simList[i]->getRoi(width,height,cam,simList[i]->pt,simList[i]->rect);
961 
962  if (topFinal > simList[i]->rect.getTop()) topFinal = simList[i]->rect.getTop();
963  if (bottomFinal < simList[i]->rect.getBottom()) bottomFinal = simList[i]->rect.getBottom();
964  if (leftFinal > simList[i]->rect.getLeft()) leftFinal = simList[i]->rect.getLeft();
965  if (rightFinal < simList[i]->rect.getRight()) rightFinal = simList[i]->rect.getRight();
966  }
967 
968  double zmin = -1;
969  int indice = -1;
970  vpRGBa *bitmap = I.bitmap;
971  vpImagePoint ip;
972 
973  for (unsigned int i = (unsigned int)topFinal; i < (unsigned int)bottomFinal; i++)
974  {
975  for (unsigned int j = (unsigned int)leftFinal; j < (unsigned int)rightFinal; j++)
976  {
977  zmin = -1;
978  double x=0,y=0;
979  ip.set_ij(i,j);
981  ip.set_ij(y,x);
982  for (int k = 0; k < (int)nbsimList; k++)
983  {
984  double z = 0;
985  if(simList[k]->getPixelDepth(ip,z))
986  {
987  if (z < zmin || zmin < 0)
988  {
989  zmin = z;
990  indice = k;
991  }
992  }
993  }
994  if (indice >= 0)
995  {
996  if (simList[indice]->colorI == GRAY_SCALED)
997  {
998  unsigned char Ipixelplan = 255;
999  simList[indice]->getPixel(ip,Ipixelplan);
1000  vpRGBa pixelcolor;
1001  pixelcolor.R = Ipixelplan;
1002  pixelcolor.G = Ipixelplan;
1003  pixelcolor.B = Ipixelplan;
1004  *(bitmap+i*width+j) = pixelcolor;
1005  }
1006  else if (simList[indice]->colorI == COLORED)
1007  {
1008  vpRGBa Ipixelplan(255,255,255);
1009  simList[indice]->getPixel(ip,Ipixelplan);
1010  //unsigned char pixelgrey = 0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B;
1011  *(bitmap+i*width+j)=Ipixelplan;
1012  }
1013  }
1014  }
1015  }
1016 
1017  delete[] simList;
1018 }
1019 #endif
1020 
1121 void
1123  std::list<vpImageSimulator> &list,
1124  const vpCameraParameters &cam)
1125 {
1126 
1127  unsigned int width = I.getWidth();
1128  unsigned int height = I.getHeight();
1129 
1130  unsigned int nbsimList = (unsigned int)list.size();
1131 
1132  if (nbsimList < 1)
1133  return;
1134 
1135  vpImageSimulator** simList = new vpImageSimulator* [nbsimList];
1136 
1137  double topFinal = height+1;;
1138  double bottomFinal = -1;
1139  double leftFinal = width+1;
1140  double rightFinal = -1;
1141 
1142  unsigned int unvisible = 0;
1143  unsigned int indexSimu=0;
1144  for(std::list<vpImageSimulator>::iterator it=list.begin(); it!=list.end(); ++it, ++indexSimu){
1145  vpImageSimulator* sim = &(*it);
1146  if (sim->visible)
1147  simList[indexSimu] = sim;
1148  else
1149  unvisible++;
1150  }
1151  nbsimList = nbsimList - unvisible;
1152 
1153  if (nbsimList < 1)
1154  {
1155  delete[] simList;
1156  return;
1157  }
1158 
1159 
1160  for (unsigned int i = 0; i < nbsimList; i++)
1161  {
1162 
1163  simList[i]->getRoi(width,height,cam,simList[i]->pt,simList[i]->rect);
1164 
1165  if (topFinal > simList[i]->rect.getTop()) topFinal = simList[i]->rect.getTop();
1166  if (bottomFinal < simList[i]->rect.getBottom()) bottomFinal = simList[i]->rect.getBottom();
1167  if (leftFinal > simList[i]->rect.getLeft()) leftFinal = simList[i]->rect.getLeft();
1168  if (rightFinal < simList[i]->rect.getRight()) rightFinal = simList[i]->rect.getRight();
1169  }
1170 
1171  double zmin = -1;
1172  int indice = -1;
1173  unsigned char *bitmap = I.bitmap;
1174  vpImagePoint ip;
1175 
1176  for (unsigned int i = (unsigned int)topFinal; i < (unsigned int)bottomFinal; i++)
1177  {
1178  for (unsigned int j = (unsigned int)leftFinal; j < (unsigned int)rightFinal; j++)
1179  {
1180  zmin = -1;
1181  double x=0,y=0;
1182  ip.set_ij(i,j);
1184  ip.set_ij(y,x);
1185  for (int k = 0; k < (int)nbsimList; k++)
1186  {
1187  double z = 0;
1188  if(simList[k]->getPixelDepth(ip,z))
1189  {
1190  if (z < zmin || zmin < 0)
1191  {
1192  zmin = z;
1193  indice = k;
1194  }
1195  }
1196  }
1197  if (indice >= 0)
1198  {
1199  if (simList[indice]->colorI == GRAY_SCALED)
1200  {
1201  unsigned char Ipixelplan = 255;
1202  simList[indice]->getPixel(ip,Ipixelplan);
1203  *(bitmap+i*width+j)=Ipixelplan;
1204  }
1205  else if (simList[indice]->colorI == COLORED)
1206  {
1207  vpRGBa Ipixelplan(255,255,255);
1208  simList[indice]->getPixel(ip,Ipixelplan);
1209  unsigned char pixelgrey = (unsigned char)(0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B);
1210  *(bitmap+i*width+j)=pixelgrey;
1211  }
1212  }
1213  }
1214  }
1215 
1216  delete[] simList;
1217 }
1218 
1219 
1321 void
1323  std::list<vpImageSimulator> &list,
1324  const vpCameraParameters &cam)
1325 {
1326 
1327  unsigned int width = I.getWidth();
1328  unsigned int height = I.getHeight();
1329 
1330  unsigned int nbsimList = (unsigned int)list.size();
1331 
1332  if (nbsimList < 1)
1333  return;
1334 
1335  vpImageSimulator** simList = new vpImageSimulator* [nbsimList];
1336 
1337  double topFinal = height+1;;
1338  double bottomFinal = -1;
1339  double leftFinal = width+1;
1340  double rightFinal = -1;
1341 
1342  unsigned int unvisible = 0;
1343  unsigned int indexSimu = 0;
1344  for(std::list<vpImageSimulator>::iterator it=list.begin(); it!=list.end(); ++it, ++indexSimu){
1345  vpImageSimulator* sim = &(*it);
1346  if (sim->visible)
1347  simList[indexSimu] = sim;
1348  else
1349  unvisible++;
1350  }
1351 
1352  nbsimList = nbsimList - unvisible;
1353 
1354  if (nbsimList < 1)
1355  {
1356  delete[] simList;
1357  return;
1358  }
1359 
1360  for (unsigned int i = 0; i < nbsimList; i++)
1361  {
1362 
1363  simList[i]->getRoi(width,height,cam,simList[i]->pt,simList[i]->rect);
1364 
1365  if (topFinal > simList[i]->rect.getTop()) topFinal = simList[i]->rect.getTop();
1366  if (bottomFinal < simList[i]->rect.getBottom()) bottomFinal = simList[i]->rect.getBottom();
1367  if (leftFinal > simList[i]->rect.getLeft()) leftFinal = simList[i]->rect.getLeft();
1368  if (rightFinal < simList[i]->rect.getRight()) rightFinal = simList[i]->rect.getRight();
1369  }
1370 
1371  double zmin = -1;
1372  int indice = -1;
1373  vpRGBa *bitmap = I.bitmap;
1374  vpImagePoint ip;
1375 
1376  for (unsigned int i = (unsigned int)topFinal; i < (unsigned int)bottomFinal; i++)
1377  {
1378  for (unsigned int j = (unsigned int)leftFinal; j < (unsigned int)rightFinal; j++)
1379  {
1380  zmin = -1;
1381  double x=0,y=0;
1382  ip.set_ij(i,j);
1384  ip.set_ij(y,x);
1385  for (int k = 0; k < (int)nbsimList; k++)
1386  {
1387  double z = 0;
1388  if(simList[k]->getPixelDepth(ip,z))
1389  {
1390  if (z < zmin || zmin < 0)
1391  {
1392  zmin = z;
1393  indice = k;
1394  }
1395  }
1396  }
1397  if (indice >= 0)
1398  {
1399  if (simList[indice]->colorI == GRAY_SCALED)
1400  {
1401  unsigned char Ipixelplan = 255;
1402  simList[indice]->getPixel(ip,Ipixelplan);
1403  vpRGBa pixelcolor;
1404  pixelcolor.R = Ipixelplan;
1405  pixelcolor.G = Ipixelplan;
1406  pixelcolor.B = Ipixelplan;
1407  *(bitmap+i*width+j) = pixelcolor;
1408  }
1409  else if (simList[indice]->colorI == COLORED)
1410  {
1411  vpRGBa Ipixelplan(255,255,255);
1412  simList[indice]->getPixel(ip,Ipixelplan);
1413  //unsigned char pixelgrey = 0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B;
1414  *(bitmap+i*width+j)=Ipixelplan;
1415  }
1416  }
1417  }
1418  }
1419 
1420  delete[] simList;
1421 }
1422 
1428 void
1430 {
1431  cMt = _cMt;
1432  vpRotationMatrix R;
1433  cMt.extract(R);
1434 
1435  normal_Cam = R * normal_obj;
1436 
1437  visible_result = vpColVector::dotProd(normal_Cam,focal);
1438 
1439  for(int i = 0; i < 4; i++)
1440  pt[i].track(cMt);
1441 
1442  vpColVector e1(3) ;
1443  vpColVector e2(3) ;
1444  vpColVector facenormal(3) ;
1445 
1446  e1[0] = pt[1].get_X() - pt[0].get_X() ;
1447  e1[1] = pt[1].get_Y() - pt[0].get_Y() ;
1448  e1[2] = pt[1].get_Z() - pt[0].get_Z() ;
1449 
1450  e2[0] = pt[2].get_X() - pt[1].get_X() ;
1451  e2[1] = pt[2].get_Y() - pt[1].get_Y() ;
1452  e2[2] = pt[2].get_Z() - pt[1].get_Z() ;
1453 
1454  facenormal = vpColVector::crossProd(e1,e2) ;
1455 
1456  double angle = pt[0].get_X()*facenormal[0] + pt[0].get_Y()*facenormal[1] + pt[0].get_Z()*facenormal[2] ;
1457 
1458  if (angle > 0)
1459  visible=true;
1460  else
1461  visible=false;
1462 
1463  if(visible)
1464  {
1465  for(int i = 0; i < 4; i++)
1466  {
1467  project(X[i],cMt,X2[i]);
1468  pt[i].track(cMt);
1469  }
1470 
1471  vbase_u = X2[1]-X2[0];
1472  vbase_v = X2[3]-X2[0];
1473 
1474  distance = vpColVector::dotProd(normal_Cam,X2[1]);
1475 
1476  if(distance < 0)
1477  {
1478  visible = false;
1479  return;
1480  }
1481 
1482  for(unsigned int i = 0; i < 3; i++)
1483  {
1484  normal_Cam_optim[i] = normal_Cam[i];
1485  X0_2_optim[i] = X2[0][i];
1486  vbase_u_optim[i] = vbase_u[i];
1487  vbase_v_optim[i] = vbase_v[i];
1488  }
1489 
1490  vpImagePoint iPa[4];
1491  for(unsigned int i = 0; i < 4; i++)
1492  {
1493  iPa[i].set_j(X2[i][0]/X2[i][2]);
1494  iPa[i].set_i(X2[i][1]/X2[i][2]);
1495  }
1496 
1497  T1.buildFrom(iPa[0],iPa[1],iPa[3]);
1498  T2.buildFrom(iPa[2],iPa[1],iPa[3]);
1499  }
1500 }
1501 
1502 void
1503 vpImageSimulator::initPlan(vpColVector* _X)
1504 {
1505  for (unsigned int i = 0; i < 4; i++)
1506  {
1507  X[i]=_X[i];
1508  pt[i].setWorldCoordinates(_X[i][0],_X[i][1],_X[i][2]);
1509  }
1510 
1511  normal_obj=vpColVector::crossProd(X[1]-X[0],X[3]-X[0]);
1512  normal_obj=normal_obj/normal_obj.euclideanNorm();
1513 
1514  euclideanNorm_u=(X[1]-X[0]).euclideanNorm();
1515  euclideanNorm_v=(X[3]-X[0]).euclideanNorm();
1516 }
1517 
1531 void
1533 {
1534  Ig = I;
1536  initPlan(_X);
1537 }
1538 
1552 void
1554 {
1555  Ic = I;
1557  initPlan(_X);
1558 }
1559 
1573 void
1574 vpImageSimulator::init(const char* file_image,vpColVector* _X)
1575 {
1576  vpImageIo::read(Ig,file_image);
1577  vpImageIo::read(Ic,file_image);
1578  initPlan(_X);
1579 }
1580 
1595 void
1596 vpImageSimulator::init(const vpImage<unsigned char> &I, const std::vector<vpPoint>& _X)
1597 {
1598  if(_X.size() != 4){
1599  throw vpException(vpException::dimensionError, "the vector must contains 4 points to initialise the simulator");
1600  }
1601  vpColVector Xvec[4];
1602  for(unsigned int i=0; i<4; ++i){
1603  Xvec[i].resize(3);
1604  Xvec[i][0] = _X[i].get_oX();
1605  Xvec[i][1] = _X[i].get_oY();
1606  Xvec[i][2] = _X[i].get_oZ();
1607  }
1608 
1609  Ig = I;
1611  initPlan(Xvec);
1612 }
1627 void
1628 vpImageSimulator::init(const vpImage<vpRGBa> &I, const std::vector<vpPoint>& _X)
1629 {
1630  if(_X.size() != 4){
1631  throw vpException(vpException::dimensionError, "the vector must contains 4 points to initialise the simulator");
1632  }
1633  vpColVector Xvec[4];
1634  for(unsigned int i=0; i<4; ++i){
1635  Xvec[i].resize(3);
1636  Xvec[i][0] = _X[i].get_oX();
1637  Xvec[i][1] = _X[i].get_oY();
1638  Xvec[i][2] = _X[i].get_oZ();
1639  }
1640 
1641  Ic = I;
1643  initPlan(Xvec);
1644 }
1659 void
1660 vpImageSimulator::init(const char* file_image, const std::vector<vpPoint>& _X)
1661 {
1662  if(_X.size() != 4){
1663  throw vpException(vpException::dimensionError, "the vector must contains 4 points to initialise the simulator");
1664  }
1665  vpColVector Xvec[4];
1666  for(unsigned int i=0; i<4; ++i){
1667  Xvec[i].resize(3);
1668  Xvec[i][0] = _X[i].get_oX();
1669  Xvec[i][1] = _X[i].get_oY();
1670  Xvec[i][2] = _X[i].get_oZ();
1671  }
1672 
1673  vpImageIo::read(Ig,file_image);
1674  vpImageIo::read(Ic,file_image);
1675  initPlan(Xvec);
1676 }
1677 
1678 bool
1679 vpImageSimulator::getPixel(const vpImagePoint &iP, unsigned char &Ipixelplan)
1680 {
1681  //test si pixel dans zone projetee
1682  if(!T1.inTriangle(iP) && !T2.inTriangle(iP))
1683  return false;
1684 
1685  //methoed algebrique
1686  double z;
1687 
1688  //calcul de la profondeur de l'intersection
1689  z = distance/(normal_Cam_optim[0]*iP.get_u()+normal_Cam_optim[1]*iP.get_v()+normal_Cam_optim[2]);
1690  //calcul coordonnees 3D intersection
1691  Xinter_optim[0]=iP.get_u()*z;
1692  Xinter_optim[1]=iP.get_v()*z;
1693  Xinter_optim[2]=z;
1694 
1695  //recuperation des coordonnes de l'intersection dans le plan objet
1696  //repere plan object :
1697  // centre = X0_2_optim[i] (premier point definissant le plan)
1698  // base = u:(X[1]-X[0]) et v:(X[3]-X[0])
1699  //ici j'ai considere que le plan est un rectangle => coordonnees sont simplement obtenu par un produit scalaire
1700  double u = 0, v = 0;
1701  double diff = 0;
1702  for(unsigned int i = 0; i < 3; i++)
1703  {
1704  diff = (Xinter_optim[i]-X0_2_optim[i]);
1705  u += diff*vbase_u_optim[i];
1706  v += diff*vbase_v_optim[i];
1707  }
1708  u = u/(euclideanNorm_u*euclideanNorm_u);
1709  v = v/(euclideanNorm_v*euclideanNorm_v);
1710 
1711  if( u > 0 && v > 0 && u < 1. && v < 1.)
1712  {
1713  double i2,j2;
1714  i2=v*(Ig.getHeight()-1);
1715  j2=u*(Ig.getWidth()-1);
1716  if (interp == BILINEAR_INTERPOLATION)
1717  Ipixelplan = Ig.getValue(i2,j2);
1718  else if (interp == SIMPLE)
1719  Ipixelplan = Ig[(unsigned int)i2][(unsigned int)j2];
1720  return true;
1721  }
1722  else
1723  return false;
1724 }
1725 
1726 bool
1727 vpImageSimulator::getPixel(vpImage<unsigned char> &Isrc,
1728  const vpImagePoint &iP, unsigned char &Ipixelplan)
1729 {
1730  //test si pixel dans zone projetee
1731  if(!T1.inTriangle(iP) && !T2.inTriangle(iP))
1732  return false;
1733 
1734  //methoed algebrique
1735  double z;
1736 
1737  //calcul de la profondeur de l'intersection
1738  z = distance/(normal_Cam_optim[0]*iP.get_u()+normal_Cam_optim[1]*iP.get_v()+normal_Cam_optim[2]);
1739  //calcul coordonnees 3D intersection
1740  Xinter_optim[0]=iP.get_u()*z;
1741  Xinter_optim[1]=iP.get_v()*z;
1742  Xinter_optim[2]=z;
1743 
1744  //recuperation des coordonnes de l'intersection dans le plan objet
1745  //repere plan object :
1746  // centre = X0_2_optim[i] (premier point definissant le plan)
1747  // base = u:(X[1]-X[0]) et v:(X[3]-X[0])
1748  //ici j'ai considere que le plan est un rectangle => coordonnees sont simplement obtenu par un produit scalaire
1749  double u = 0, v = 0;
1750  double diff = 0;
1751  for(unsigned int i = 0; i < 3; i++)
1752  {
1753  diff = (Xinter_optim[i]-X0_2_optim[i]);
1754  u += diff*vbase_u_optim[i];
1755  v += diff*vbase_v_optim[i];
1756  }
1757  u = u/(euclideanNorm_u*euclideanNorm_u);
1758  v = v/(euclideanNorm_v*euclideanNorm_v);
1759 
1760  if( u > 0 && v > 0 && u < 1. && v < 1.)
1761  {
1762  double i2,j2;
1763  i2=v*(Isrc.getHeight()-1);
1764  j2=u*(Isrc.getWidth()-1);
1765  if (interp == BILINEAR_INTERPOLATION)
1766  Ipixelplan = Isrc.getValue(i2,j2);
1767  else if (interp == SIMPLE)
1768  Ipixelplan = Isrc[(unsigned int)i2][(unsigned int)j2];
1769  return true;
1770  }
1771  else
1772  return false;
1773 }
1774 
1775 
1776 bool
1777 vpImageSimulator::getPixel(const vpImagePoint &iP, vpRGBa &Ipixelplan)
1778 {
1779  //test si pixel dans zone projetee
1780  if(!T1.inTriangle(iP) && !T2.inTriangle(iP))
1781  return false;
1782 
1783  //methoed algebrique
1784  double z;
1785 
1786  //calcul de la profondeur de l'intersection
1787  z = distance/(normal_Cam_optim[0]*iP.get_u()+normal_Cam_optim[1]*iP.get_v()+normal_Cam_optim[2]);
1788  //calcul coordonnees 3D intersection
1789  Xinter_optim[0]=iP.get_u()*z;
1790  Xinter_optim[1]=iP.get_v()*z;
1791  Xinter_optim[2]=z;
1792 
1793  //recuperation des coordonnes de l'intersection dans le plan objet
1794  //repere plan object :
1795  // centre = X0_2_optim[i] (premier point definissant le plan)
1796  // base = u:(X[1]-X[0]) et v:(X[3]-X[0])
1797  //ici j'ai considere que le plan est un rectangle => coordonnees sont simplement obtenu par un produit scalaire
1798  double u = 0, v = 0;
1799  double diff = 0;
1800  for(unsigned int i = 0; i < 3; i++)
1801  {
1802  diff = (Xinter_optim[i]-X0_2_optim[i]);
1803  u += diff*vbase_u_optim[i];
1804  v += diff*vbase_v_optim[i];
1805  }
1806  u = u/(euclideanNorm_u*euclideanNorm_u);
1807  v = v/(euclideanNorm_v*euclideanNorm_v);
1808 
1809  if( u > 0 && v > 0 && u < 1. && v < 1.)
1810  {
1811  double i2,j2;
1812  i2=v*(Ic.getHeight()-1);
1813  j2=u*(Ic.getWidth()-1);
1814  if (interp == BILINEAR_INTERPOLATION)
1815  Ipixelplan = Ic.getValue(i2,j2);
1816  else if (interp == SIMPLE)
1817  Ipixelplan = Ic[(unsigned int)i2][(unsigned int)j2];
1818  return true;
1819  }
1820  else
1821  return false;
1822 }
1823 
1824 bool
1825 vpImageSimulator::getPixel(vpImage<vpRGBa> &Isrc, const vpImagePoint &iP,
1826  vpRGBa &Ipixelplan)
1827 {
1828  //test si pixel dans zone projetee
1829  if(!T1.inTriangle(iP) && !T2.inTriangle(iP))
1830  return false;
1831 
1832  //methoed algebrique
1833  double z;
1834 
1835  //calcul de la profondeur de l'intersection
1836  z = distance/(normal_Cam_optim[0]*iP.get_u()+normal_Cam_optim[1]*iP.get_v()+normal_Cam_optim[2]);
1837  //calcul coordonnees 3D intersection
1838  Xinter_optim[0]=iP.get_u()*z;
1839  Xinter_optim[1]=iP.get_v()*z;
1840  Xinter_optim[2]=z;
1841 
1842  //recuperation des coordonnes de l'intersection dans le plan objet
1843  //repere plan object :
1844  // centre = X0_2_optim[i] (premier point definissant le plan)
1845  // base = u:(X[1]-X[0]) et v:(X[3]-X[0])
1846  //ici j'ai considere que le plan est un rectangle => coordonnees sont simplement obtenu par un produit scalaire
1847  double u = 0, v = 0;
1848  double diff = 0;
1849  for(unsigned int i = 0; i < 3; i++)
1850  {
1851  diff = (Xinter_optim[i]-X0_2_optim[i]);
1852  u += diff*vbase_u_optim[i];
1853  v += diff*vbase_v_optim[i];
1854  }
1855  u = u/(euclideanNorm_u*euclideanNorm_u);
1856  v = v/(euclideanNorm_v*euclideanNorm_v);
1857 
1858  if( u > 0 && v > 0 && u < 1. && v < 1.)
1859  {
1860  double i2,j2;
1861  i2=v*(Isrc.getHeight()-1);
1862  j2=u*(Isrc.getWidth()-1);
1863  if (interp == BILINEAR_INTERPOLATION)
1864  Ipixelplan = Isrc.getValue(i2,j2);
1865  else if (interp == SIMPLE)
1866  Ipixelplan = Isrc[(unsigned int)i2][(unsigned int)j2];
1867  return true;
1868  }
1869  else
1870  return false;
1871 }
1872 
1873 bool
1874 vpImageSimulator::getPixelDepth(const vpImagePoint &iP, double &Zpixelplan)
1875 {
1876  //test si pixel dans zone projetee
1877  if(!T1.inTriangle(iP) && !T2.inTriangle(iP))
1878  return false;
1879 
1880  Zpixelplan = distance/(normal_Cam_optim[0]*iP.get_u()+normal_Cam_optim[1]*iP.get_v()+normal_Cam_optim[2]);
1881  return true;
1882 }
1883 
1884 bool
1885 vpImageSimulator::getPixelVisibility(const vpImagePoint &iP,
1886  double &Visipixelplan)
1887 {
1888  //test si pixel dans zone projetee
1889  if(!T1.inTriangle(iP) && !T2.inTriangle(iP))
1890  return false;
1891 
1892  Visipixelplan = visible_result;
1893  return true;
1894 }
1895 
1896 void
1897 vpImageSimulator::project(const vpColVector &_vin,
1898  const vpHomogeneousMatrix &_cMt, vpColVector &_vout)
1899 {
1900  vpColVector XH(4);
1901  getHomogCoord(_vin,XH);
1902  getCoordFromHomog(_cMt*XH,_vout);
1903 }
1904 
1905 void
1906 vpImageSimulator::getHomogCoord(const vpColVector &_v, vpColVector &_vH)
1907 {
1908  for(unsigned int i=0;i<3;i++)
1909  _vH[i]=_v[i];
1910  _vH[3]=1.;
1911 }
1912 
1913 void
1914 vpImageSimulator::getCoordFromHomog(const vpColVector &_vH, vpColVector &_v)
1915 {
1916  for(unsigned int i=0;i<3;i++)
1917  _v[i]=_vH[i]/_vH[3];
1918 }
1919 
1920 
1921 void
1922 vpImageSimulator::getRoi(const unsigned int &Iwidth,
1923  const unsigned int &Iheight,
1924  const vpCameraParameters &cam,
1925  vpPoint* point, vpRect &rectangle)
1926 {
1927  double top = Iheight+1;
1928  double bottom = -1;
1929  double right = -1;
1930  double left= Iwidth+1;
1931  for( int i = 0; i < 4; i++)
1932  {
1933  double u=0,v=0;
1934  vpMeterPixelConversion::convertPoint(cam,point[i].get_x(),point[i].get_y(),u,v);
1935  if (v < top) top = v;
1936  if (v > bottom) bottom = v;
1937  if (u < left) left = u;
1938  if (u > right) right = u;
1939  }
1940  if (top < 0) top = 0;
1941  if(top >= Iheight) top = Iheight-1;
1942  if (bottom < 0) bottom = 0;
1943  if(bottom >= Iheight) bottom = Iheight-1;
1944  if(left < 0) left = 0;
1945  if(left >= Iwidth) left = Iwidth-1;
1946  if(right < 0) right = 0;
1947  if(right >= Iwidth) right = Iwidth-1;
1948 
1949  rectangle.setTop(top);
1950  rectangle.setBottom(bottom);
1951  rectangle.setLeft(left);
1952  rectangle.setRight(right);
1953 }
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:159
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:120
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
error that can be emited by ViSP classes.
Definition: vpException.h:75
Type getValue(double i, double j) const
Definition: vpImage.h:1039
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:120
vpImageSimulator(const vpColorPlan &col=COLORED)
double get_Z() const
Get the point Z coordinate in the camera frame.
Definition: vpPoint.h:122
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:2816
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:150
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:277
unsigned int getRows() const
Return the number of rows of the matrix.
Definition: vpMatrix.h:157
static const vpColor white
Definition: vpColor.h:162
double get_X() const
Get the point X coordinate in the camera frame.
Definition: vpPoint.h:118
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