Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PhotometricOptimizer.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
24 #ifndef _PHOTOMETRIC_OPTIMIZER_H_
25 #define _PHOTOMETRIC_OPTIMIZER_H_
26 
27 #include <hugin_shared.h>
30 
31 #include <vector>
32 #include <panodata/PanoramaData.h>
35 
36 namespace HuginBase
37 {
38 
40  {
41 
42  public:
44  typedef std::vector<vigra_ext::PointPairRGB> PointPairs;
45 
48  const OptimizeVector& vars,
49  const PointPairs& correspondences, const float imageStepSize)
50  : TimeConsumingPanoramaAlgorithm(panorama, progressDisplay),
51  o_vars(vars), o_correspondences(correspondences), o_resultError(0.0), o_imageStepSize(imageStepSize)
52  {};
53 
55  virtual ~PhotometricOptimizer() {};
56 
57 
58  public:
60  static void optimizePhotometric(PanoramaData& pano, const OptimizeVector& vars,
61  const PointPairs& correspondences,
62  const float imageStepSize,
63  AppBase::ProgressDisplay* progress,
64  double& error);
65 
66  protected:
68  struct VarMapping
69  {
70  std::string type;
71  std::set<unsigned> imgs;
72  };
73 
75  struct OptimData
76  {
77 
79  std::vector<SrcPanoImage> m_imgs;
80  std::vector<VarMapping> m_vars;
81  std::vector<vigra_ext::PointPairRGB> m_data;
82  double huberSigma;
84 
85  int m_maxIter;
87 
88 
90  OptimData(const PanoramaData& pano, const OptimizeVector& optvars,
91  const std::vector<vigra_ext::PointPairRGB>& data,
92  double mEstimatorSigma, bool symmetric,
93  int maxIter, AppBase::ProgressDisplay* progress);
94 
96  void ToX(double * x);
97 
99  void FromX(double * x);
100 
101  };
102 
103  static int photometricVis(double *p, double *x, int m, int n, int iter, double sqerror, void * data);
104 
106  static void photometricError(double* p, double* x, int m, int n, void* data);
107 
108 
109  public:
111  virtual bool modifiesPanoramaData() const
112  { return true; }
113 
115  virtual bool runAlgorithm();
116 
117 
118  public:
119  double getResultError() const
120  {
121  // [TODO] if(!hasRunSuccessfully()) DEBUG;
122  return o_resultError;
123  }
124 
125 
126  protected:
129  const float o_imageStepSize;
131  };
132 
133 
134 
135 
137  {
138  public:
141  OPT_PHOTOMETRIC_LDR=0,
144  OPT_PHOTOMETRIC_HDR_WB
145  };
146 
149  const OptimizeVector& vars,
150  const PointPairs& correspondences,
151  const float imageStepSize,
152  PhotometricOptimizeMode optMode)
153  : PhotometricOptimizer(panorama, progressDisplay, vars, correspondences, imageStepSize), o_optMode(optMode)
154  {};
155 
158 
159 
160  public:
163  static void smartOptimizePhotometric(PanoramaData & pano, PhotometricOptimizeMode mode,
164  const std::vector<vigra_ext::PointPairRGB> & correspondences,
165  const float imageStepSize,
166  AppBase::ProgressDisplay* progress,
167  double & error);
168 
170  virtual bool runAlgorithm();
171 
172 
173  protected:
175  };
176 
177 
178 
179 } // namespace
180 
181 
182 #endif
SmartPhotometricOptimizer(PanoramaData &panorama, AppBase::ProgressDisplay *progressDisplay, const OptimizeVector &vars, const PointPairs &correspondences, const float imageStepSize, PhotometricOptimizeMode optMode)
std::vector< vigra_ext::PointPairRGB > PointPairs
PhotometricOptimizeMode
local optimize definition.
PhotometricOptimizer(PanoramaData &panorama, AppBase::ProgressDisplay *progressDisplay, const OptimizeVector &vars, const PointPairs &correspondences, const float imageStepSize)
virtual bool modifiesPanoramaData() const
returns true if the algorithm changes the PanoramaData.
Model for a panorama.
Definition: PanoramaData.h:81
!! from PTOptimise.h 1951
#define IMPEX
Definition: hugin_shared.h:39
options wxIntPtr wxIntPtr sortData std::vector< PanoInfo > * data
std::vector< std::set< std::string > > OptimizeVector
std::vector< vigra_ext::PointPairRGB > m_data