Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FitPanorama.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
26 #include "FitPanorama.h"
27 
28 #include <algorithm>
29 #include <panodata/PanoramaData.h>
32 
33 namespace HuginBase {
34 
35 void CalculateFitPanorama::fitPano(PanoramaData& panorama, double& HFOV, double& height)
36 {
37  // FIXME: doesn't work properly for fisheye and mirror projections,
38  // it will not calculate a vfov bigger than 180.
40 
41  // use estimated fov to calculate a suitable panorama height.
42  // calculate VFOV based on current panorama
43  PTools::Transform transf;
44  SrcPanoImage src;
45  src.setProjection(SrcPanoImage::EQUIRECTANGULAR);
46  src.setHFOV(360);
47  src.setSize(vigra::Size2D(360,180));
48 
49  // output pano with new hfov
50  PanoramaOptions opts = panorama.getOptions();
51  opts.setHFOV(fov.x, false);
52  transf.createInvTransform(src, opts);
53 
54  // limit fov to suitable range for this projection
55  fov.x = std::min(fov.x, panorama.getOptions().getMaxHFOV());
56  fov.y = std::min(fov.y, panorama.getOptions().getMaxVFOV());
57 
58  hugin_utils::FDiff2D pmiddle;
59  // special case for projections with max VFOV > 180 (fisheye, stereographic)
60  if (panorama.getOptions().getMaxVFOV() > 180 && fov.x > 180) {
61  transf.transform(pmiddle, hugin_utils::FDiff2D(180, 180 - fov.x / 2 + 0.01));
62  } else {
63  transf.transform(pmiddle, hugin_utils::FDiff2D(0, fov.y / 2));
64  }
65 
66  height = fabs(2*pmiddle.y);
67  HFOV = fov.x;
68 }
69 
70 
72 {
74  {
75 
77 
80 
81  o_panorama.setOptions(opts);
82 
83  return true; // let's hope so.
84 
85  }
86 
87  return false;
88 }
89 
90 } //namespace
void setHeight(unsigned int h)
set panorama height
int roundi(T x)
Definition: hugin_math.h:73
static hugin_utils::FDiff2D calcFOV(const PanoramaData &panorama)
double getMaxHFOV() const
get maximum possible hfov with current projection
virtual bool runAlgorithm()
implementation of the algorithm.
Definition: FitPanorama.h:56
static void fitPano(PanoramaData &panorama, double &HFOV, double &height)
Definition: FitPanorama.cpp:35
bool transform(double &x_dest, double &y_dest, double x_src, double y_src) const
excecute transform
double HFOV
void createInvTransform(const vigra::Diff2D &srcSize, VariableMap srcVars, Lens::LensProjectionFormat srcProj, const vigra::Diff2D &destSize, PanoramaOptions::ProjectionFormat destProj, const std::vector< double > &destProjParam, double destHFOV, const vigra::Diff2D &origSrcSize)
create image-&gt;pano transformation
virtual void setOptions(const PanoramaOptions &opt)=0
set new output settings This is not used directly for optimizing/stiching, but it can be feed into ru...
double getMaxVFOV() const
get maximum possible vfov with current projection
virtual double getResultHeight()
Definition: FitPanorama.h:75
virtual const PanoramaOptions & getOptions() const =0
returns the options for this panorama
Model for a panorama.
Definition: PanoramaData.h:81
void setHFOV(double h, bool keepView=true)
set the horizontal field of view.
virtual double getResultHorizontalFOV()
Definition: FitPanorama.h:68
virtual bool runAlgorithm()
implementation of the algorithm.
Definition: FitPanorama.cpp:71
Holds transformations for Image -&gt; Pano and the other way.
void setSize(vigra::Size2D val)
Set the image size in pixels.
All variables of a source image.
Definition: SrcPanoImage.h:194
Panorama image options.
static T min(T x, T y)
Definition: svm.cpp:62