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