Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CalculateOptimalScale.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
27 #ifndef _BASICALGORITHMS_CALCULATEOPTIMALSCALE_H
28 #define _BASICALGORITHMS_CALCULATEOPTIMALSCALE_H
29 
30 #include <hugin_shared.h>
32 
33 #include <panodata/PanoramaData.h>
34 
35 
36 
37 namespace HuginBase {
38 
39 
41 {
42 
43  public:
45  explicit CalculateOptimalScale(PanoramaData& panorama)
46  : PanoramaAlgorithm(panorama), o_optimalScale(0)
47  {}
48 
51  {}
52 
53 
54  public:
56  virtual bool modifiesPanoramaData() const
57  { return false; }
58 
60  virtual bool runAlgorithm()
61  {
62  o_optimalScale = calcOptimalScale(o_panorama);
63  return true; // let's hope so.
64  }
65 
66  public:
68  static double calcOptimalScale(PanoramaData& panorama);
69 
73  static double calcOptimalPanoScale(const SrcPanoImage & src,
74  const PanoramaOptions & dest);
75 
77  virtual double getResultOptimalScale()
78  {
79  // [TODO] if(!hasRunSuccessfully()) DEBUG;
80  return o_optimalScale;
81  }
82 
84  virtual unsigned getResultOptimalWidth()
85  {
86  // [TODO] if(!hasRunSuccessfully()) DEBUG;
87  return hugin_utils::roundi(getResultOptimalScale() * o_panorama.getOptions().getWidth());
88  }
89 
90  protected:
92 
93 };
94 
95 
97 {
98  public:
100  explicit SetWidthOptimal(PanoramaData& panorama)
101  : CalculateOptimalScale(panorama)
102  {}
103 
106  {}
107 
108 
109  public:
111  virtual bool modifiesPanoramaData() const
112  { return true; }
113 
115  virtual bool runAlgorithm()
116  {
117  bool success = CalculateOptimalScale::runAlgorithm();
118  if(success)
119  {
122  o_panorama.setOptions(opts);
123  }
124  return success;
125  }
126 };
127 
128 
129 } //namespace
130 #endif
virtual bool runAlgorithm()
implementation of the algorithm.
int roundi(T x)
Definition: hugin_math.h:73
CalculateOptimalScale(PanoramaData &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 bool runAlgorithm()
implementation of the algorithm.
virtual const PanoramaOptions & getOptions() const =0
returns the options for this panorama
Model for a panorama.
Definition: PanoramaData.h:81
#define IMPEX
Definition: hugin_shared.h:39
virtual bool modifiesPanoramaData() const
returns true if the algorithm changes the PanoramaData.
virtual bool modifiesPanoramaData() const
returns true if the algorithm changes the PanoramaData.
All variables of a source image.
Definition: SrcPanoImage.h:194
Panorama image options.
SetWidthOptimal(PanoramaData &panorama)
void setWidth(unsigned int w, bool keepView=true)
set panorama width keep the HFOV, if keepView=true