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 #include <visp/vpMbtPolygon.h>
63 : cMt(), pt(), ptClipped(), interp(SIMPLE), normal_obj(), normal_Cam(), normal_Cam_optim(),
64 distance(1.), visible_result(1.), visible(false), X0_2_optim(NULL),
65 euclideanNorm_u(0.), euclideanNorm_v(0.), vbase_u(), vbase_v(),
66 vbase_u_optim(NULL), vbase_v_optim(NULL), Xinter_optim(NULL), listTriangle(),
67 colorI(col), Ig(), Ic(), rect(), cleanPrevImage(false),
68 setBackgroundTexture(false), bgColor(
vpColor::white), focal(), needClipping(false)
89 normal_Cam_optim =
new double[3];
90 X0_2_optim =
new double[3];
91 vbase_u_optim =
new double[3];
92 vbase_v_optim =
new double[3];
93 Xinter_optim =
new double[3];
103 : cMt(), pt(), ptClipped(), interp(SIMPLE), normal_obj(), normal_Cam(), normal_Cam_optim(),
104 distance(1.), visible_result(1.), visible(false), X0_2_optim(NULL),
105 euclideanNorm_u(0.), euclideanNorm_v(0.), vbase_u(), vbase_v(),
106 vbase_u_optim(NULL), vbase_v_optim(NULL), Xinter_optim(NULL), listTriangle(),
107 colorI(GRAY_SCALED), Ig(), Ic(), rect(), cleanPrevImage(false),
108 setBackgroundTexture(false), bgColor(
vpColor::white), focal(), needClipping(false)
111 for(
unsigned int i=0;i<4;i++)
127 normal_obj = text.normal_obj;
128 euclideanNorm_u = text.euclideanNorm_u;
129 euclideanNorm_v = text.euclideanNorm_v;
136 normal_Cam_optim =
new double[3];
137 X0_2_optim =
new double[3];
138 vbase_u_optim =
new double[3];
139 vbase_v_optim =
new double[3];
140 Xinter_optim =
new double[3];
142 colorI = text.colorI;
143 interp = text.interp;
144 bgColor = text.bgColor;
145 cleanPrevImage = text.cleanPrevImage;
146 setBackgroundTexture =
false;
156 delete[] normal_Cam_optim;
158 delete[] vbase_u_optim;
159 delete[] vbase_v_optim;
160 delete[] Xinter_optim;
167 for(
unsigned int i=0;i<4;i++)
176 bgColor = sim.bgColor;
177 cleanPrevImage = sim.cleanPrevImage;
181 normal_obj = sim.normal_obj;
182 euclideanNorm_u = sim.euclideanNorm_u;
183 euclideanNorm_v = sim.euclideanNorm_v;
202 int nb_point_dessine = 0;
203 if (setBackgroundTexture)
210 unsigned char col = (
unsigned char) (0.2126 * bgColor.
R
211 + 0.7152 * bgColor.
G + 0.0722 * bgColor.
B);
212 for (
unsigned int i = 0; i < I.
getHeight(); i++)
214 for (
unsigned int j = 0; j < I.
getWidth(); j++)
229 double top = rect.
getTop();
234 unsigned char *bitmap = I.
bitmap;
238 for (
unsigned int i = (
unsigned int)top; i < (
unsigned int)bottom; i++)
240 for (
unsigned int j = (
unsigned int)left; j < (
unsigned int)right; j++)
248 unsigned char Ipixelplan = 0;
249 if(getPixel(ip,Ipixelplan))
251 *(bitmap+i*width+j)=Ipixelplan;
258 if(getPixel(ip,Ipixelplan))
260 unsigned char pixelgrey = (
unsigned char)(0.2126 * Ipixelplan.
R + 0.7152 * Ipixelplan.
G + 0.0722 * Ipixelplan.
B);
261 *(bitmap+i*width+j)=pixelgrey;
283 int nb_point_dessine = 0;
286 unsigned char col = (
unsigned char)(0.2126 * bgColor.
R + 0.7152 * bgColor.
G + 0.0722 * bgColor.
B);
287 for (
unsigned int i = 0; i < I.
getHeight(); i++)
289 for (
unsigned int j = 0; j < I.
getWidth(); j++)
302 double top = rect.
getTop();
307 unsigned char *bitmap = I.
bitmap;
311 for (
unsigned int i = (
unsigned int)top; i < (
unsigned int)bottom; i++)
313 for (
unsigned int j = (
unsigned int)left; j < (
unsigned int)right; j++)
319 unsigned char Ipixelplan = 0;
320 if(getPixel(Isrc,ip,Ipixelplan))
322 *(bitmap+i*width+j)=Ipixelplan;
346 int nb_point_dessine = 0;
349 unsigned char col = (
unsigned char)(0.2126 * bgColor.
R + 0.7152 * bgColor.
G + 0.0722 * bgColor.
B);
350 for (
unsigned int i = 0; i < I.
getHeight(); i++)
352 for (
unsigned int j = 0; j < I.
getWidth(); j++)
365 double top = rect.
getTop();
370 unsigned char *bitmap = I.
bitmap;
374 for (
unsigned int i = (
unsigned int)top; i < (
unsigned int)bottom; i++)
376 for (
unsigned int j = (
unsigned int)left; j < (
unsigned int)right; j++)
384 unsigned char Ipixelplan;
385 if(getPixel(ip,Ipixelplan))
387 if (Xinter_optim[2] < zBuffer[i][j] || zBuffer[i][j] < 0)
389 *(bitmap+i*width+j)=Ipixelplan;
391 zBuffer[i][j] = Xinter_optim[2];
398 if(getPixel(ip,Ipixelplan))
400 if (Xinter_optim[2] < zBuffer[i][j] || zBuffer[i][j] < 0)
402 unsigned char pixelgrey = (
unsigned char)(0.2126 * Ipixelplan.
R + 0.7152 * Ipixelplan.
G + 0.0722 * Ipixelplan.
B);
403 *(bitmap+i*width+j)=pixelgrey;
405 zBuffer[i][j] = Xinter_optim[2];
423 int nb_point_dessine = 0;
426 for (
unsigned int i = 0; i < I.
getHeight(); i++)
428 for (
unsigned int j = 0; j < I.
getWidth(); j++)
442 double top = rect.
getTop();
451 for (
unsigned int i = (
unsigned int)top; i < (
unsigned int)bottom; i++)
453 for (
unsigned int j = (
unsigned int)left; j < (
unsigned int)right; j++)
461 unsigned char Ipixelplan;
462 if(getPixel(ip,Ipixelplan))
465 pixelcolor.
R = Ipixelplan;
466 pixelcolor.
G = Ipixelplan;
467 pixelcolor.
B = Ipixelplan;
468 *(bitmap+i*width+j) = pixelcolor;
475 if(getPixel(ip,Ipixelplan))
477 *(bitmap+i*width+j) = Ipixelplan;
498 int nb_point_dessine = 0;
501 for (
unsigned int i = 0; i < I.
getHeight(); i++)
503 for (
unsigned int j = 0; j < I.
getWidth(); j++)
517 double top = rect.
getTop();
526 for (
unsigned int i = (
unsigned int)top; i < (
unsigned int)bottom; i++)
528 for (
unsigned int j = (
unsigned int)left; j < (
unsigned int)right; j++)
535 if(getPixel(Isrc,ip,Ipixelplan))
537 *(bitmap+i*width+j) = Ipixelplan;
561 int nb_point_dessine = 0;
564 for (
unsigned int i = 0; i < I.
getHeight(); i++)
566 for (
unsigned int j = 0; j < I.
getWidth(); j++)
579 double top = rect.
getTop();
588 for (
unsigned int i = (
unsigned int)top; i < (
unsigned int)bottom; i++)
590 for (
unsigned int j = (
unsigned int)left; j < (
unsigned int)right; j++)
598 unsigned char Ipixelplan;
599 if(getPixel(ip,Ipixelplan))
601 if (Xinter_optim[2] < zBuffer[i][j] || zBuffer[i][j] < 0)
604 pixelcolor.
R = Ipixelplan;
605 pixelcolor.
G = Ipixelplan;
606 pixelcolor.
B = Ipixelplan;
607 *(bitmap+i*width+j) = pixelcolor;
609 zBuffer[i][j] = Xinter_optim[2];
616 if(getPixel(ip,Ipixelplan))
618 if (Xinter_optim[2] < zBuffer[i][j] || zBuffer[i][j] < 0)
620 *(bitmap+i*width+j) = Ipixelplan;
622 zBuffer[i][j] = Xinter_optim[2];
631 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
754 double topFinal = height+1;;
755 double bottomFinal = -1;
756 double leftFinal = width+1;
757 double rightFinal = -1;
761 unsigned int unvisible = 0;
762 for (
unsigned int i = 0; i < nbsimList; i++)
771 nbsimList = nbsimList - unvisible;
780 for (
unsigned int i = 0; i < nbsimList; i++)
782 if(!simList[i]->needClipping)
783 simList[i]->getRoi(width,height,cam,simList[i]->pt,simList[i]->rect);
785 simList[i]->getRoi(width,height,cam,simList[i]->ptClipped,simList[i]->rect);
787 if (topFinal > simList[i]->rect.
getTop()) topFinal = simList[i]->rect.
getTop();
788 if (bottomFinal < simList[i]->rect.
getBottom()) bottomFinal = simList[i]->rect.
getBottom();
789 if (leftFinal > simList[i]->rect.
getLeft()) leftFinal = simList[i]->rect.
getLeft();
790 if (rightFinal < simList[i]->rect.
getRight()) rightFinal = simList[i]->rect.
getRight();
795 unsigned char *bitmap = I.
bitmap;
798 for (
unsigned int i = (
unsigned int)topFinal; i < (
unsigned int)bottomFinal; i++)
800 for (
unsigned int j = (
unsigned int)leftFinal; j < (
unsigned int)rightFinal; j++)
807 for (
int k = 0; k < (int)nbsimList; k++)
810 if(simList[k]->getPixelDepth(ip,z))
812 if (z < zmin || zmin < 0)
823 unsigned char Ipixelplan = 255;
824 simList[indice]->getPixel(ip,Ipixelplan);
825 *(bitmap+i*width+j)=Ipixelplan;
827 else if (simList[indice]->colorI ==
COLORED)
829 vpRGBa Ipixelplan(255,255,255);
830 simList[indice]->getPixel(ip,Ipixelplan);
831 unsigned char pixelgrey = (
unsigned char)(0.2126 * Ipixelplan.
R + 0.7152 * Ipixelplan.
G + 0.0722 * Ipixelplan.
B);
832 *(bitmap+i*width+j)=pixelgrey;
962 double topFinal = height+1;;
963 double bottomFinal = -1;
964 double leftFinal = width+1;
965 double rightFinal = -1;
969 unsigned int unvisible = 0;
970 for (
unsigned int i = 0; i < nbsimList; i++)
979 nbsimList = nbsimList - unvisible;
987 for (
unsigned int i = 0; i < nbsimList; i++)
989 if(!simList[i]->needClipping)
990 simList[i]->getRoi(width,height,cam,simList[i]->pt,simList[i]->rect);
992 simList[i]->getRoi(width,height,cam,simList[i]->ptClipped,simList[i]->rect);
994 if (topFinal > simList[i]->rect.
getTop()) topFinal = simList[i]->rect.
getTop();
995 if (bottomFinal < simList[i]->rect.
getBottom()) bottomFinal = simList[i]->rect.
getBottom();
996 if (leftFinal > simList[i]->rect.
getLeft()) leftFinal = simList[i]->rect.
getLeft();
997 if (rightFinal < simList[i]->rect.
getRight()) rightFinal = simList[i]->rect.
getRight();
1005 for (
unsigned int i = (
unsigned int)topFinal; i < (
unsigned int)bottomFinal; i++)
1007 for (
unsigned int j = (
unsigned int)leftFinal; j < (
unsigned int)rightFinal; j++)
1014 for (
int k = 0; k < (int)nbsimList; k++)
1017 if(simList[k]->getPixelDepth(ip,z))
1019 if (z < zmin || zmin < 0)
1030 unsigned char Ipixelplan = 255;
1031 simList[indice]->getPixel(ip,Ipixelplan);
1033 pixelcolor.
R = Ipixelplan;
1034 pixelcolor.
G = Ipixelplan;
1035 pixelcolor.
B = Ipixelplan;
1036 *(bitmap+i*width+j) = pixelcolor;
1038 else if (simList[indice]->colorI ==
COLORED)
1040 vpRGBa Ipixelplan(255,255,255);
1041 simList[indice]->getPixel(ip,Ipixelplan);
1043 *(bitmap+i*width+j)=Ipixelplan;
1155 std::list<vpImageSimulator> &list,
1162 unsigned int nbsimList = (
unsigned int)list.size();
1169 double topFinal = height+1;;
1170 double bottomFinal = -1;
1171 double leftFinal = width+1;
1172 double rightFinal = -1;
1174 unsigned int unvisible = 0;
1175 unsigned int indexSimu=0;
1176 for(std::list<vpImageSimulator>::iterator it=list.begin(); it!=list.end(); ++it, ++indexSimu){
1179 simList[indexSimu] = sim;
1183 nbsimList = nbsimList - unvisible;
1192 for (
unsigned int i = 0; i < nbsimList; i++)
1194 if(!simList[i]->needClipping)
1195 simList[i]->getRoi(width,height,cam,simList[i]->pt,simList[i]->rect);
1197 simList[i]->getRoi(width,height,cam,simList[i]->ptClipped,simList[i]->rect);
1199 if (topFinal > simList[i]->rect.
getTop()) topFinal = simList[i]->rect.
getTop();
1200 if (bottomFinal < simList[i]->rect.
getBottom()) bottomFinal = simList[i]->rect.
getBottom();
1201 if (leftFinal > simList[i]->rect.
getLeft()) leftFinal = simList[i]->rect.
getLeft();
1202 if (rightFinal < simList[i]->rect.
getRight()) rightFinal = simList[i]->rect.
getRight();
1207 unsigned char *bitmap = I.
bitmap;
1210 for (
unsigned int i = (
unsigned int)topFinal; i < (
unsigned int)bottomFinal; i++)
1212 for (
unsigned int j = (
unsigned int)leftFinal; j < (
unsigned int)rightFinal; j++)
1219 for (
int k = 0; k < (int)nbsimList; k++)
1222 if(simList[k]->getPixelDepth(ip,z))
1224 if (z < zmin || zmin < 0)
1235 unsigned char Ipixelplan = 255;
1236 simList[indice]->getPixel(ip,Ipixelplan);
1237 *(bitmap+i*width+j)=Ipixelplan;
1239 else if (simList[indice]->colorI ==
COLORED)
1241 vpRGBa Ipixelplan(255,255,255);
1242 simList[indice]->getPixel(ip,Ipixelplan);
1243 unsigned char pixelgrey = (
unsigned char)(0.2126 * Ipixelplan.
R + 0.7152 * Ipixelplan.
G + 0.0722 * Ipixelplan.
B);
1244 *(bitmap+i*width+j)=pixelgrey;
1357 std::list<vpImageSimulator> &list,
1364 unsigned int nbsimList = (
unsigned int)list.size();
1371 double topFinal = height+1;;
1372 double bottomFinal = -1;
1373 double leftFinal = width+1;
1374 double rightFinal = -1;
1376 unsigned int unvisible = 0;
1377 unsigned int indexSimu = 0;
1378 for(std::list<vpImageSimulator>::iterator it=list.begin(); it!=list.end(); ++it, ++indexSimu){
1381 simList[indexSimu] = sim;
1386 nbsimList = nbsimList - unvisible;
1394 for (
unsigned int i = 0; i < nbsimList; i++)
1396 if(!simList[i]->needClipping)
1397 simList[i]->getRoi(width,height,cam,simList[i]->pt,simList[i]->rect);
1399 simList[i]->getRoi(width,height,cam,simList[i]->ptClipped,simList[i]->rect);
1401 if (topFinal > simList[i]->rect.
getTop()) topFinal = simList[i]->rect.
getTop();
1402 if (bottomFinal < simList[i]->rect.
getBottom()) bottomFinal = simList[i]->rect.
getBottom();
1403 if (leftFinal > simList[i]->rect.
getLeft()) leftFinal = simList[i]->rect.
getLeft();
1404 if (rightFinal < simList[i]->rect.
getRight()) rightFinal = simList[i]->rect.
getRight();
1412 for (
unsigned int i = (
unsigned int)topFinal; i < (
unsigned int)bottomFinal; i++)
1414 for (
unsigned int j = (
unsigned int)leftFinal; j < (
unsigned int)rightFinal; j++)
1421 for (
int k = 0; k < (int)nbsimList; k++)
1424 if(simList[k]->getPixelDepth(ip,z))
1426 if (z < zmin || zmin < 0)
1437 unsigned char Ipixelplan = 255;
1438 simList[indice]->getPixel(ip,Ipixelplan);
1440 pixelcolor.
R = Ipixelplan;
1441 pixelcolor.
G = Ipixelplan;
1442 pixelcolor.
B = Ipixelplan;
1443 *(bitmap+i*width+j) = pixelcolor;
1445 else if (simList[indice]->colorI ==
COLORED)
1447 vpRGBa Ipixelplan(255,255,255);
1448 simList[indice]->getPixel(ip,Ipixelplan);
1450 *(bitmap+i*width+j)=Ipixelplan;
1470 needClipping =
false;
1472 normal_Cam = R * normal_obj;
1476 for(
unsigned int i = 0; i < 4; i++)
1483 e1[0] = pt[1].get_X() - pt[0].get_X() ;
1484 e1[1] = pt[1].get_Y() - pt[0].get_Y() ;
1485 e1[2] = pt[1].get_Z() - pt[0].get_Z() ;
1487 e2[0] = pt[2].get_X() - pt[1].get_X() ;
1488 e2[1] = pt[2].get_Y() - pt[1].get_Y() ;
1489 e2[2] = pt[2].get_Z() - pt[1].get_Z() ;
1493 double angle = pt[0].get_X()*facenormal[0] + pt[0].get_Y()*facenormal[1] + pt[0].get_Z()*facenormal[2] ;
1504 for(
unsigned int i = 0; i < 4; i++)
1506 project(X[i],cMt,X2[i]);
1508 if(pt[i].get_Z() < 0)
1509 needClipping =
true;
1512 vbase_u = X2[1]-X2[0];
1513 vbase_v = X2[3]-X2[0];
1524 for(
unsigned int i = 0; i < 3; i++)
1526 normal_Cam_optim[i] = normal_Cam[i];
1527 X0_2_optim[i] = X2[0][i];
1528 vbase_u_optim[i] = vbase_u[i];
1529 vbase_v_optim[i] = vbase_v[i];
1532 std::vector<vpPoint> *ptPtr = &pt;
1538 listTriangle.clear();
1539 for(
unsigned int i = 1 ; i < (*ptPtr).size()-1 ; i++){
1541 ip1.
set_j((*ptPtr)[0].get_x());
1542 ip1.
set_i((*ptPtr)[0].get_y());
1544 ip2.
set_j((*ptPtr)[i].get_x());
1545 ip2.
set_i((*ptPtr)[i].get_y());
1547 ip3.
set_j((*ptPtr)[i+1].get_x());
1548 ip3.
set_i((*ptPtr)[i+1].get_y());
1551 listTriangle.push_back(tri);
1559 for (
unsigned int i = 0; i < 4; i++)
1562 pt[i].setWorldCoordinates(X_[i][0],X_[i][1],X_[i][2]);
1568 euclideanNorm_u=(X[1]-X[0]).euclideanNorm();
1569 euclideanNorm_v=(X[3]-X[0]).euclideanNorm();
1656 for(
unsigned int i=0; i<4; ++i){
1658 Xvec[i][0] = X_[i].get_oX();
1659 Xvec[i][1] = X_[i].get_oY();
1660 Xvec[i][2] = X_[i].get_oZ();
1688 for(
unsigned int i=0; i<4; ++i){
1690 Xvec[i][0] = X_[i].get_oX();
1691 Xvec[i][1] = X_[i].get_oY();
1692 Xvec[i][2] = X_[i].get_oZ();
1720 for(
unsigned int i=0; i<4; ++i){
1722 Xvec[i][0] = X_[i].get_oX();
1723 Xvec[i][1] = X_[i].get_oY();
1724 Xvec[i][2] = X_[i].get_oZ();
1733 vpImageSimulator::getPixel(
const vpImagePoint &iP,
unsigned char &Ipixelplan)
1737 bool inside =
false;
1738 for(
unsigned int i = 0 ; i < listTriangle.size() ; i++)
1739 if(listTriangle[i].inTriangle(iP)){
1743 if(!inside)
return false;
1753 z = distance/(normal_Cam_optim[0]*iP.
get_u()+normal_Cam_optim[1]*iP.
get_v()+normal_Cam_optim[2]);
1755 Xinter_optim[0]=iP.
get_u()*z;
1756 Xinter_optim[1]=iP.
get_v()*z;
1764 double u = 0, v = 0;
1766 for(
unsigned int i = 0; i < 3; i++)
1768 diff = (Xinter_optim[i]-X0_2_optim[i]);
1769 u += diff*vbase_u_optim[i];
1770 v += diff*vbase_v_optim[i];
1772 u = u/(euclideanNorm_u*euclideanNorm_u);
1773 v = v/(euclideanNorm_v*euclideanNorm_v);
1775 if( u > 0 && v > 0 && u < 1. && v < 1.)
1782 else if (interp ==
SIMPLE)
1783 Ipixelplan = Ig[(
unsigned int)i2][(
unsigned int)j2];
1795 bool inside =
false;
1796 for(
unsigned int i = 0 ; i < listTriangle.size() ; i++)
1797 if(listTriangle[i].inTriangle(iP)){
1801 if(!inside)
return false;
1810 z = distance/(normal_Cam_optim[0]*iP.
get_u()+normal_Cam_optim[1]*iP.
get_v()+normal_Cam_optim[2]);
1812 Xinter_optim[0]=iP.
get_u()*z;
1813 Xinter_optim[1]=iP.
get_v()*z;
1821 double u = 0, v = 0;
1823 for(
unsigned int i = 0; i < 3; i++)
1825 diff = (Xinter_optim[i]-X0_2_optim[i]);
1826 u += diff*vbase_u_optim[i];
1827 v += diff*vbase_v_optim[i];
1829 u = u/(euclideanNorm_u*euclideanNorm_u);
1830 v = v/(euclideanNorm_v*euclideanNorm_v);
1832 if( u > 0 && v > 0 && u < 1. && v < 1.)
1839 else if (interp ==
SIMPLE)
1840 Ipixelplan = Isrc[(
unsigned int)i2][(
unsigned int)j2];
1852 bool inside =
false;
1853 for(
unsigned int i = 0 ; i < listTriangle.size() ; i++)
1854 if(listTriangle[i].inTriangle(iP)){
1858 if(!inside)
return false;
1866 z = distance/(normal_Cam_optim[0]*iP.
get_u()+normal_Cam_optim[1]*iP.
get_v()+normal_Cam_optim[2]);
1868 Xinter_optim[0]=iP.
get_u()*z;
1869 Xinter_optim[1]=iP.
get_v()*z;
1877 double u = 0, v = 0;
1879 for(
unsigned int i = 0; i < 3; i++)
1881 diff = (Xinter_optim[i]-X0_2_optim[i]);
1882 u += diff*vbase_u_optim[i];
1883 v += diff*vbase_v_optim[i];
1885 u = u/(euclideanNorm_u*euclideanNorm_u);
1886 v = v/(euclideanNorm_v*euclideanNorm_v);
1888 if( u > 0 && v > 0 && u < 1. && v < 1.)
1895 else if (interp ==
SIMPLE)
1896 Ipixelplan = Ic[(
unsigned int)i2][(
unsigned int)j2];
1910 bool inside =
false;
1911 for(
unsigned int i = 0 ; i < listTriangle.size() ; i++)
1912 if(listTriangle[i].inTriangle(iP)){
1916 if(!inside)
return false;
1922 z = distance/(normal_Cam_optim[0]*iP.
get_u()+normal_Cam_optim[1]*iP.
get_v()+normal_Cam_optim[2]);
1924 Xinter_optim[0]=iP.
get_u()*z;
1925 Xinter_optim[1]=iP.
get_v()*z;
1933 double u = 0, v = 0;
1935 for(
unsigned int i = 0; i < 3; i++)
1937 diff = (Xinter_optim[i]-X0_2_optim[i]);
1938 u += diff*vbase_u_optim[i];
1939 v += diff*vbase_v_optim[i];
1941 u = u/(euclideanNorm_u*euclideanNorm_u);
1942 v = v/(euclideanNorm_v*euclideanNorm_v);
1944 if( u > 0 && v > 0 && u < 1. && v < 1.)
1951 else if (interp ==
SIMPLE)
1952 Ipixelplan = Isrc[(
unsigned int)i2][(
unsigned int)j2];
1960 vpImageSimulator::getPixelDepth(
const vpImagePoint &iP,
double &Zpixelplan)
1963 bool inside =
false;
1964 for(
unsigned int i = 0 ; i < listTriangle.size() ; i++)
1965 if(listTriangle[i].inTriangle(iP)){
1969 if(!inside)
return false;
1973 Zpixelplan = distance/(normal_Cam_optim[0]*iP.
get_u()+normal_Cam_optim[1]*iP.
get_v()+normal_Cam_optim[2]);
1978 vpImageSimulator::getPixelVisibility(
const vpImagePoint &iP,
1979 double &Visipixelplan)
1982 bool inside =
false;
1983 for(
unsigned int i = 0 ; i < listTriangle.size() ; i++)
1984 if(listTriangle[i].inTriangle(iP)){
1988 if(!inside)
return false;
1992 Visipixelplan = visible_result;
1997 vpImageSimulator::project(
const vpColVector &_vin,
2001 getHomogCoord(_vin,XH);
2002 getCoordFromHomog(_cMt*XH,_vout);
2008 for(
unsigned int i=0;i<3;i++)
2016 for(
unsigned int i=0;i<3;i++)
2017 _v[i]=_vH[i]/_vH[3];
2022 vpImageSimulator::getRoi(
const unsigned int &Iwidth,
2023 const unsigned int &Iheight,
2025 const std::vector<vpPoint> &point,
2028 double top = Iheight+1;
2031 double left= Iwidth+1;
2033 for(
unsigned int i = 0; i < point.size(); i++)
2037 if (v < top) top = v;
2038 if (v > bottom) bottom = v;
2039 if (u < left) left = u;
2040 if (u > right) right = u;
2042 if (top < 0) top = 0;
2043 if(top >= Iheight) top = Iheight-1;
2044 if (bottom < 0) bottom = 0;
2045 if(bottom >= Iheight) bottom = Iheight-1;
2046 if(left < 0) left = 0;
2047 if(left >= Iwidth) left = Iwidth-1;
2048 if(right < 0) right = 0;
2049 if(right >= Iwidth) right = Iwidth-1;
2057 std::vector<vpColVector>
2060 std::vector<vpColVector> X_;
2061 for (
int i=0; i<4; i++)
Definition of the vpMatrix class.
unsigned int nbElements(void)
return the number of element in the list
void init(const vpImage< unsigned char > &I, vpColVector *X)
virtual ~vpImageSimulator()
unsigned int getWidth() const
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.
Provide simple list management.
Type * bitmap
points toward the bitmap
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.
static void getClippedPolygon(const std::vector< vpPoint > &ptIn, std::vector< vpPoint > &ptOut, const vpHomogeneousMatrix &cMo, const unsigned int &clippingFlags, const vpCameraParameters &cam=vpCameraParameters(), const double &znear=0.001, const double &zfar=100)
error that can be emited by ViSP classes.
Type getValue(double i, double j) const
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.
Class that defines a RGB 32 bits structure.
void next(void)
position the current element on the next one
The vpRotationMatrix considers the particular case of a rotation matrix.
void set_i(const double ii)
void setCameraPosition(const vpHomogeneousMatrix &cMt)
void front(void)
Position the current element on the first element of the list.
type & value(void)
return the value of the current element
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
vpImageSimulator(const vpColorPlan &col=COLORED)
void set_j(const double jj)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
void setRight(double pos)
std::vector< vpColVector > get3DcornersTextureRectangle()
double euclideanNorm() const
unsigned char R
Red component.
unsigned int getCols() const
Return the number of columns of the matrix.
static double dotProd(const vpColVector &a, const vpColVector &b)
Dot Product.
error that can be emited by the vpMatrix class and its derivates
unsigned int getHeight() const
Defines a rectangle in the plane.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static vpColVector crossProd(const vpColVector &a, const vpColVector &b)
Compute the cross product of two vectors C = a x b.
static void read(vpImage< unsigned char > &I, const char *filename)
unsigned int getRows() const
Return the number of rows of the matrix.
void setBottom(double pos)
void set_ij(const double ii, const double jj)
void resize(const unsigned int i, const bool flagNullify=true)