25 #include <Image/RectificationBase.hh>
26 #include <Image/PlanarRectification.hh>
27 #include <Geometry/ProjectionParametersPerspective.hh>
32 #define SUPERPARENT RectificationBase<InputStorageType, OutputStorageType>
33 #define PARENT RectificationViaProjectionMappingBase<InputStorageType, OutputStorageType>
36 template <
class InputStorageType,
class OutputStorageType>
40 rectOrientationGiven_(false),
41 fixedIntrinsicsGiven_(false)
44 template <
class InputStorageType,
class OutputStorageType>
49 template <
class InputStorageType,
class OutputStorageType>
64 template <
class InputStorageType,
class OutputStorageType>
68 rectOrientation_ = orientation;
69 rectOrientationGiven_ =
true;
70 PARENT::rectificationParamsAreValid_ =
false;
73 template <
class InputStorageType,
class OutputStorageType>
77 fixedIntrinsicsA_ = fixedIntrinsicsB_ = ppp;
78 fixedIntrinsicsGiven_ =
true;
79 PARENT::rectificationParamsAreValid_ =
false;
82 template <
class InputStorageType,
class OutputStorageType>
87 fixedIntrinsicsA_ = pppA;
88 fixedIntrinsicsB_ = pppB;
89 fixedIntrinsicsGiven_ =
true;
90 PARENT::rectificationParamsAreValid_ =
false;
93 template <
class InputStorageType,
class OutputStorageType>
98 Pose rectPoseA, rectPoseB;
101 if (!SUPERPARENT::ppBA_->DoIntrinsicsDiffer(SUPERPARENT::ppBB_)) {
102 if (SUPERPARENT::ppBA_->GetQ().Dist(SUPERPARENT::ppBB_->GetQ()) == 0.0f) {
103 BIASWARN(
"The camera parameters look like the image pair is already "
104 "rectified! Parameters are cloned.");
105 PARENT::rectPPA_ = SUPERPARENT::ppBA_->Clone();
106 PARENT::rectPPB_ = SUPERPARENT::ppBB_->Clone();
111 if(!rectOrientationGiven_) {
112 BIASASSERT((SUPERPARENT::ppBA_)!=NULL);
113 BIASASSERT((SUPERPARENT::ppBB_)!=NULL);
114 if (SUPERPARENT::CalculateRectifiedBases(SUPERPARENT::ppBA_->GetPose(),
115 SUPERPARENT::ppBB_->GetPose(),
116 rectPoseA, rectPoseB,
true) != 0) {
117 BIASERR(
"Failed to compute rectified base! Is epipole in any image?");
123 rectPoseA.
Set(rectOrientation_,cA);
124 rectPoseB.
Set(rectOrientation_, cB);
127 delete PARENT::rectPPA_;
128 delete PARENT::rectPPB_;
134 BIASASSERT(ppPA_ != NULL);
137 BIASASSERT(ppPB_ != NULL);
145 if(!fixedIntrinsicsGiven_) {
185 anglesA[2], anglesA[3], anglesA[4]);
197 anglesB[2], anglesB[3], anglesB[4]);
209 double minPhi = (anglesA[0]<anglesB[0]) ? anglesB[0] : anglesA[0];
210 double maxPhi = (anglesA[1]>anglesB[1]) ? anglesB[1] : anglesA[1];
212 double minTheta = anglesB[3];
214 double maxTheta = anglesA[4];
216 double minAngleStep = (stepSizeA<stepSizeB) ? stepSizeA : stepSizeB;
218 double aspectratio = 1.0;
220 if(retainAspectRatio_) {
226 if(aspectratio<1.0) {
227 minAngleStep *= aspectratio;
261 minAngleStep, aspectratio);
263 minAngleStep, aspectratio);
266 (*rectPPPA_) = fixedIntrinsicsA_;
267 (*rectPPPB_) = fixedIntrinsicsB_;
278 template <
class InputStorageType,
class OutputStorageType>
282 retainAspectRatio_ = retain;
292 #if defined(BUILD_IMAGE_CHAR)
297 #if defined(BUILD_IMAGE_USHORT)
301 #if defined(BUILD_IMAGE_SHORT)
305 #if defined(BUILD_IMAGE_SHORT)&&defined(BUILD_IMAGE_USHORT)
309 #if defined(BUILD_IMAGE_INT)
313 #if defined(BUILD_IMAGE_USHORT)
317 #if defined(BUILD_IMAGE_USHORT) && defined(BUILD_IMAGE_INT)
321 #if defined(BUILD_IMAGE_DOUBLE)
void RetainOriginalApectRatio(bool retain=true)
If this is set to true, the rectification will use the mean of the input pixel aspect ratios for the ...
int SetIntrinsics(double minPhi, double maxPhi, double minTheta, double maxTheta, double angleStep, double aspectratio=1.0)
Method calculates K-Matrix and image size from specified angles.
virtual int DetermineRectificationParameters_()
current implementation is suboptimal, a beter way for the choise of internal parameters must be found...
Base class for rectification implementations that make use of projections to represent rectified stat...
int Set(const PoseParametrization &pose)
Set pose from pose parametrization.
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
virtual int GetSphericalViewingRange(const CoordinateTransform3D &sphericalReferenceFrame, double &minPhi, double &maxPhi, double ¢erPhi, double &minTheta, double &maxTheta)
Determines the maximal and minimal viewing range in means of spherical coordinates.
virtual int GetMinimalAngularSamplingStep(double &minAngleStep)
Delivers the assumed minimal angular distance between two optical rays belonging to integer image coo...
virtual void SetPose(const BIAS::Pose pose)
Set pose from pose object.
Represents 3d pose transformations, parametrized as Euclidean translation and unit quaternion orienta...
virtual double GetAspectratio() const
Return aspectratio (i.e.
void FixateIntrinsics(const ProjectionParametersPerspective &ppp)
Rectification via perspective cameras, removes distortions.
void FixateRectOrientation(const Quaternion< double > &rectOrientation)
Camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
virtual bool IsInputCameraValid(const BIAS::Image< InputStorageType > &img, const BIAS::ProjectionParametersBase *proj)
Only works with perspective cameras.