26 #ifndef __BIAS_ProjectionParametersSphericalFast_hh__
27 #define __BIAS_ProjectionParametersSphericalFast_hh__
28 #include "bias_config.h"
30 #include <Base/Common/BIASpragmaStart.hh>
31 #include <Geometry/ProjectionParametersBase.hh>
32 #include <Geometry/ProjectionParametersPerspective.hh>
33 #include <MathAlgo/Interpolator.hh>
34 #include <Base/ImageUtils/BresenhamCircle.hh>
35 #include <MathAlgo/PolynomialSolve.hh>
50 const unsigned int height = 0)
55 coeffsDist_.resize(5, 0.0);
57 coeffsUndist_.resize(5, 0.0);
58 coeffsUndist_[0] = 1.0;
63 const double maxAngle,
64 const unsigned int width,
65 const unsigned int height)
68 maxCamAngle_=maxAngle;
70 coeffsDist_.resize(5, 0.0);
72 coeffsUndist_.resize(5, 0.0);
73 coeffsUndist_[0] = 1.0;
124 bool IgnoreDistortion =
false)
const;
134 bool IgnoreDistortion =
false)
const {
152 bool IgnoreDistortion =
false)
const;
159 const double& depth = 1.0,
160 bool IgnoreDistortion =
false)
const;
200 void SetMaxCamAngle(
const double maxCamAngle);
208 void RecalculateUndistortion(
const double maxCamAngle);
216 int SetUndistortion(
const std::vector<double>& undistAngles,
217 const std::vector<double>& distAngles,
218 const double radius);
231 int InitPolyCoeffs(
const double maxCamAngle,
232 const std::vector<double>& coefficients,
233 const bool undistCoeffs =
true);
242 virtual void Rescale(
double ratio,
const double offset = 0.0) {
247 virtual void Rescale(
unsigned int width,
unsigned int height){
248 unsigned int oldwidth = width_;
250 radius_ /= ((double)oldwidth/(
double)width_);
271 virtual BIAS::KMatrix GetFakeKMatrix(
double& imgsize,
int resolution=0,
272 const double& maxangle = 1.4)
const;
277 const double& maxangle = 1.4)
const {
292 const double perspHalfViewingAngleDEG,
303 bool IgnoreDistortion =
false)
const;
314 int EstimateUndistortionPolynomial(std::vector<double>& coefficients,
315 const unsigned int degree = 5);
325 int EstimateDistortionPolynomial(std::vector<double>& coefficients,
326 const unsigned int degree = 5);
334 std::vector<double> &coeffsundist)
const {
335 coeffsdist = coeffsDist_;
336 coeffsundist = coeffsUndist_;
339 void TestPolynomialInversion();
342 #ifdef BIAS_HAVE_XML2
344 virtual int XMLGetClassName(std::string& TopLevelTag,
345 double& Version)
const;
348 virtual int XMLOut(
const xmlNodePtr Node,
XMLIO& XMLObject)
const;
351 virtual int XMLIn(
const xmlNodePtr Node,
XMLIO& XMLObject);
354 friend std::ostream&
operator<<(std::ostream &os,
358 const std::vector<double>& coeff)
const {
361 register int n = (int)coeff.size() - 1;
367 result = (result + coeff[n])*x*x;
370 result = (result + coeff[0])*x;
375 int FitPolynomial(std::vector<double>& coefficients,
376 std::vector<double>& a,
377 std::vector<double>& b,
378 unsigned int degree);
390 void TransfCoordImage2Sphere_ (
const HomgPoint2D& Source,
391 double &theta,
double &phi)
const;
399 void TransfCoordSphere2Image_ (
double theta,
double phi,
408 void EnforceNormalRange_(
double& theta,
double& phi)
const;
431 void ProjectOutsidePositions_(
int& posX,
int& posY);
440 os<<
"ProjectionParametersSphericalFast:"<<std::endl;
442 os<<
"Radius: "<<p.
radius_<<std::endl;
444 os<<
"Coefficients:"<<std::endl;
445 for (
unsigned int i=0; i<p.
coeffsDist_.size(); i++) {
446 os<<
"distortion coeff " << i <<
" " << p.
coeffsDist_[i] <<std::endl;
449 os<<
"undistortion coeff " << i <<
" " << p.
coeffsUndist_[i] <<std::endl;
458 #include <Base/Common/BIASpragmaEnd.hh>
virtual BIAS::KMatrix GetFakeKMatrix(double &imgsize, int resolution=0, const double &maxangle=1.4) const
Returns a fake KMatrix for the camera.
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
Scans a circle using Bresenham's integer arithmetic algorithm.
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
virtual void Rescale(double ratio, const double offset=0.0)
Adapt internal parameters to resampled image.
Wrapper class for reading and writing XML files based on the XML library libxml2. ...
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
std::ostream & operator<<(std::ostream &os, const Array2D< T > &arg)
Can be used to run along the image border.
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
double principalX_
principal point in pixel coordinates (one for all zoom settings)
Camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
virtual ProjectionParametersBase & operator=(const ProjectionParametersBase &p)