void vpImageSimulator::getRoi(const unsigned int Iwidth, const unsigned int Iheight, const vpCameraParameters cam, vpPoint* point, vpRect &rectangle) { double top = Iheight+1; double bottom = -1; double right = -1; double left= Iwidth+1; for( int i = 0; i < 4; i++) { double u=0,v=0; vpMeterPixelConversion::convertPoint(cam,point[i].get_x(),point[i].get_y(),u,v); if (v < top) top = v; if (v > bottom) bottom = v; if (u < left) left = u; if (u > right) right = u; } if (top < 0) top = 0; if(top >= Iheight) top = Iheight-1; if (bottom < 0) bottom = 0; if(bottom >= Iheight) bottom = Iheight-1; if(left < 0) left = 0; if(left >= Iwidth) left = Iwidth-1; if(right < 0) right = 0; if(right >= Iwidth) right = Iwidth-1; rectangle.setTop(top); rectangle.setBottom(bottom); rectangle.setLeft(left); rectangle.setRight(right); }