CalculateOptimalROI.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00024 #ifndef _BASICALGORITHMS_CALCULATEOPTIMALROI_H
00025 #define _BASICALGORITHMS_CALCULATEOPTIMALROI_H
00026 
00027 #include <hugin_shared.h>
00028 #include <panotools/PanoToolsInterface.h>
00029 #include <algorithms/PanoramaAlgorithm.h>
00030 #include <panodata/PanoramaData.h>
00031 
00032 #include <vector>
00033 #include <list>
00034 
00035 namespace HuginBase {
00036 
00037 class IMPEX CalculateOptimalROI : public TimeConsumingPanoramaAlgorithm
00038 {
00039     public:
00041         CalculateOptimalROI(PanoramaData& panorama, AppBase::ProgressDisplay* progress, bool intersect = false)
00042             : TimeConsumingPanoramaAlgorithm(panorama, progress), intersection(intersect)
00043         {
00044             //set to zero for error condition
00045             m_bestRect = vigra::Rect2D(0,0,0,0);
00046             o_optimalSize = vigra::Size2D(0,0);
00047         }
00048         CalculateOptimalROI(PanoramaData& panorama, AppBase::ProgressDisplay* progress, std::vector<UIntSet> hdr_stacks)
00049             : TimeConsumingPanoramaAlgorithm(panorama, progress), intersection(true), stacks(hdr_stacks)
00050         {
00051             //set to zero for error condition
00052             m_bestRect = vigra::Rect2D(0, 0, 0, 0);
00053             o_optimalSize = vigra::Size2D(0,0);
00054         }
00055         
00057         virtual ~CalculateOptimalROI() {};
00058         
00060         virtual bool modifiesPanoramaData() const
00061             { return false; }
00062             
00064         virtual bool runAlgorithm()
00065         {
00066             printf("Run called\n");
00067             return calcOptimalROI(o_panorama);
00068         }
00069         
00071         virtual vigra::Rect2D getResultOptimalROI()
00072         {
00073             if (hasRunSuccessfully())
00074             {
00075                 return m_bestRect;
00076             }
00077             else
00078             {
00079                 return vigra::Rect2D();
00080             }
00081         }
00082 
00084         void setStacks(std::vector<UIntSet> hdr_stacks);
00085 
00086     private:
00088         bool calcOptimalROI(PanoramaData& panorama);
00089 
00090         vigra::Size2D o_optimalSize;
00091         bool intersection;
00092         std::vector<UIntSet> stacks;
00093         UIntSet activeImages;
00094         std::map<unsigned int,PTools::Transform*> transfMap;
00095         //map for storing already tested pixels
00096         std::vector<bool> testedPixels;
00097         std::vector<bool> pixels;
00098         vigra::Rect2D m_bestRect;
00099 
00100         bool imgPixel(int i, int j);
00101         bool stackPixel(int i, int j, UIntSet &stack);
00102         
00103         //local stuff, convert over later
00104         bool autocrop();
00105         void nonreccheck(const vigra::Rect2D& rect, int acc, int searchStrategy, long& maxvalue);
00106         bool CheckRectCoversPano(const vigra::Rect2D& rect);
00107         void AddCheckingRects(std::list<vigra::Rect2D>& testingRects, const vigra::Rect2D& rect, const long maxvalue);
00108 
00109         void CleanUp();
00110 };
00111 
00112 } //namespace
00113 #endif

Generated on 28 Jul 2015 for Hugintrunk by  doxygen 1.4.7