00001
00024 #ifndef _Hgn1_PANORAMA_H
00025 #define _Hgn1_PANORAMA_H
00026
00027 #include <panodata/Panorama.h>
00028 #include <panodata/PTScriptParsing.h>
00029 #include <algorithms/nona/CalculateFOV.h>
00030 #include <algorithms/nona/FitPanorama.h>
00031 #include <algorithms/basic/CalculateOptimalScale.h>
00032 #include <algorithms/basic/CalculateCPStatistics.h>
00033 #include <algorithms/nona/CenterHorizontally.h>
00034 #include <algorithms/basic/RotatePanorama.h>
00035 #include <algorithms/basic/TranslatePanorama.h>
00036 #include <algorithms/basic/StraightenPanorama.h>
00037 #include <algorithms/basic/CalculateMeanExposure.h>
00038 #include <algorithms/basic/CalculateOptimalROI.h>
00039 #include <algorithms/basic/LayerStacks.h>
00040
00041 #include <typeinfo>
00042 #include "PT/PanoImage.h"
00043 #include "PT/PanoramaMemento.h"
00044
00045
00046 namespace PT {
00047
00048 using HuginBase::UIntSet;
00049 using HuginBase::UIntVector;
00050
00051
00052 class Panorama : public HuginBase::Panorama
00053 {
00054 public:
00055 Panorama()
00056 : HuginBase::Panorama()
00057 {};
00058
00059 Panorama(const HuginBase::Panorama& pano)
00060 : HuginBase::Panorama(pano)
00061 {};
00062
00063 virtual ~Panorama() {};
00064
00065
00066 public:
00071 hugin_utils::FDiff2D calcFOV() const
00072 {
00073 Panorama pano(*this);
00074 return HuginBase::CalculateFOV::calcFOV(pano);
00075 }
00076
00079 void fitPano(double & HFOV, double & height)
00080 {
00081 HuginBase::CalculateFitPanorama fitPano(*this);
00082 fitPano.run();
00083 HFOV = fitPano.getResultHorizontalFOV();
00084 height = fitPano.getResultHeight();
00085 }
00086
00093 unsigned calcOptimalWidth() const
00094 {
00095 Panorama pano(*this);
00096 return hugin_utils::roundi(HuginBase::CalculateOptimalScale::calcOptimalScale(pano) * pano.getOptions().getWidth());
00097 }
00098
00101 void calcOptimalROI(vigra::Rect2D & roi,vigra::Size2D & size)
00102 {
00103 printf("calcOptimalROI Called\n");
00104 HuginBase::CalculateOptimalROI cropPano(*this);
00105
00106 cropPano.run();
00107
00108 roi=cropPano.getResultOptimalROI();
00109 size=cropPano.getResultOptimalSize();
00110 }
00111
00114 void calcOptimalStackROI(vigra::Rect2D & roi,vigra::Size2D & size)
00115 {
00116 printf("calcOptimalROI Called\n");
00117 UIntSet activeImages=getActiveImages();
00118 std::vector<UIntSet> stackImgs=getHDRStacks(*this,activeImages, getOptions());
00119 HuginBase::CalculateOptimalROI cropPano(*this);
00120
00121
00122 if(stackImgs.size()<activeImages.size())
00123 {
00124 cropPano.setStacks(stackImgs);
00125 }
00126 cropPano.run();
00127 roi=cropPano.getResultOptimalROI();
00128 size=cropPano.getResultOptimalSize();
00129 }
00130
00131
00133 void calcCtrlPntsErrorStats(double & min, double & max, double & mean, double & var, int imgNr=-1) const
00134 {
00135 Panorama pano(*this);
00136 HuginBase::CalculateCPStatisticsError calcStat(pano, imgNr);
00137 calcStat.run();
00138 min = calcStat.getResultMin();
00139 max = calcStat.getResultMax();
00140 mean = calcStat.getResultMean();
00141 var = calcStat.getResultVariance();
00142 }
00143
00145 void calcCtrlPntsRadiStats(double & min, double & max, double & mean, double & var,
00146 double & q10, double & q90, int imgNr=-1) const
00147 {
00148 Panorama pano(*this);
00149 HuginBase::CalculateCPStatisticsRadial calcStat(pano, imgNr);
00150 calcStat.run();
00151 min = calcStat.getResultMin();
00152 max = calcStat.getResultMax();
00153 mean = calcStat.getResultMean();
00154 var = calcStat.getResultVariance();
00155 q10 = calcStat.getResultPercentile10();
00156 q90 = calcStat.getResultPercentile90();
00157 }
00158
00160 void centerHorizontically()
00161 {
00162 HuginBase::CenterHorizontally(*this).run();
00163 }
00164
00169 void rotate(double yaw, double pitch, double roll)
00170 {
00171 HuginBase::RotatePanorama(*this, yaw,pitch,roll).run();
00172 }
00173
00178 void rotate(const Matrix3 & rot)
00179 {
00180 HuginBase::RotatePanorama(*this, rot).run();
00181 }
00182
00187 void translate(double x, double y, double z)
00188 {
00189 HuginBase::TranslatePanorama(*this, x, y, z).run();
00190 }
00191
00196
00197
00198
00199
00200
00201
00203 void straighten()
00204 {
00205 HuginBase::StraightenPanorama(*this).run();
00206 }
00207
00208 };
00209
00210
00211 class PanoramaObserver : public HuginBase::PanoramaObserver
00212 {
00213
00214 public:
00215 virtual ~PanoramaObserver() {};
00216
00217
00218 public:
00219 virtual void panoramaChanged(Panorama &pano)
00220 { DEBUG_DEBUG("Default panoramaChanged called"); };
00221
00222
00223 virtual void panoramaImagesChanged(Panorama &pano, const UIntSet & changed)
00224 { DEBUG_DEBUG("DEFAULT handler method"); };
00225
00226
00227 public:
00228 virtual void panoramaChanged(HuginBase::PanoramaData& pano)
00229 {
00230 DEBUG_INFO("New interface is called.")
00231
00232 try {
00233 panoramaChanged(dynamic_cast<Panorama&>(pano));
00234 } catch(std::bad_cast e) {
00235 DEBUG_WARN("Can't handle Non- PT::Panorama instance.")
00236 }
00237 };
00238
00239 virtual void panoramaImagesChanged(HuginBase::PanoramaData& pano,
00240 const UIntSet& changed)
00241 {
00242 DEBUG_INFO("New interface is called.")
00243
00244 try {
00245 panoramaImagesChanged(dynamic_cast<Panorama&>(pano), changed);
00246 } catch(std::bad_cast e) {
00247 DEBUG_WARN("Can't handle Non-PT::Panorama instance.")
00248 }
00249 };
00250 };
00251
00252
00253 inline double calcOptimalPanoScale(const SrcPanoImage& src,
00254 const PanoramaOptions& dest)
00255 {
00256 return HuginBase::CalculateOptimalScale::calcOptimalPanoScale(src, dest);
00257 }
00258
00259 inline double calcMeanExposure(Panorama& pano)
00260 {
00261 return HuginBase::CalculateMeanExposure::calcMeanExposure(pano);
00262 }
00263
00264
00265 using HuginBase::PTScriptParsing::getPTParam;
00266
00267 using HuginBase::PTScriptParsing::getIntParam;
00268 using HuginBase::PTScriptParsing::readVar;
00269 using HuginBase::PTScriptParsing::getDoubleParam;
00270 using HuginBase::PTScriptParsing::getPTDoubleParam;
00271
00272
00273
00274 }
00275 #endif // _PANORAMA_H