35 #include <Geometry/ProjectionParametersPerspective.hh>
36 #include <Base/Image/Image.hh>
37 #include <Base/Image/ImageIO.hh>
43 int main(
int argc,
char *argv[])
66 double CamConst = 20.30377;
67 double SensorSizeX = 23.6;
68 double SensorSizeY = 15.8;
70 unsigned int ImgWidth = 3872;
71 unsigned int ImgHeight = 2592;
73 double principalX = (double) ImgWidth*0.5 * (1-0.06444/SensorSizeX);
74 double principalY = (double) ImgHeight*0.5 * (1-0.15281/SensorSizeY);
75 double focalX = (double)ImgWidth*0.5*(CamConst/SensorSizeX );
76 double aspectrat = (1-1.38247e-004)*(
double)ImgWidth/(double)ImgHeight;
81 double kc1 = -2.87698e-004;
82 double kc2 = 6.73824e-007 ;
83 double kc3 = 1.97915e-005;
84 double kc4 = -2.11616e-005;
94 string fname =
"ProjParPersExample01.xml";
99 cerr <<
"error writing "<< fname << endl;
102 cout <<
"XMLWrite wrote "<< fname << endl;
113 cerr <<
"error reading "<< fname << endl;
116 cout <<
"XMLWrite read "<< fname << endl;
122 cout<<
"the file contained brown distortion parameters - as expected. everything went fine."<<endl;
124 cout<<
"parameters are: kc1="<<kc1<<
" "<<
128 "r0="<<r0<<
" "<<endl;
131 cerr<<
"unexpected parameter type. check io functions!"<<endl;
135 cout<<
"did not XMLWrite because BIAS_HAVE_XML2 not available."<<endl;
151 for(
unsigned x = 0; x<ImgWidth; x++)
152 for(
unsigned y = 0; y<ImgHeight; y++)
160 float disx = (float) point2d[0] - (
float) x;
162 float disy = (float) point2d[1] - (
float) y;
164 float magn = sqrt((disx*disx)+(disy*disy));
170 cerr<<
" can't save displacement image." << endl;
175 cerr<<
" can't save displacement image." << endl;
180 cerr<<
" can't save displacement image." << endl;
184 cout<<
" displacement images saved." << endl;
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
int XMLRead(const std::string &Filename)
derived classes must implement the function XMLIn which is called by this function XMLRead to read ev...
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
void GetUndistortionBrown(double &kc1, double &kc2, double &kc3, double &kc4, double &r0) const
Get the lens undistortion parameters including the parameter describing root of the polynomial...
virtual void SetPrincipal(const double x, const double y)
Set principal point in pixels relative to top left corner, virtual overload to recalculate K_...
void SetIdealImageSize(unsigned int width, unsigned int height)
void ** GetImageDataArray() const
Get an array of pointers to image data.
int XMLWrite(const std::string &Filename, int CompressionLevel=0, bool AutoAddCompressionSuffix=true, std::string encoding="UTF-8") const
call this to add the class to a new xml tree and write it to the file Filename.
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
virtual bool Undistort(BIAS::HomgPoint2D &point2d) const
Using the Matlab camera calibration toolbox parameters for an undistortion of distorted coordinates...
void SetUndistortionBrown(double kc1, double kc2, double kc3, double kc4, double r0)
Set the lens undistortion parameters including the root of the polynomial.
void Init(unsigned int width, unsigned int height, unsigned int nChannels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
Initialize image size and channels.
BIAS_ProjParaPersp_DISTORTION_TYPE
void SetFocalLengthAndAspect(double f, double AspectRatio)
Set the current camera focal length in pixel and the a spect ratio.
This is the base class for images in BIAS.
BIAS_ProjParaPersp_DISTORTION_TYPE GetDistortionType() const
Get type of distortion parameters.