26 #ifndef __BIAS_ProjectionParametersSpherical_hh__
27 #define __BIAS_ProjectionParametersSpherical_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>
49 const unsigned int height = 0)
54 interpolatorInit_ =
false;
58 const double maxAngle,
59 const unsigned int width,
60 const unsigned int height)
64 MaxCamAngle_=maxAngle;
65 interpolatorInit_ =
false;
119 bool IgnoreDistortion =
false)
const;
129 bool IgnoreDistortion =
false)
const {
147 bool IgnoreDistortion =
false)
const;
154 const double& depth = 1.0,
155 bool IgnoreDistortion =
false)
const;
195 void SetMaxCamAngle(
const double maxCamAngle);
203 void RecalculateUndistortion(
const double maxCamAngle);
211 int SetUndistortion(
const std::vector<double>& undistAngles,
212 const std::vector<double>& distAngles,
213 const double radius);
217 const double acCoeff1,
const double acCoeff2,
218 const double acCoeff3,
const double acCoeff4)
220 std::vector<double> coefficients;
221 coefficients.reserve(5);
222 coefficients.push_back(acCoeff0);
223 coefficients.push_back(acCoeff1);
224 coefficients.push_back(acCoeff2);
225 coefficients.push_back(acCoeff3);
226 coefficients.push_back(acCoeff4);
227 return InitAngleCorrFromPoly(maxCamAngle, coefficients);
242 int InitAngleCorrFromPoly(
const double maxCamAngle,
243 const std::vector<double>& coefficients,
244 const bool mapsRadiusToZ =
true);
253 virtual void Rescale(
double ratio,
const double offset = 0.0) {
258 virtual void Rescale(
unsigned int width,
unsigned int height){
259 unsigned int oldwidth = width_;
261 radius_ /= ((double)oldwidth/(
double)width_);
282 virtual BIAS::KMatrix GetFakeKMatrix(
double& imgsize,
int resolution=0,
283 const double& maxangle = 1.4)
const;
288 const double& maxangle = 1.4)
const {
303 const double perspHalfViewingAngleDEG,
315 bool IgnoreDistortion =
false)
const;
326 int EstimateUndistortionPolynomial(std::vector<double>& coefficients,
327 const unsigned int degree = 4,
328 bool LinearMonomialIsZero =
true);
338 int EstimateDistortionPolynomial(std::vector<double>& coefficients,
339 const unsigned int degree = 4,
340 bool LinearMonomialIsZero =
false);
349 for (
unsigned i = 0; i < acCoeff_.size(); i++)
350 coeffs.push_back(acCoeff_[i]);
362 std::vector<double>& distAngles)
const {
363 interpolatorAngle_.GetKnotPoints(undistAngles);
364 interpolatorAngle_.GetControlPoints(distAngles);
376 std::vector<double>& undistAngles)
const{
377 interpolatorAngleBack_.GetKnotPoints(distAngles);
378 interpolatorAngleBack_.GetControlPoints(undistAngles);
382 #ifdef BIAS_HAVE_XML2
384 virtual int XMLGetClassName(std::string& TopLevelTag,
385 double& Version)
const;
388 virtual int XMLOut(
const xmlNodePtr Node,
XMLIO& XMLObject)
const;
391 virtual int XMLIn(
const xmlNodePtr Node,
XMLIO& XMLObject);
394 friend std::ostream&
operator<<(std::ostream &os,
405 int FitPolynomialWithoutLinearMonomial_(
const unsigned int degree,
406 const std::vector<double>& x,
407 const std::vector<double>& y,
408 std::vector<double> &coefficients);
414 void TransfCoordImage2Sphere_ (
const HomgPoint2D& Source,
415 double &theta,
double &phi)
const;
421 void TransfCoordCalibImage2Sphere_ (
const HomgPoint2D& Source,
422 double &theta,
double &phi)
const;
428 void TransfCoordSphere2Image_ (
double theta,
double phi,
435 int TransfCoordRotateSphere2Image_ (
double theta,
double phi,
444 void TransfCoordSphere2CalibImage_ (
double theta,
double phi,
451 void EnforceNormalRange_(
double& theta,
double& phi)
const;
479 void ProjectOutsidePositions_(
int& posX,
int& posY);
488 os<<
"ProjectionParametersSpherical:"<<std::endl;
490 os<<
"Radius: "<<p.
radius_<<std::endl;
492 os<<
"Coefficients:"<<std::endl;
493 std::vector<double> controlpoints, knotpoints;
496 for (
unsigned int i=0; i<controlpoints.size(); i++) {
497 os<< knotpoints[i]<<
" "<< controlpoints[i]<<std::endl;
505 #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.
void GetKnotPoints(std::vector< double > &kPnt) const
this class interpolates a function y=f(t) between given control points (the y-values) ...
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)
void GetControlPoints(std::vector< double > &cPnt) const
Camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
virtual ProjectionParametersBase & operator=(const ProjectionParametersBase &p)