FitPanorama.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00026 #include "FitPanorama.h"
00027 
00028 #include <algorithm>
00029 #include <panodata/PanoramaData.h>
00030 #include <panotools/PanoToolsInterface.h>
00031 #include <algorithms/nona/CalculateFOV.h>
00032 
00033 namespace HuginBase {
00034 
00035 void CalculateFitPanorama::fitPano(PanoramaData& panorama, double& HFOV, double& height)
00036 {
00037     // FIXME: doesn't work properly for fisheye and mirror projections,
00038     // it will not calculate a vfov bigger than 180.
00039     hugin_utils::FDiff2D fov = CalculateFOV::calcFOV(panorama);
00040     
00041     // use estimated fov to calculate a suitable panorama height.
00042     // calculate VFOV based on current panorama
00043     PTools::Transform transf;
00044     SrcPanoImage src;
00045     src.setProjection(SrcPanoImage::EQUIRECTANGULAR);
00046     src.setHFOV(360);
00047     src.setSize(vigra::Size2D(360,180));
00048     
00049     // output pano with new hfov
00050     PanoramaOptions opts = panorama.getOptions();
00051     opts.setHFOV(fov.x, false);
00052     transf.createInvTransform(src, opts);
00053     
00054     // limit fov to suitable range for this projection
00055     fov.x = std::min(fov.x, panorama.getOptions().getMaxHFOV());
00056     fov.y = std::min(fov.y, panorama.getOptions().getMaxVFOV());
00057     
00058     hugin_utils::FDiff2D pmiddle;
00059     // special case for projections with max VFOV > 180 (fisheye, stereographic)
00060     if (panorama.getOptions().getMaxVFOV() >  180 && fov.x > 180) {
00061         transf.transform(pmiddle, hugin_utils::FDiff2D(180, 180 - fov.x / 2 + 0.01));
00062     } else {
00063         transf.transform(pmiddle, hugin_utils::FDiff2D(0, fov.y / 2));
00064     }
00065     
00066     height = fabs(2*pmiddle.y);
00067     HFOV = fov.x;
00068 }
00069 
00070 
00071 bool FitPanorama::runAlgorithm()
00072 {
00073     if( CalculateFitPanorama::runAlgorithm() )
00074     {
00075         
00076         PanoramaOptions opts = o_panorama.getOptions();
00077         
00078         opts.setHFOV(getResultHorizontalFOV());
00079         opts.setHeight(hugin_utils::roundi(getResultHeight()));
00080         
00081         o_panorama.setOptions(opts);
00082         
00083         return true; // let's hope so.
00084         
00085     }
00086     
00087     return false;
00088 }
00089 
00090 } //namespace

Generated on 9 Dec 2016 for Hugintrunk by  doxygen 1.4.7