Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages
hugin_base/panotools/PanoToolsInterface.h
Go to the documentation of this file.00001 // -*- c-basic-offset: 4 -*- 00024 #ifndef _PANOTOOLS_PANOTOOLSINTERFACE_H 00025 #define _PANOTOOLS_PANOTOOLSINTERFACE_H 00026 00027 #include <hugin_shared.h> 00028 #include <hugin_config.h> 00029 00030 #include <iostream> 00031 #include <string> 00032 #include <set> 00033 00034 #include <hugin_math/hugin_math.h> 00035 #include <panodata/PanoramaVariable.h> 00036 #include <panodata/Lens.h> 00037 #include <panodata/PanoramaOptions.h> 00038 #include <panodata/SrcPanoImage.h> 00039 #include <panodata/ControlPoint.h> 00040 00041 00042 // libpano includes ------------------------------------------------------------ 00043 00044 #ifdef _WIN32 00045 // include windows.h with sensible defines, otherwise 00046 // panotools might include with its stupid, commonly 00047 // named macros all over the place. 00048 #define _STLP_VERBOSE_AUTO_LINK 00049 //#define _USE_MATH_DEFINES 00050 #define NOMINMAX 00051 #define VC_EXTRALEAN 00052 #include <windows.h> 00053 #undef DIFFERENCE 00054 #undef min 00055 #undef max 00056 #undef MIN 00057 #undef MAX 00058 #endif 00059 00060 00061 extern "C" { 00062 #ifdef __INTEL__ 00063 #define __INTELMEMO__ 00064 #undef __INTEL__ 00065 #endif 00066 00067 #include <pano13/panorama.h> 00068 #include <pano13/filter.h> 00069 00070 #ifdef __INTELMEMO__ 00071 #define __INTEL__ 00072 #undef __INTELMEMO__ 00073 #endif 00074 00075 #include <pano13/filter.h> 00076 00077 // somehow these are still set after panorama.h has been included 00078 #undef DIFFERENCE 00079 #undef min 00080 #undef max 00081 #undef MIN 00082 #undef MAX 00083 00084 } 00085 00086 //------------------------------------------------------------------------------ 00087 00088 00089 namespace vigra { class Diff2D; } 00090 namespace HuginBase { class PanoramaData; } 00091 00092 00093 00101 namespace HuginBase { namespace PTools { 00102 00103 00105 class IMPEX Transform 00106 { 00107 00108 public: 00115 Transform() 00116 : m_initialized(false), m_srcTX(0), m_srcTY(0), 00117 m_destTX(0), m_destTY(0) 00118 { 00119 // initialize pointer 00120 m_srcImage.data = NULL; 00121 m_dstImage.data = NULL; 00122 } 00123 00125 ~Transform(); 00126 00127 private: 00128 // private, no copy constructor for the pt structures yet. 00129 Transform(const Transform &); 00130 Transform & operator=(const Transform &); 00131 00132 00133 public: 00151 void createTransform(const vigra::Diff2D & srcSize, 00152 VariableMap srcVars, 00153 Lens::LensProjectionFormat srcProj, 00154 const vigra::Diff2D &destSize, 00155 PanoramaOptions::ProjectionFormat destProj, 00156 const std::vector<double> & destProjParam, 00157 double destHFOV, 00158 const vigra::Diff2D & origSrcSize); 00159 00161 void createTransform(const PanoramaData& pano, unsigned int imgNr, 00162 const PanoramaOptions & dest, 00163 vigra::Diff2D srcSize=vigra::Diff2D(0,0)); 00164 00166 void createTransform(const SrcPanoImage & src, const PanoramaOptions & dest); 00167 00185 void createInvTransform(const vigra::Diff2D & srcSize, 00186 VariableMap srcVars, 00187 Lens::LensProjectionFormat srcProj, 00188 const vigra::Diff2D & destSize, 00189 PanoramaOptions::ProjectionFormat destProj, 00190 const std::vector<double> & destProjParam, 00191 double destHFOV, 00192 const vigra::Diff2D & origSrcSize); 00193 00195 void createInvTransform(const PanoramaData& pano, unsigned int imgNr, 00196 const PanoramaOptions & dest, 00197 vigra::Diff2D srcSize=vigra::Diff2D(0,0)); 00198 00200 void createInvTransform(const SrcPanoImage & src, const PanoramaOptions & dest); 00201 00204 bool transform(double & x_dest, double & y_dest, 00205 double x_src, double y_src) const; 00206 00208 bool transform(hugin_utils::FDiff2D& dest, const hugin_utils::FDiff2D & src) const; 00209 00213 bool transformImgCoord(double & x_dest, double & y_dest, 00214 double x_src, double y_src) const; 00215 00216 bool transformImgCoordPartial(double & x_dest, double & y_dest, double x_src, double y_src) const; 00217 00219 bool transformImgCoord(hugin_utils::FDiff2D& dest, const hugin_utils::FDiff2D & src) const 00220 { return transformImgCoord(dest.x, dest.y, src.x, src.y); } 00221 00222 00223 bool emitGLSL(std::ostringstream& oss) const; 00224 00225 private: 00226 // update internal PT data structs. 00227 void updatePTData(const vigra::Diff2D &srcSize, 00228 const VariableMap & srcVars, 00229 Lens::LensProjectionFormat & srcProj, 00230 const vigra::Diff2D & destSize, 00231 PanoramaOptions::ProjectionFormat & destProj, 00232 const std::vector<double> & destProjParam, 00233 double destHFOV); 00234 00235 00236 private: 00237 bool m_initialized; 00238 00239 Image m_srcImage; 00240 Image m_dstImage; 00241 struct MakeParams m_mp; 00242 struct fDesc m_stack[15]; 00243 00244 // used to convert from screen to cartesian coordinates 00245 double m_srcTX, m_srcTY; 00246 double m_destTX, m_destTY; 00247 00248 }; 00249 00250 00251 00255 class AlignInfoWrap 00256 { 00257 public: 00259 AlignInfoWrap(); 00260 00262 ~AlignInfoWrap(); 00263 00264 00265 public: 00267 bool setInfo(const PanoramaData& pano); 00268 00270 void setGlobal(); 00271 00273 VariableMapVector getVariables() const; 00274 00276 CPVector getCtrlPoints() const; 00277 00278 // std::map<int,int> m_ctrlPointMap; 00279 // CPVector m_controlPoints; 00280 00281 protected: 00282 AlignInfo gl; 00283 }; 00284 00285 00286 00287 00288 00292 void setDestImage(Image & image, vigra::Diff2D size, unsigned char * imageData, 00293 const PanoramaOptions::ProjectionFormat & format, 00294 const std::vector<double> & projParams, 00295 double destHFOV); 00296 00300 void setFullImage(Image & image, vigra::Diff2D size, unsigned char * imageData, 00301 const VariableMap & vars, 00302 const Lens::LensProjectionFormat format, 00303 bool correctDistortions); 00304 00311 void createAdjustPrefs(aPrefs & p, TrformStr & transf); 00312 00315 void setAdjustSrcImg(TrformStr & trf, aPrefs & ap, 00316 int width, int height, unsigned char * imageData, 00317 const VariableMap & vars, 00318 const Lens::LensProjectionFormat format, 00319 bool correctDistortions); 00320 00321 00323 void setAdjustDestImg(TrformStr & trf, aPrefs & ap, 00324 int width, int height, unsigned char * imageData, 00325 const PanoramaOptions & opts); 00326 00327 00332 void createAdjustTrform(TrformStr & trf); 00333 00337 void freeTrform(TrformStr & trf); 00338 00343 void freeImage(Image &img); 00344 00345 00347 void setOptVars(optVars & opt, const std::set<std::string> & optvars); 00348 00350 VariableMapVector GetAlignInfoVariables(const AlignInfo & gl); 00351 00353 CPVector GetAlignInfoCtrlPoints(const AlignInfo & gl); 00354 00355 00356 00357 }} // namespace 00358 00359 #endif // _H
1.3.9.1