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 
00254 IMPEX void setDestImage(Image & image, vigra::Diff2D size, unsigned char * imageData,
00255                   const PanoramaOptions::ProjectionFormat & format,
00256                   const std::vector<double> & projParams,
00257                   double destHFOV);
00258 
00262 IMPEX void setFullImage(Image & image, vigra::Diff2D size, unsigned char * imageData,
00263                   const VariableMap & vars,
00264                   const Lens::LensProjectionFormat format,
00265                   bool correctDistortions);
00266 
00271 IMPEX void freeImage(Image &img);
00272 
00274 IMPEX VariableMapVector GetAlignInfoVariables(const AlignInfo & gl);
00275 
00277 IMPEX CPVector GetAlignInfoCtrlPoints(const AlignInfo & gl);
00278 
00279 
00280 
00281 }} // namespace
00282 
00283 #endif // _H

Generated on 31 Oct 2014 for Hugintrunk by  doxygen 1.4.7