Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CalculateOptimalROI.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
24 #ifndef _BASICALGORITHMS_CALCULATEOPTIMALROI_H
25 #define _BASICALGORITHMS_CALCULATEOPTIMALROI_H
26 
27 #include <hugin_shared.h>
30 #include <panodata/PanoramaData.h>
31 
32 #include <vector>
33 #include <list>
34 
35 namespace HuginBase {
36 
38 {
39  public:
41  CalculateOptimalROI(PanoramaData& panorama, AppBase::ProgressDisplay* progress, bool intersect = false)
42  : TimeConsumingPanoramaAlgorithm(panorama, progress), intersection(intersect)
43  {
44  //set to zero for error condition
45  m_bestRect = vigra::Rect2D(0,0,0,0);
46  o_optimalSize = vigra::Size2D(0,0);
47  }
48  CalculateOptimalROI(PanoramaData& panorama, AppBase::ProgressDisplay* progress, std::vector<UIntSet> hdr_stacks)
49  : TimeConsumingPanoramaAlgorithm(panorama, progress), intersection(true), stacks(hdr_stacks)
50  {
51  //set to zero for error condition
52  m_bestRect = vigra::Rect2D(0, 0, 0, 0);
53  o_optimalSize = vigra::Size2D(0,0);
54  }
55 
57  virtual ~CalculateOptimalROI() {};
58 
60  virtual bool modifiesPanoramaData() const
61  { return false; }
62 
64  virtual bool runAlgorithm()
65  {
66  return calcOptimalROI(o_panorama);
67  }
68 
70  virtual vigra::Rect2D getResultOptimalROI()
71  {
72  if (hasRunSuccessfully())
73  {
74  return m_bestRect;
75  }
76  else
77  {
78  return vigra::Rect2D();
79  }
80  }
81 
83  void setStacks(std::vector<UIntSet> hdr_stacks);
84 
85  private:
87  bool calcOptimalROI(PanoramaData& panorama);
88 
89  vigra::Size2D o_optimalSize;
91  std::vector<UIntSet> stacks;
93  std::map<unsigned int,PTools::Transform*> transfMap;
94  //map for storing already tested pixels
95  std::vector<bool> testedPixels;
96  std::vector<bool> pixels;
97  vigra::Rect2D m_bestRect;
98 
99  bool imgPixel(int i, int j);
100  bool stackPixel(int i, int j, UIntSet &stack);
101 
102  //local stuff, convert over later
103  bool autocrop();
104  void nonreccheck(const vigra::Rect2D& rect, int acc, int searchStrategy, long& maxvalue);
105  bool CheckRectCoversPano(const vigra::Rect2D& rect);
106  void AddCheckingRects(std::list<vigra::Rect2D>& testingRects, const vigra::Rect2D& rect, const long maxvalue);
107 
108  void CleanUp();
109 };
110 
112 {
113 public:
116  virtual bool modifiesPanoramaData() const
117  {
118  return false;
119  };
121  virtual bool runAlgorithm()
122  {
123  return CalcOutsideCrop(o_panorama, getProgressDisplay());
124  };
125 
127  virtual vigra::Rect2D getResultOptimalROI();
128 private:
130  bool CalcOutsideCrop(PanoramaData& pano, AppBase::ProgressDisplay* progress);
131  vigra::Rect2D m_bestRect;
132 };
133 
134 } //namespace
135 #endif
void CleanUp(std::vector< InputImage * > &images)
Definition: stacker.cpp:900
CalculateOptimalROI(PanoramaData &panorama, AppBase::ProgressDisplay *progress, std::vector< UIntSet > hdr_stacks)
CalculateOptimalROI(PanoramaData &panorama, AppBase::ProgressDisplay *progress, bool intersect=false)
constructor
virtual bool modifiesPanoramaData() const
returns true if the algorithm changes the PanoramaData.
virtual bool modifiesPanoramaData() const
returns true if the algorithm changes the PanoramaData.
std::set< unsigned int > UIntSet
Definition: PanoramaData.h:51
virtual bool runAlgorithm()
runs the outside crop finding algorithm
virtual vigra::Rect2D getResultOptimalROI()
return the ROI structure?, for now area
virtual ~CalculateOptimalROI()
destructor
Model for a panorama.
Definition: PanoramaData.h:81
virtual bool runAlgorithm()
implementation of the algorithm.
#define IMPEX
Definition: hugin_shared.h:39
CalculateOptimalROIOutside(PanoramaData &panorama, AppBase::ProgressDisplay *progress)
constructor
std::map< unsigned int, PTools::Transform * > transfMap