Hugin trunk 0.1
Loading...
Searching...
No Matches
FitPanorama.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
26#include "FitPanorama.h"
27
28#include <algorithm>
33
34namespace HuginBase {
35
37{
38 // FIXME: doesn't work properly for fisheye and mirror projections,
39 // it will not calculate a vfov bigger than 180.
41
42 // use estimated fov to calculate a suitable panorama height.
43 // calculate VFOV based on current panorama
47 src.setHFOV(360);
48 src.setSize(vigra::Size2D(360,180));
49
50 // output pano with new hfov
51 PanoramaOptions opts = panorama.getOptions();
52 opts.setHFOV(fov.x, false);
53 transf.createInvTransform(src, opts);
54
55 // limit fov to suitable range for this projection
56 fov.x = std::min(fov.x, panorama.getOptions().getMaxHFOV());
57 fov.y = std::min(fov.y, panorama.getOptions().getMaxVFOV());
58
59 // special treatment for rectilinear projection
60 if (panorama.getOptions().getProjection() == HuginBase::PanoramaOptions::RECTILINEAR)
61 {
62 // first calculate the maximal vertical fov for maximal horizontal fov
64 transf.transform(pedge, fov / 2.0);
65 // with this maximal vfov calculate the output roi for each active image
66 // to get the maximal vertical area covered by images
68 tempOpts.setHFOV(fov.x);
69 tempOpts.setHeight(fabs(2 * pedge.y));
70 tempOpts.setROI(vigra::Rect2D(0, 0, tempOpts.getWidth(), tempOpts.getHeight()));
71 vigra::Rect2D roi;
72 for (const auto& i : panorama.getActiveImages())
73 {
75 };
76 height = 2.0 * std::max(tempOpts.getHeight() / 2.0 - roi.top(), roi.bottom() - tempOpts.getHeight() / 2.0);
77 }
78 else
79 {
81 // special case for projections with max VFOV > 180 (fisheye, stereographic)
82 if (panorama.getOptions().getMaxVFOV() > 180 && fov.x > 180)
83 {
84 transf.transform(pmiddle, hugin_utils::FDiff2D(180, 180 - fov.x / 2 + 0.01));
85 }
86 else
87 {
88 transf.transform(pmiddle, hugin_utils::FDiff2D(0, fov.y / 2));
89 };
90
91 height = fabs(2 * pmiddle.y);
92 };
93 HFOV = fov.x;
94}
95
96
98{
100 {
101
103
106
108
109 return true; // let's hope so.
110
111 }
112
113 return false;
114}
115
116} //namespace
static hugin_utils::FDiff2D calcFOV(const PanoramaData &panorama)
static void fitPano(PanoramaData &panorama, double &HFOV, double &height)
virtual bool runAlgorithm()
implementation of the algorithm.
Definition FitPanorama.h:56
virtual double getResultHorizontalFOV()
Definition FitPanorama.h:68
virtual double getResultHeight()
Definition FitPanorama.h:75
virtual bool runAlgorithm()
implementation of the algorithm.
Holds transformations for Image -> Pano and the other way.
Model for a panorama.
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...
virtual const PanoramaOptions & getOptions() const =0
returns the options for this panorama
Panorama image options.
void setHFOV(double h, bool keepView=true)
set the horizontal field of view.
void setHeight(unsigned int h)
set panorama height
All variables of a source image.
void setSize(vigra::Size2D val)
Set the image size in pixels.
double HFOV
mainly consists of wrapper around the pano tools library, to assist in ressource management and to pr...
Definition wxcms.cpp:39
vigra::Rect2D estimateOutputROI(const PanoramaData &pano, const PanoramaOptions &opts, unsigned i, const double maxLength)
int roundi(T x)
Definition hugin_math.h:73
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41