Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PanoToolsInterface.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
24 #ifndef _PANOTOOLS_PANOTOOLSINTERFACE_H
25 #define _PANOTOOLS_PANOTOOLSINTERFACE_H
26 
27 #include <hugin_shared.h>
28 #include <hugin_config.h>
29 
30 #include <iostream>
31 #include <string>
32 #include <set>
33 
34 #include <hugin_math/hugin_math.h>
36 #include <panodata/Lens.h>
38 #include <panodata/SrcPanoImage.h>
39 #include <panodata/ControlPoint.h>
40 
41 
42 // libpano includes ------------------------------------------------------------
43 
44 #ifdef _WIN32
45 // include windows.h with sensible defines, otherwise
46 // panotools might include with its stupid, commonly
47 // named macros all over the place.
48 #define _STLP_VERBOSE_AUTO_LINK
49 //#define _USE_MATH_DEFINES
50 #define NOMINMAX
51 #define VC_EXTRALEAN
52 #include <windows.h>
53 #undef DIFFERENCE
54 #undef min
55 #undef max
56 #undef MIN
57 #undef MAX
58 #endif
59 
60 
61 extern "C" {
62 #ifdef __INTEL__
63 #define __INTELMEMO__
64 #undef __INTEL__
65 #endif
66 
67 #include <pano13/panorama.h>
68 #include <pano13/filter.h>
69 
70 #ifdef __INTELMEMO__
71 #define __INTEL__
72 #undef __INTELMEMO__
73 #endif
74 
75 #include <pano13/filter.h>
76 
77 // somehow these are still set after panorama.h has been included
78 #undef DIFFERENCE
79 #undef min
80 #undef max
81 #undef MIN
82 #undef MAX
83 
84 }
85 
86 //------------------------------------------------------------------------------
87 
88 
89 namespace vigra { class Diff2D; }
90 namespace HuginBase { class PanoramaData; }
91 
92 
93 
101 namespace HuginBase { namespace PTools {
102 
103 
106 {
107 
108  public:
116  : m_initialized(false), m_srcTX(0), m_srcTY(0),
117  m_destTX(0), m_destTY(0)
118  {
119  // initialize pointer
120  m_srcImage.data = NULL;
121  m_dstImage.data = NULL;
122  }
123 
125  ~Transform();
126 
127  private:
128  // private, no copy constructor for the pt structures yet.
129  Transform(const Transform &);
130  Transform & operator=(const Transform &);
131 
132 
133  public:
151  void createTransform(const vigra::Diff2D & srcSize,
152  VariableMap srcVars,
154  const vigra::Diff2D &destSize,
156  const std::vector<double> & destProjParam,
157  double destHFOV,
158  const vigra::Diff2D & origSrcSize);
159 
161  void createTransform(const PanoramaData& pano, unsigned int imgNr,
162  const PanoramaOptions & dest,
163  vigra::Diff2D srcSize=vigra::Diff2D(0,0));
164 
166  void createTransform(const SrcPanoImage & src, const PanoramaOptions & dest);
167 
185  void createInvTransform(const vigra::Diff2D & srcSize,
186  VariableMap srcVars,
188  const vigra::Diff2D & destSize,
190  const std::vector<double> & destProjParam,
191  double destHFOV,
192  const vigra::Diff2D & origSrcSize);
193 
195  void createInvTransform(const PanoramaData& pano, unsigned int imgNr,
196  const PanoramaOptions & dest,
197  vigra::Diff2D srcSize=vigra::Diff2D(0,0));
198 
200  void createInvTransform(const SrcPanoImage & src, const PanoramaOptions & dest);
201 
204  bool transform(double & x_dest, double & y_dest,
205  double x_src, double y_src) const;
206 
208  bool transform(hugin_utils::FDiff2D& dest, const hugin_utils::FDiff2D & src) const;
209 
213  bool transformImgCoord(double & x_dest, double & y_dest,
214  double x_src, double y_src) const;
215 
216  bool transformImgCoordPartial(double & x_dest, double & y_dest, double x_src, double y_src) const;
217 
220  { return transformImgCoord(dest.x, dest.y, src.x, src.y); }
221 
222 
223  bool emitGLSL(std::ostringstream& oss) const;
224 
225  private:
226  // update internal PT data structs.
227  void updatePTData(const vigra::Diff2D &srcSize,
228  const VariableMap & srcVars,
229  Lens::LensProjectionFormat & srcProj,
230  const vigra::Diff2D & destSize,
232  const std::vector<double> & destProjParam,
233  double destHFOV);
234 
235 
236  private:
238 
239  Image m_srcImage;
240  Image m_dstImage;
241  struct MakeParams m_mp;
242  struct fDesc m_stack[15];
243 
244  // used to convert from screen to cartesian coordinates
245  double m_srcTX, m_srcTY;
246  double m_destTX, m_destTY;
247 
248 };
249 
250 
254 IMPEX void setDestImage(Image & image, vigra::Diff2D size, unsigned char * imageData,
255  const PanoramaOptions::ProjectionFormat & format,
256  const std::vector<double> & projParams,
257  double destHFOV);
258 
262 IMPEX void setFullImage(Image & image, vigra::Diff2D size, unsigned char * imageData,
263  const VariableMap & vars,
264  const Lens::LensProjectionFormat format,
265  bool correctDistortions);
266 
271 IMPEX void freeImage(Image &img);
272 
274 IMPEX VariableMapVector GetAlignInfoVariables(const AlignInfo & gl);
275 
277 IMPEX CPVector GetAlignInfoCtrlPoints(const AlignInfo & gl);
278 
279 
280 
281 }} // namespace
282 
283 #endif // _H
VariableMapVector GetAlignInfoVariables(const AlignInfo &gl)
misc math function &amp; classes used by other parts of the program
Transform()
construct a new Transform object, without initializing a transformation
bool transformImgCoord(hugin_utils::FDiff2D &dest, const hugin_utils::FDiff2D &src) const
std::vector< VariableMap > VariableMapVector
void freeImage(Image &img)
free the pointer storage needed by Image
Model for a panorama.
Definition: PanoramaData.h:81
void setDestImage(Image &image, vigra::Diff2D size, unsigned char *imageData, const PanoramaOptions::ProjectionFormat &format, const std::vector< double > &projParams, double destHFOV)
set an output image, with properties from opts, that points to the bitmap data of imgData ...
#define IMPEX
Definition: hugin_shared.h:39
std::map< std::string, Variable > VariableMap
CPVector GetAlignInfoCtrlPoints(const AlignInfo &gl)
Lens class.
Holds transformations for Image -&gt; Pano and the other way.
std::vector< ControlPoint > CPVector
Definition: ControlPoint.h:99
ProjectionFormat
Projection of final panorama.
All variables of a source image.
Definition: SrcPanoImage.h:194
Panorama image options.
void setFullImage(Image &image, vigra::Diff2D size, unsigned char *imageData, const VariableMap &vars, const Lens::LensProjectionFormat format, bool correctDistortions)
fills image with a complete input image, including distortion correction parameters if correctDistort...