small example demonstrating the ProjectionParametersPerspective by calculating the lens distortion after brown (?)
#include <Geometry/ProjectionParametersPerspective.hh>
#include <Base/Image/Image.hh>
#include <Base/Image/ImageIO.hh>
using namespace BIAS;
using namespace std;
int main(int argc, char *argv[])
{
double CamConst = 20.30377;
double SensorSizeX = 23.6;
double SensorSizeY = 15.8;
unsigned int ImgWidth = 3872;
unsigned int ImgHeight = 2592;
double principalX = (double) ImgWidth*0.5 * (1-0.06444/SensorSizeX);
double principalY = (double) ImgHeight*0.5 * (1-0.15281/SensorSizeY);
double focalX = (double)ImgWidth*0.5*(CamConst/SensorSizeX );
double aspectrat = (1-1.38247e-004)*(double)ImgWidth/(double)ImgHeight;
double kc1 = -2.87698e-004;
double kc2 = 6.73824e-007 ;
double kc3 = 1.97915e-005;
double kc4 = -2.11616e-005;
double r0 = .85;
#ifdef BIAS_HAVE_XML2
string fname = "ProjParPersExample01.xml";
if (res!=0)
{
cerr << "error writing "<< fname << endl;
return -3;
}
cout << "XMLWrite wrote "<< fname << endl;
kc1 = 0;
kc2 = 0;
kc3 = 0;
kc4 = 0;
r0 = 0;
if (res!=0)
{
cerr << "error reading "<< fname << endl;
return -3;
}
cout << "XMLWrite read "<< fname << endl;
switch(distype)
{
cout<<"the file contained brown distortion parameters - as expected. everything went fine."<<endl;
cout<<"parameters are: kc1="<<kc1<<" "<<
"kc2="<<kc2<<" "<<
"kc3="<<kc3<<" "<<
"kc4="<<kc4<<" "<<
"r0="<<r0<<" "<<endl;
break;
default:
cerr<<"unexpected parameter type. check io functions!"<<endl;
}
#else
cout<<"did not XMLWrite because BIAS_HAVE_XML2 not available."<<endl;
#endif
for(unsigned x = 0; x<ImgWidth; x++)
for(unsigned y = 0; y<ImgHeight; y++)
{
float disx = (float) point2d[0] - (float) x;
float disy = (float) point2d[1] - (float) y;
float magn = sqrt((disx*disx)+(disy*disy));
}
{
cerr<<" can't save displacement image." << endl;
return -3;
}
{
cerr<<" can't save displacement image." << endl;
return -3;
}
{
cerr<<" can't save displacement image." << endl;
return -3;
}
cout<< " displacement images saved." << endl;
return 0;
}