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

Generated on Fri Aug 29 01:25:41 2014 for Hugintrunk by  doxygen 1.3.9.1