From: <ip...@us...> - 2007-06-04 15:02:22
|
Revision: 2048 http://hugin.svn.sourceforge.net/hugin/?rev=2048&view=rev Author: ippei Date: 2007-06-04 08:02:20 -0700 (Mon, 04 Jun 2007) Log Message: ----------- fist step in panodata reorganisation Modified Paths: -------------- hugin/branches/ippei/src/hugin_base/panodata/Panorama.h Added Paths: ----------- hugin/branches/ippei/src/hugin_base/panodata/ControlPoint.h hugin/branches/ippei/src/hugin_base/panodata/Lens.h hugin/branches/ippei/src/hugin_base/panodata/PanoramaOptions.h hugin/branches/ippei/src/hugin_base/panodata/PanoramaVariable.h Removed Paths: ------------- hugin/branches/ippei/src/hugin_base/panodata/PanoramaMemento.h Copied: hugin/branches/ippei/src/hugin_base/panodata/ControlPoint.h (from rev 2045, hugin/branches/ippei/src/hugin_base/panodata/PanoramaMemento.h) =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/ControlPoint.h (rev 0) +++ hugin/branches/ippei/src/hugin_base/panodata/ControlPoint.h 2007-06-04 15:02:20 UTC (rev 2048) @@ -0,0 +1,147 @@ +// -*- c-basic-offset: 4 -*- +/** @file PanoramaMemento.h + * + * @author Pablo d'Angelo <pab...@we...> + * + * $Id: PanoramaMemento.h 1970 2007-04-18 22:26:56Z dangelo $ + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _PANORAMAMEMENTO_H +#define _PANORAMAMEMENTO_H + + +#include <string> +#include <vector> +#include <map> +#include <algorithm> +#include <set> +#include <math.h> + +#ifdef HasPANO13 +extern "C" { + +#ifdef __INTEL__ +#define __INTELMEMO__ +#undef __INTEL__ +#endif + +#include "pano13/panorama.h" + +#ifdef __INTELMEMO__ +#define __INTEL__ +#undef __INTELMEMO__ +#endif + +// remove stupid #defines from the evil windows.h + +#ifdef DIFFERENCE +#undef DIFFERENCE +#endif + +#ifdef MIN +#undef MIN +#endif + +#ifdef MAX +#undef MAX +#endif + +#ifdef min +#undef min +#endif + +#ifdef max +#undef max +#endif +} +#endif + +#include "PT/PanoImage.h" + +#include "vigra_ext/Interpolators.h" + +namespace PT { + +/// represents a control point +class ControlPoint +{ +public: + /** minimize x,y or both. higher numbers mean multiple line + * control points + */ + enum OptimizeMode { + X_Y = 0, ///< evaluate x,y + X, ///< evaluate x, points are on a vertical line + Y ///< evaluate y, points are on a horizontal line + }; + ControlPoint() + : image1Nr(0), image2Nr(0), + x1(0),y1(0), + x2(0),y2(0), + error(0), mode(X_Y) + { }; + +// ControlPoint(Panorama & pano, const QDomNode & node); + ControlPoint(unsigned int img1, double sX, double sY, + unsigned int img2, double dX, double dY, + int mode = X_Y) + : image1Nr(img1), image2Nr(img2), + x1(sX),y1(sY), + x2(dX),y2(dY), + error(0), mode(mode) + { }; + + bool operator==(const ControlPoint & o) const + { + return (image1Nr == o.image1Nr && + image2Nr == o.image2Nr && + x1 == o.x1 && y1 == o.y1 && + x2 == o.x2 && y2 == o.y2 && + mode == o.mode && + error == o.error); + } + + const std::string & getModeName(OptimizeMode mode) const; + +// QDomNode toXML(QDomDocument & doc) const; + +// void setFromXML(const QDomNode & elem, Panorama & pano); + + /// swap (image1Nr,x1,y1) with (image2Nr,x2,y2) + void mirror(); + +protected: + // TODO: accessors + + unsigned int image1Nr; + unsigned int image2Nr; + double x1,y1; + double x2,y2; + double error; + int mode; + + static std::string modeNames[]; + +}; + + +typedef std::vector<ControlPoint> CPVector; + + +} // namespace +#endif // _PANORAMAMEMENTO_H Copied: hugin/branches/ippei/src/hugin_base/panodata/Lens.h (from rev 2045, hugin/branches/ippei/src/hugin_base/panodata/PanoramaMemento.h) =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/Lens.h (rev 0) +++ hugin/branches/ippei/src/hugin_base/panodata/Lens.h 2007-06-04 15:02:20 UTC (rev 2048) @@ -0,0 +1,214 @@ +// -*- c-basic-offset: 4 -*- +/** @file Lens.h + * + * @brief Lens class + * + * !! from PanoramaMemento.h 1970 + * + * @author Pablo d'Angelo <pab...@we...> + * + * $Id: PanoramaMemento.h 1970 2007-04-18 22:26:56Z dangelo $ + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _PANORAMAMEMENTO_H +#define _PANORAMAMEMENTO_H + + +#include <string> +#include <vector> +#include <map> +#include <algorithm> +#include <set> +#include <math.h> + +#ifdef HasPANO13 +extern "C" { + +#ifdef __INTEL__ +#define __INTELMEMO__ +#undef __INTEL__ +#endif + +#include "pano13/panorama.h" + +#ifdef __INTELMEMO__ +#define __INTEL__ +#undef __INTELMEMO__ +#endif + +// remove stupid #defines from the evil windows.h + +#ifdef DIFFERENCE +#undef DIFFERENCE +#endif + +#ifdef MIN +#undef MIN +#endif + +#ifdef MAX +#undef MAX +#endif + +#ifdef min +#undef min +#endif + +#ifdef max +#undef max +#endif +} +#endif + +#include "PT/PanoImage.h" + +#include "vigra_ext/Interpolators.h" + +namespace PT { + +class Lens { + +public: + /** Lens type + */ + enum LensProjectionFormat { RECTILINEAR = 0, + PANORAMIC = 1, + CIRCULAR_FISHEYE = 2, + FULL_FRAME_FISHEYE = 3, + EQUIRECTANGULAR = 4}; + + + /** construct a new lens. + * + */ + Lens(); + +// QDomElement toXML(QDomDocument & doc); +// void setFromXML(const QDomNode & node); + + /** try to fill Lens data (HFOV) from EXIF header + * + * @return true if focal length was found, lens will contain + * the correct data. + */ +// bool readEXIF(const std::string & filename); + + /** get projection type */ + LensProjectionFormat getProjection() const + { + return m_projectionFormat; + } + + /** set projection type */ + void setProjection(LensProjectionFormat l) { + m_projectionFormat = l; + } + + /** get HFOV in degrees */ + double getHFOV() const; + + /** set HFOV in degrees */ + void setHFOV(double d); + + /** get focal length of lens, it is calculated from the HFOV */ + double getFocalLength() const; + + /** set focal length, updates HFOV */ + void setFocalLength(double); + + /** get crop factor, d35mm/dreal */ + double getCropFactor() const; + + /** Set the crop factor. + * + * This will recalculate the sensor size. + * + * @param c is the ratio of the sensor diagonals: + * factor = diag35mm / real_diag + */ + void setCropFactor(double c); + + /** get sensor dimension */ + FDiff2D getSensorSize() const + { + return m_sensorSize; + } + + /** set sensor dimensions. Only square pixels are supported so far.*/ + void setSensorSize(const FDiff2D & size); + + /** return the sensor ratio (width/height) + */ + double getAspectRatio() const + { + return (double)m_imageSize.x / m_imageSize.y; + } + + /** check if the image associated with this lens is in landscape orientation. + */ + bool isLandscape() const + { + return m_imageSize.x >= m_imageSize.y; + } + + /** set the exposure value */ + void setEV(double ev); + + /** get the image size, in pixels */ + vigra::Size2D getImageSize() const + { + return m_imageSize; + } + + /** set image size in pixels */ + void setImageSize(const vigra::Size2D & sz) + { + m_imageSize = sz; + } + + /** try to read image information from file */ + bool initFromFile(const std::string & filename, double &cropFactor, double & roll); + +// double isLandscape() const { +// return sensorRatio >=1; +// } + + // updates everything, including the lens variables. + void update(const Lens & l); + + +// bool isLandscape; + // these are the lens specific settings. + // lens correction parameters + LensVarMap variables; + static char *variableNames[]; + + bool m_hasExif; +private: + + LensProjectionFormat m_projectionFormat; + vigra::Size2D m_imageSize; + FDiff2D m_sensorSize; +}; + + +typedef std::vector<Lens> LensVector; + + +} // namespace +#endif // _PANORAMAMEMENTO_H Modified: hugin/branches/ippei/src/hugin_base/panodata/Panorama.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/Panorama.h 2007-06-04 14:28:23 UTC (rev 2047) +++ hugin/branches/ippei/src/hugin_base/panodata/Panorama.h 2007-06-04 15:02:20 UTC (rev 2048) @@ -701,6 +701,89 @@ +// -- from memento.h -- + + + + + + + + + + + +typedef std::vector<PanoImage> ImageVector; +typedef std::vector<std::set<std::string> > OptimizeVector; + +class Panorama; +/** Memento class for a Panorama object + * + * Holds the internal state of a Panorama. + * Used when other objects need to get/set the state without + * knowing anything about the internals. + * + * It is also used for saving/loading (the state can be serialized + * to an xml file). + * + * @todo xml support + */ +class PanoramaMemento +{ +public: + PanoramaMemento() + : needsOptimization(false) + { }; + /// copy ctor. +// PanoramaMemento(const PanoramaMemento & o); + /// assignment operator +// PanoramaMemento & operator=(const PanoramaMemento & o); + virtual ~PanoramaMemento(); + + /** enum for supported PTScript syntax bastards */ + enum PTFileFormat { PTFILE_HUGIN, PTFILE_PTGUI, PTFILE_PTA }; + + + /** load a PTScript file + * + * initializes the PanoramaMemento from a PTScript file + */ + bool loadPTScript(std::istream & i, const std::string & prefix = ""); + +private: + + enum PTParseState { P_NONE, + P_OUTPUT, + P_MODIFIER, + P_IMAGE, + P_OPTIMIZE, + P_CP + }; + + + friend class PT::Panorama; + // state members for the state + + ImageVector images; + VariableMapVector variables; + + CPVector ctrlPoints; + + std::vector<Lens> lenses; + PanoramaOptions options; + + OptimizeVector optvec; + + // indicates that changes have been made to + // control points or lens parameters after the + // last optimisation + bool needsOptimization; +}; + + + + + } // namespace Deleted: hugin/branches/ippei/src/hugin_base/panodata/PanoramaMemento.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/PanoramaMemento.h 2007-06-04 14:28:23 UTC (rev 2047) +++ hugin/branches/ippei/src/hugin_base/panodata/PanoramaMemento.h 2007-06-04 15:02:20 UTC (rev 2048) @@ -1,691 +0,0 @@ -// -*- c-basic-offset: 4 -*- -/** @file PanoramaMemento.h - * - * @author Pablo d'Angelo <pab...@we...> - * - * $Id: PanoramaMemento.h 1970 2007-04-18 22:26:56Z dangelo $ - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef _PANORAMAMEMENTO_H -#define _PANORAMAMEMENTO_H - - -#include <string> -#include <vector> -#include <map> -#include <algorithm> -#include <set> -#include <math.h> - -#ifdef HasPANO13 -extern "C" { - -#ifdef __INTEL__ -#define __INTELMEMO__ -#undef __INTEL__ -#endif - -#include "pano13/panorama.h" - -#ifdef __INTELMEMO__ -#define __INTEL__ -#undef __INTELMEMO__ -#endif - -// remove stupid #defines from the evil windows.h - -#ifdef DIFFERENCE -#undef DIFFERENCE -#endif - -#ifdef MIN -#undef MIN -#endif - -#ifdef MAX -#undef MAX -#endif - -#ifdef min -#undef min -#endif - -#ifdef max -#undef max -#endif -} -#endif - -#include "PT/PanoImage.h" - -#include "vigra_ext/Interpolators.h" - -namespace PT { - -/** a variable has a value and a name. - * - * linking is only supported by LinkedVariable, which - * is only used by Lens. - */ -class Variable -{ -public: - Variable(const std::string & name, double val = 0.0) - : name(name), value(val) - { }; - virtual ~Variable() {}; - - /// print this variable - virtual std::ostream & print(std::ostream & o) const; - - const std::string & getName() const - { return name; } - void setValue(double v) - { value = v; } - double getValue() const - { return value; } - -protected: - - std::string name; - double value; -}; - -// a linked variable (which contains the link target explicitly -class LinkedVariable : public Variable -{ - LinkedVariable(const std::string & name, double val = 0.0, int link=-1) - : Variable(name, val), m_link(link) - { - } - - bool isLinked() const - { return m_link >= 0; } - int getLink() const - { return m_link; } - void setLink(int link) - { m_link = link; } - -protected: - int m_link; -}; - -/** A lens variable can be linked. - * - * It is only used in the lens class, not directly in the images. - */ -class LensVariable : public Variable -{ -public: - LensVariable(const std::string & name, double value, bool link=false) - : Variable(name, value), linked(link) - { }; - virtual ~LensVariable() {} - virtual std::ostream & printLink(std::ostream & o, unsigned int link) const; - - bool isLinked() const - { return linked; } - void setLinked(bool l=true) - { linked = l; } -private: - bool linked; -}; - - - -/** functor to print a variable. */ -struct PrintVar : public std::unary_function<Variable, void> -{ - PrintVar(std::ostream & o) : os(o) { } - void operator() (Variable x) const { x.print(os) << " "; } - std::ostream& os; -}; - -typedef std::map<std::string,Variable> VariableMap; -typedef std::vector<VariableMap> VariableMapVector; -typedef std::map<std::string,LensVariable> LensVarMap; - -/** fill map with all image & lens variables */ -void fillVariableMap(VariableMap & vars); - -/** just lens variables */ -void fillLensVarMap(LensVarMap & vars); - -/** print a variable map to \p o */ -void printVariableMap(std::ostream & o, const VariableMap & vars); - -class Lens { - -public: - /** Lens type - */ - enum LensProjectionFormat { RECTILINEAR = 0, - PANORAMIC = 1, - CIRCULAR_FISHEYE = 2, - FULL_FRAME_FISHEYE = 3, - EQUIRECTANGULAR = 4}; - - - /** construct a new lens. - * - */ - Lens(); - -// QDomElement toXML(QDomDocument & doc); -// void setFromXML(const QDomNode & node); - - /** try to fill Lens data (HFOV) from EXIF header - * - * @return true if focal length was found, lens will contain - * the correct data. - */ -// bool readEXIF(const std::string & filename); - - /** get projection type */ - LensProjectionFormat getProjection() const - { - return m_projectionFormat; - } - - /** set projection type */ - void setProjection(LensProjectionFormat l) { - m_projectionFormat = l; - } - - /** get HFOV in degrees */ - double getHFOV() const; - - /** set HFOV in degrees */ - void setHFOV(double d); - - /** get focal length of lens, it is calculated from the HFOV */ - double getFocalLength() const; - - /** set focal length, updates HFOV */ - void setFocalLength(double); - - /** get crop factor, d35mm/dreal */ - double getCropFactor() const; - - /** Set the crop factor. - * - * This will recalculate the sensor size. - * - * @param c is the ratio of the sensor diagonals: - * factor = diag35mm / real_diag - */ - void setCropFactor(double c); - - /** get sensor dimension */ - FDiff2D getSensorSize() const - { - return m_sensorSize; - } - - /** set sensor dimensions. Only square pixels are supported so far.*/ - void setSensorSize(const FDiff2D & size); - - /** return the sensor ratio (width/height) - */ - double getAspectRatio() const - { - return (double)m_imageSize.x / m_imageSize.y; - } - - /** check if the image associated with this lens is in landscape orientation. - */ - bool isLandscape() const - { - return m_imageSize.x >= m_imageSize.y; - } - - /** set the exposure value */ - void setEV(double ev); - - /** get the image size, in pixels */ - vigra::Size2D getImageSize() const - { - return m_imageSize; - } - - /** set image size in pixels */ - void setImageSize(const vigra::Size2D & sz) - { - m_imageSize = sz; - } - - /** try to read image information from file */ - bool initFromFile(const std::string & filename, double &cropFactor, double & roll); - -// double isLandscape() const { -// return sensorRatio >=1; -// } - - // updates everything, including the lens variables. - void update(const Lens & l); - - -// bool isLandscape; - // these are the lens specific settings. - // lens correction parameters - LensVarMap variables; - static char *variableNames[]; - - bool m_hasExif; -private: - - LensProjectionFormat m_projectionFormat; - vigra::Size2D m_imageSize; - FDiff2D m_sensorSize; -}; - - -/// represents a control point -class ControlPoint -{ -public: - /** minimize x,y or both. higher numbers mean multiple line - * control points - */ - enum OptimizeMode { - X_Y = 0, ///< evaluate x,y - X, ///< evaluate x, points are on a vertical line - Y ///< evaluate y, points are on a horizontal line - }; - ControlPoint() - : image1Nr(0), image2Nr(0), - x1(0),y1(0), - x2(0),y2(0), - error(0), mode(X_Y) - { }; - -// ControlPoint(Panorama & pano, const QDomNode & node); - ControlPoint(unsigned int img1, double sX, double sY, - unsigned int img2, double dX, double dY, - int mode = X_Y) - : image1Nr(img1), image2Nr(img2), - x1(sX),y1(sY), - x2(dX),y2(dY), - error(0), mode(mode) - { }; - - bool operator==(const ControlPoint & o) const - { - return (image1Nr == o.image1Nr && - image2Nr == o.image2Nr && - x1 == o.x1 && y1 == o.y1 && - x2 == o.x2 && y2 == o.y2 && - mode == o.mode && - error == o.error); - } - - const std::string & getModeName(OptimizeMode mode) const; - -// QDomNode toXML(QDomDocument & doc) const; - -// void setFromXML(const QDomNode & elem, Panorama & pano); - - /// swap (image1Nr,x1,y1) with (image2Nr,x2,y2) - void mirror(); - - unsigned int image1Nr; - unsigned int image2Nr; - double x1,y1; - double x2,y2; - double error; - int mode; - - static std::string modeNames[]; -}; - -/** Panorama image options - * - * this holds the settings for the final panorama - */ -class PanoramaOptions -{ -public: - - - /** Projection of final panorama - */ - enum ProjectionFormat { RECTILINEAR = 0, - CYLINDRICAL = 1, - EQUIRECTANGULAR = 2, - FULL_FRAME_FISHEYE = 3, - STEREOGRAPHIC = 4, - MERCATOR = 5, - TRANSVERSE_MERCATOR = 6, - SINUSOIDAL = 7, - LAMBERT = 8, - LAMBERT_AZIMUTHAL = 9, - ALBERS_EQUAL_AREA_CONIC = 10, - MILLER_CYLINDRICAL = 11 - }; - - /** PTStitcher acceleration */ - enum PTStitcherAcceleration { - NO_SPEEDUP, - MAX_SPEEDUP, - MEDIUM_SPEEDUP // for projects with morphing. - }; - - /** Fileformat - */ - enum FileFormat { - JPEG = 0, - PNG, - TIFF, - TIFF_m, - TIFF_mask, - TIFF_multilayer, - TIFF_multilayer_mask, - PICT, - PSD, - PSD_m, - PSD_mask, - PAN, - IVR, - IVR_java, - VRML, - QTVR, - HDR, - HDR_m - }; - - /** output mode */ - enum OutputMode { - OUTPUT_LDR=0, - OUTPUT_HDR - }; - - /** blenders */ - enum BlendingMechanism { - NO_BLEND=0, - PTBLENDER_BLEND=1, - ENBLEND_BLEND=2, - SMARTBLEND_BLEND=3 - }; - - enum Remapper { - NONA=0, - PTMENDER - }; - - /** type of color correction - */ - enum ColorCorrection { NONE = 0, - BRIGHTNESS_COLOR, - BRIGHTNESS, - COLOR }; - - PanoramaOptions() - { - reset(); - }; - - void reset() - { - m_projectionFormat = EQUIRECTANGULAR; -#ifdef HasPANO13 - panoProjectionFeaturesQuery(m_projectionFormat, &m_projFeatures); -#endif - m_hfov = 360; - m_size = vigra::Size2D(3000, 1500); - m_roi = vigra::Rect2D(m_size); - outfile = "panorama.JPG"; - quality = 90; - tiff_saveROI = false; - tiffCompression = "NONE"; - colorCorrection = NONE; - colorReferenceImage = 0; - optimizeReferenceImage = 0; - gamma = 1.0; - interpolator = vigra_ext::INTERP_CUBIC; - featherWidth = 10; - outputFormat = JPEG; - remapAcceleration = MAX_SPEEDUP; - blendMode = NO_BLEND; - remapper = NONA; - saveCoordImgs = false; - huberSigma = 2; - photometricHuberSigma = 2/255.0; - photometricSymmetricError = false; - outputMode = OUTPUT_LDR; - outputEMoRParams.resize(5,0.0); - outputExposureValue = 0.0; - outputPixelType = ""; - } - virtual ~PanoramaOptions() {}; - - void printScriptLine(std::ostream & o,bool forPTOptimizer=false) const; - - /// return string name of output file format - static const std::string & getFormatName(FileFormat f); - - /** returns the FileFormat corrosponding to name. - * - * if name is not recognized, FileFormat::TIFF is returned - */ - static FileFormat getFormatFromName(const std::string & name); - - /** set panorama width - * keep the HFOV, if keepView=true - */ - void setWidth(unsigned int w, bool keepView = true); - - /* get panorama width */ - unsigned int getWidth() const - { - return m_size.x; - } - - /** set panorama height - * - * This changes the panorama vfov - */ - void setHeight(unsigned int h); - - /** get panorama height */ - unsigned int getHeight() const - { - return m_size.y; - } - - /// get size of output image - vigra::Size2D getSize() const - { - return m_size; - } - - const vigra::Rect2D & getROI() const - { return m_roi; } - void setROI(const vigra::Rect2D & val) - { m_roi = val; } - - /** set the Projection format and adjust the hfov/vfov - * if nessecary - */ - void setProjection(ProjectionFormat f); - - PanoramaOptions::ProjectionFormat getProjection() const - { - return m_projectionFormat; - }; - - /** Get the optional projection parameters */ - const std::vector<double> & getProjectionParameters() const; - - /** set the optional parameters (they need to be of the correct size) */ - void setProjectionParameters(const std::vector<double> & params); - - /** true, if FOV calcuations are supported for projection \p f */ - bool fovCalcSupported(ProjectionFormat f) const; - - /** set the horizontal field of view. - * also updates the image height (keep pano - * field of view similar.) - */ - void setHFOV(double h, bool keepView=true); - - double getHFOV() const - { - return m_hfov; - } - - void setVFOV(double v); - double getVFOV() const; - - /** get maximum possible hfov with current projection */ - double getMaxHFOV() const; - /** get maximum possible vfov with current projection */ - double getMaxVFOV() const; - - DestPanoImage getDestImage() const; - - const std::string & getOutputExtension(); - - // they are public, because they need to be set through - // get/setOptions in Panorama. - - std::string outfile; - FileFormat outputFormat; - // jpeg options - int quality; - // TIFF options - std::string tiffCompression; - bool tiff_saveROI; - - ColorCorrection colorCorrection; - unsigned int colorReferenceImage; - - // misc options - double gamma; - vigra_ext::Interpolator interpolator; - - unsigned int optimizeReferenceImage; - unsigned int featherWidth; - - PTStitcherAcceleration remapAcceleration; - BlendingMechanism blendMode; - Remapper remapper; - - bool saveCoordImgs; - - double huberSigma; - - double photometricHuberSigma; - double photometricSymmetricError; - - // modes related to high dynamic range output - OutputMode outputMode; - // select the exposure of the output images in LDR mode. - double outputExposureValue; - std::vector<float> outputEMoRParams; - // choose pixel type for output images. - std::string outputPixelType; - - -#ifdef HasPANO13 - pano_projection_features m_projFeatures; -#endif - -private: - static const std::string fileformatNames[]; - static const std::string fileformatExt[]; - double m_hfov; -// unsigned int m_width; -// unsigned int m_height; - ProjectionFormat m_projectionFormat; - - std::vector<double> m_projectionParams; - vigra::Size2D m_size; - vigra::Rect2D m_roi; -}; - -typedef std::vector<ControlPoint> CPVector; -typedef std::vector<PanoImage> ImageVector; -typedef std::vector<std::set<std::string> > OptimizeVector; -typedef std::vector<Lens> LensVector; - -class Panorama; -/** Memento class for a Panorama object - * - * Holds the internal state of a Panorama. - * Used when other objects need to get/set the state without - * knowing anything about the internals. - * - * It is also used for saving/loading (the state can be serialized - * to an xml file). - * - * @todo xml support - */ -class PanoramaMemento -{ -public: - PanoramaMemento() - : needsOptimization(false) - { }; - /// copy ctor. -// PanoramaMemento(const PanoramaMemento & o); - /// assignment operator -// PanoramaMemento & operator=(const PanoramaMemento & o); - virtual ~PanoramaMemento(); - - /** enum for supported PTScript syntax bastards */ - enum PTFileFormat { PTFILE_HUGIN, PTFILE_PTGUI, PTFILE_PTA }; - - - /** load a PTScript file - * - * initializes the PanoramaMemento from a PTScript file - */ - bool loadPTScript(std::istream & i, const std::string & prefix = ""); - -private: - - enum PTParseState { P_NONE, - P_OUTPUT, - P_MODIFIER, - P_IMAGE, - P_OPTIMIZE, - P_CP - }; - - - friend class PT::Panorama; - // state members for the state - - ImageVector images; - VariableMapVector variables; - - CPVector ctrlPoints; - - std::vector<Lens> lenses; - PanoramaOptions options; - - OptimizeVector optvec; - - // indicates that changes have been made to - // control points or lens parameters after the - // last optimisation - bool needsOptimization; -}; - -} // namespace -#endif // _PANORAMAMEMENTO_H Copied: hugin/branches/ippei/src/hugin_base/panodata/PanoramaOptions.h (from rev 2045, hugin/branches/ippei/src/hugin_base/panodata/PanoramaMemento.h) =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/PanoramaOptions.h (rev 0) +++ hugin/branches/ippei/src/hugin_base/panodata/PanoramaOptions.h 2007-06-04 15:02:20 UTC (rev 2048) @@ -0,0 +1,347 @@ +// -*- c-basic-offset: 4 -*- +/** @file PanoramaMemento.h + * + * @author Pablo d'Angelo <pab...@we...> + * + * $Id: PanoramaMemento.h 1970 2007-04-18 22:26:56Z dangelo $ + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _PANORAMAMEMENTO_H +#define _PANORAMAMEMENTO_H + + +#include <string> +#include <vector> +#include <map> +#include <algorithm> +#include <set> +#include <math.h> + +#ifdef HasPANO13 +extern "C" { + +#ifdef __INTEL__ +#define __INTELMEMO__ +#undef __INTEL__ +#endif + +#include "pano13/panorama.h" + +#ifdef __INTELMEMO__ +#define __INTEL__ +#undef __INTELMEMO__ +#endif + +// remove stupid #defines from the evil windows.h + +#ifdef DIFFERENCE +#undef DIFFERENCE +#endif + +#ifdef MIN +#undef MIN +#endif + +#ifdef MAX +#undef MAX +#endif + +#ifdef min +#undef min +#endif + +#ifdef max +#undef max +#endif +} +#endif + +#include "PT/PanoImage.h" + +#include "vigra_ext/Interpolators.h" + +namespace PT { + +/** Panorama image options + * + * this holds the settings for the final panorama + */ +class PanoramaOptions +{ +public: + + + /** Projection of final panorama + */ + enum ProjectionFormat { RECTILINEAR = 0, + CYLINDRICAL = 1, + EQUIRECTANGULAR = 2, + FULL_FRAME_FISHEYE = 3, + STEREOGRAPHIC = 4, + MERCATOR = 5, + TRANSVERSE_MERCATOR = 6, + SINUSOIDAL = 7, + LAMBERT = 8, + LAMBERT_AZIMUTHAL = 9, + ALBERS_EQUAL_AREA_CONIC = 10, + MILLER_CYLINDRICAL = 11 + }; + + /** PTStitcher acceleration */ + enum PTStitcherAcceleration { + NO_SPEEDUP, + MAX_SPEEDUP, + MEDIUM_SPEEDUP // for projects with morphing. + }; + + /** Fileformat + */ + enum FileFormat { + JPEG = 0, + PNG, + TIFF, + TIFF_m, + TIFF_mask, + TIFF_multilayer, + TIFF_multilayer_mask, + PICT, + PSD, + PSD_m, + PSD_mask, + PAN, + IVR, + IVR_java, + VRML, + QTVR, + HDR, + HDR_m + }; + + /** output mode */ + enum OutputMode { + OUTPUT_LDR=0, + OUTPUT_HDR + }; + + /** blenders */ + enum BlendingMechanism { + NO_BLEND=0, + PTBLENDER_BLEND=1, + ENBLEND_BLEND=2, + SMARTBLEND_BLEND=3 + }; + + enum Remapper { + NONA=0, + PTMENDER + }; + + /** type of color correction + */ + enum ColorCorrection { NONE = 0, + BRIGHTNESS_COLOR, + BRIGHTNESS, + COLOR }; + + PanoramaOptions() + { + reset(); + }; + + void reset() + { + m_projectionFormat = EQUIRECTANGULAR; +#ifdef HasPANO13 + panoProjectionFeaturesQuery(m_projectionFormat, &m_projFeatures); +#endif + m_hfov = 360; + m_size = vigra::Size2D(3000, 1500); + m_roi = vigra::Rect2D(m_size); + outfile = "panorama.JPG"; + quality = 90; + tiff_saveROI = false; + tiffCompression = "NONE"; + colorCorrection = NONE; + colorReferenceImage = 0; + optimizeReferenceImage = 0; + gamma = 1.0; + interpolator = vigra_ext::INTERP_CUBIC; + featherWidth = 10; + outputFormat = JPEG; + remapAcceleration = MAX_SPEEDUP; + blendMode = NO_BLEND; + remapper = NONA; + saveCoordImgs = false; + huberSigma = 2; + photometricHuberSigma = 2/255.0; + photometricSymmetricError = false; + outputMode = OUTPUT_LDR; + outputEMoRParams.resize(5,0.0); + outputExposureValue = 0.0; + outputPixelType = ""; + } + virtual ~PanoramaOptions() {}; + + void printScriptLine(std::ostream & o,bool forPTOptimizer=false) const; + + /// return string name of output file format + static const std::string & getFormatName(FileFormat f); + + /** returns the FileFormat corrosponding to name. + * + * if name is not recognized, FileFormat::TIFF is returned + */ + static FileFormat getFormatFromName(const std::string & name); + + /** set panorama width + * keep the HFOV, if keepView=true + */ + void setWidth(unsigned int w, bool keepView = true); + + /* get panorama width */ + unsigned int getWidth() const + { + return m_size.x; + } + + /** set panorama height + * + * This changes the panorama vfov + */ + void setHeight(unsigned int h); + + /** get panorama height */ + unsigned int getHeight() const + { + return m_size.y; + } + + /// get size of output image + vigra::Size2D getSize() const + { + return m_size; + } + + const vigra::Rect2D & getROI() const + { return m_roi; } + void setROI(const vigra::Rect2D & val) + { m_roi = val; } + + /** set the Projection format and adjust the hfov/vfov + * if nessecary + */ + void setProjection(ProjectionFormat f); + + PanoramaOptions::ProjectionFormat getProjection() const + { + return m_projectionFormat; + }; + + /** Get the optional projection parameters */ + const std::vector<double> & getProjectionParameters() const; + + /** set the optional parameters (they need to be of the correct size) */ + void setProjectionParameters(const std::vector<double> & params); + + /** true, if FOV calcuations are supported for projection \p f */ + bool fovCalcSupported(ProjectionFormat f) const; + + /** set the horizontal field of view. + * also updates the image height (keep pano + * field of view similar.) + */ + void setHFOV(double h, bool keepView=true); + + double getHFOV() const + { + return m_hfov; + } + + void setVFOV(double v); + double getVFOV() const; + + /** get maximum possible hfov with current projection */ + double getMaxHFOV() const; + /** get maximum possible vfov with current projection */ + double getMaxVFOV() const; + + DestPanoImage getDestImage() const; + + const std::string & getOutputExtension(); + + // they are public, because they need to be set through + // get/setOptions in Panorama. + + std::string outfile; + FileFormat outputFormat; + // jpeg options + int quality; + // TIFF options + std::string tiffCompression; + bool tiff_saveROI; + + ColorCorrection colorCorrection; + unsigned int colorReferenceImage; + + // misc options + double gamma; + vigra_ext::Interpolator interpolator; + + unsigned int optimizeReferenceImage; + unsigned int featherWidth; + + PTStitcherAcceleration remapAcceleration; + BlendingMechanism blendMode; + Remapper remapper; + + bool saveCoordImgs; + + double huberSigma; + + double photometricHuberSigma; + double photometricSymmetricError; + + // modes related to high dynamic range output + OutputMode outputMode; + // select the exposure of the output images in LDR mode. + double outputExposureValue; + std::vector<float> outputEMoRParams; + // choose pixel type for output images. + std::string outputPixelType; + + +#ifdef HasPANO13 + pano_projection_features m_projFeatures; +#endif + +private: + static const std::string fileformatNames[]; + static const std::string fileformatExt[]; + double m_hfov; +// unsigned int m_width; +// unsigned int m_height; + ProjectionFormat m_projectionFormat; + + std::vector<double> m_projectionParams; + vigra::Size2D m_size; + vigra::Rect2D m_roi; +}; + + +} // namespace +#endif // _PANORAMAMEMENTO_H Copied: hugin/branches/ippei/src/hugin_base/panodata/PanoramaVariable.h (from rev 2045, hugin/branches/ippei/src/hugin_base/panodata/PanoramaMemento.h) =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/PanoramaVariable.h (rev 0) +++ hugin/branches/ippei/src/hugin_base/panodata/PanoramaVariable.h 2007-06-04 15:02:20 UTC (rev 2048) @@ -0,0 +1,190 @@ +// -*- c-basic-offset: 4 -*- +/** @file PanoramaVariable.h + * + * @author Pablo d'Angelo <pab...@we...> + * + * $Id: PanoramaMemento.h 1970 2007-04-18 22:26:56Z dangelo $ + * + * !! from PanoramaMemento.h 1970 + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _PANORAMAMEMENTO_H +#define _PANORAMAMEMENTO_H + + +#include <string> +#include <vector> +#include <map> +#include <algorithm> +#include <set> +#include <math.h> + +#ifdef HasPANO13 +extern "C" { + +#ifdef __INTEL__ +#define __INTELMEMO__ +#undef __INTEL__ +#endif + +#include "pano13/panorama.h" + +#ifdef __INTELMEMO__ +#define __INTEL__ +#undef __INTELMEMO__ +#endif + +// remove stupid #defines from the evil windows.h + +#ifdef DIFFERENCE +#undef DIFFERENCE +#endif + +#ifdef MIN +#undef MIN +#endif + +#ifdef MAX +#undef MAX +#endif + +#ifdef min +#undef min +#endif + +#ifdef max +#undef max +#endif +} +#endif + +#include "PT/PanoImage.h" + +#include "vigra_ext/Interpolators.h" + +namespace PT { + +/** a variable has a value and a name. + * + * linking is only supported by LinkedVariable, which + * is only used by Lens. + */ +class Variable +{ +public: + Variable(const std::string & name, double val = 0.0) + : name(name), value(val) + { }; + virtual ~Variable() {}; + + /// print this variable + virtual std::ostream & print(std::ostream & o) const; + + const std::string & getName() const + { return name; } + void setValue(double v) + { value = v; } + double getValue() const + { return value; } + +protected: + + std::string name; + double value; +}; + + + + +// a linked variable (which contains the link target explicitly +class LinkedVariable : public Variable +{ + LinkedVariable(const std::string & name, double val = 0.0, int link=-1) + : Variable(name, val), m_link(link) + { + } + + bool isLinked() const + { return m_link >= 0; } + int getLink() const + { return m_link; } + void setLink(int link) + { m_link = link; } + +protected: + int m_link; +}; + + + + + +/** A lens variable can be linked. + * + * It is only used in the lens class, not directly in the images. + */ +class LensVariable : public Variable +{ +public: + LensVariable(const std::string & name, double value, bool link=false) + : Variable(name, value), linked(link) + { }; + virtual ~LensVariable() {} + virtual std::ostream & printLink(std::ostream & o, unsigned int link) const; + + bool isLinked() const + { return linked; } + void setLinked(bool l=true) + { linked = l; } +private: + bool linked; +}; + + + + +/** functor to print a variable. */ +struct PrintVar : public std::unary_function<Variable, void> +{ + PrintVar(std::ostream & o) : os(o) { } + void operator() (Variable x) const { x.print(os) << " "; } + std::ostream& os; +}; + + + + + +typedef std::map<std::string,Variable> VariableMap; +typedef std::vector<VariableMap> VariableMapVector; +typedef std::map<std::string,LensVariable> LensVarMap; + +/** fill map with all image & lens variables */ +void fillVariableMap(VariableMap & vars); + +/** just lens variables */ +void fillLensVarMap(LensVarMap & vars); + +/** print a variable map to \p o */ +void printVariableMap(std::ostream & o, const VariableMap & vars); + + + + +} // namespace +#endif // _PANORAMAMEMENTO_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ip...@us...> - 2007-06-04 17:48:02
|
Revision: 2050 http://hugin.svn.sourceforge.net/hugin/?rev=2050&view=rev Author: ippei Date: 2007-06-04 10:47:55 -0700 (Mon, 04 Jun 2007) Log Message: ----------- fist step in panodata reorganisation Modified Paths: -------------- hugin/branches/ippei/src/hugin_base/panodata/Panorama.h hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h hugin/branches/ippei/src/hugin_base/panodata/PanoramaVariable.h Added Paths: ----------- hugin/branches/ippei/src/hugin_base/panodata/PanoramaDataLegacySupport.h Modified: hugin/branches/ippei/src/hugin_base/panodata/Panorama.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/Panorama.h 2007-06-04 16:41:51 UTC (rev 2049) +++ hugin/branches/ippei/src/hugin_base/panodata/Panorama.h 2007-06-04 17:47:55 UTC (rev 2050) @@ -37,118 +37,13 @@ class Matrix3; -namespace PT { -class Panorama; -class PanoCommand; -typedef std::set<unsigned int> UIntSet; -typedef std::vector<unsigned int> UIntVector; +namespace PT { -/// helper functions for parsing a script line -bool getPTParam(std::string & output, const std::string & line, const std::string & parameter); +class PanoramaObserver; -#if 0 -template <class T> -bool getParam(T & value, const std::string & line, const std::string & name) -{ - std::string s; - if (!getPTParam(s, line, name)) { - return false; - } - std::istringstream is(s); - is >> value; - return true; -} -#endif -template <class T> -bool getIntParam(T & value, const std::string & line, const std::string & name) -{ - std::string s; - if (!getPTParam(s, line, name)) { - return false; - } - std::istringstream is(s); - is >> value; - return true; -} - -bool readVar(Variable & var, int & link, const std::string & line); - -bool getPTStringParam(std::string & output, const std::string & line, - const std::string & parameter); - -bool getPTStringParamColon(std::string & output, const std::string & line, const std::string & parameter); - -bool getDoubleParam(double & d, const std::string & line, const std::string & name); - -bool getPTDoubleParam(double & value, int & link, - const std::string & line, const std::string & var); - - -/** this handler class will receive change events from the Panorama. - * - * Maybe a fine grained event interface is better, but it can be - * added later. - */ - -class PanoramaObserver -{ -public: - virtual ~PanoramaObserver() - { }; - /** Notification about a Panorama change. - * - * This function will always be called, even when the - * change could be handled by panoramaImageAdded() or - * other notify functions. - * - * This allows lazy observers to just listen to - * panoramaChanged(). - * - */ - virtual void panoramaChanged(Panorama &pano) - { DEBUG_DEBUG("Default panoramaChanged called"); }; - - /** notifies about changes to images - * - * Images might have been added/removed. to find out - * how many images are still there, use Panorama::getNrOfImages. - * - * @param pano the panorama object that changed - * @param changed set of changed images - * - */ - virtual void panoramaImagesChanged(Panorama &pano, const UIntSet & changed) - { DEBUG_DEBUG("DEFAULT handler method"); }; - - /** notification about a new image. - * - * It is called whenever an image has been added. - */ -// virtual void panoramaImageAdded(Panorama &pano, unsigned int imgNr) -// { DEBUG_WARN("DEFAULT handler method"); }; - - /** notifiy about the removal of an image. - * - * always called when an image is removed. - * Beware: the image might already destroyed when this is called. - */ -// virtual void panoramaImageRemoved(Panorama &pano, unsigned int imgNr) -// { DEBUG_WARN("DEFAULT handler method"); }; - - /** notify about an image change. - * - * This is called whenever the image (for example the filename) - * or something the image depends on (for example: Lens, Control - * Points) has changed. - */ -// virtual void panoramaImageChanged(Panorama &pano, unsigned int imgNr) -// { DEBUG_TRACE(""); }; -}; - - /** Model for a panorama. * * This class contains the properties of a panorama @@ -199,7 +94,7 @@ * implemented without too much pain. */ -class Panorama +class Panorama : PanoramaData, PanoramaDataLegacySupport, AppBase::Document { public: @@ -682,6 +577,8 @@ }; +// -- algorithms [TODO: move out!] -- + /** function to calculate the scaling factor so that the distances in the input image and panorama image are similar at the panorama center */ @@ -690,6 +587,8 @@ double calcMeanExposure(const Panorama & pano); + + // helper functions, workaround for gcc 3.3, which doesn't find // the map_get template functions. PT::LensVariable & map_get(PT::LensVarMap &m, const std::string & key); @@ -699,24 +598,57 @@ +// -- Parsing -- +/// helper functions for parsing a script line +bool getPTParam(std::string & output, const std::string & line, const std::string & parameter); -// -- from memento.h -- +#if 0 +template <class T> +bool getParam(T & value, const std::string & line, const std::string & name) +{ + std::string s; + if (!getPTParam(s, line, name)) { + return false; + } + std::istringstream is(s); + is >> value; + return true; +} +#endif +template <class T> +bool getIntParam(T & value, const std::string & line, const std::string & name) +{ + std::string s; + if (!getPTParam(s, line, name)) { + return false; + } + std::istringstream is(s); + is >> value; + return true; +} +bool readVar(Variable & var, int & link, const std::string & line); +bool getPTStringParam(std::string & output, const std::string & line, + const std::string & parameter); +bool getPTStringParamColon(std::string & output, const std::string & line, const std::string & parameter); +bool getDoubleParam(double & d, const std::string & line, const std::string & name); +bool getPTDoubleParam(double & value, int & link, + const std::string & line, const std::string & var); + typedef std::vector<PanoImage> ImageVector; typedef std::vector<std::set<std::string> > OptimizeVector; -class Panorama; /** Memento class for a Panorama object * * Holds the internal state of a Panorama. Modified: hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h 2007-06-04 16:41:51 UTC (rev 2049) +++ hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h 2007-06-04 17:47:55 UTC (rev 2050) @@ -1,10 +1,12 @@ // -*- c-basic-offset: 4 -*- -/** @file Panorama.h +/** @file PanoramaData.h * * @author Pablo d'Angelo <pab...@we...> * * $Id: Panorama.h 1947 2007-04-15 20:46:00Z dangelo $ * + * !! from Panorama.h 1947 + * * This is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either @@ -112,6 +114,22 @@ }; +/** Memento class for a PanoramaData object +* +* Preserves the internal state of a PanoramaData. +* Used when other objects need to get/set the state without +* knowing anything about the internals. +* +*/ +class PanoramaDataMemento +{ +public: + + virtual ~PanoramaMemento(); + + // virtual PanoramaMemento & operator=(const PanoramaMemento & o); + +}; @@ -190,8 +208,7 @@ // -- Observing -- -// - + /** add a panorama observer. * * It will recieve all change messages. @@ -238,12 +255,8 @@ virtual void markAsOptimized(bool optimized=true); -// -- Data Access -- -// query interface, used by the view to get information about -// the panorama. +// -- Data Access [TODO: clean up] -- -public: - /// number of images. virtual std::size_t getNrOfImages() const; @@ -298,7 +311,6 @@ /** returns the options for this panorama */ virtual const PanoramaOptions & getOptions() const; - // iterator like interface for the images and control points // ImageVector::const_iterator @@ -380,7 +392,6 @@ */ virtual unsigned int addLens(const Lens & lens); - /** Change the variable for a single lens * * updates a lens variable, copies it into @@ -389,7 +400,6 @@ */ virtual void updateLensVariable(unsigned int lensNr, const LensVariable &var); - /** update a lens * * Changes the lens variables in all images of this lens. @@ -402,7 +412,6 @@ */ virtual void removeLens(unsigned int lensNr); - /** remove unused lenses. * * some operations might create lenses that are not @@ -448,20 +457,18 @@ // -- script interface -- - -public: - /** parse optimzier output - * - * @param set of image numbers that where used during by - * printPanoramaScript(). - * @param vars will be set the the optimzied variables - * @param ctrlPoints will contain the controlpoints, with distance - * information - * - * @return false on error (could not read optimizer output, parse error) - */ - virtual void readOptimizerOutput(const UIntSet & imgs, VariableMapVector & vars, CPVector & ctrlPoints) const; + /** parse optimzier output + * + * @param set of image numbers that where used during by + * printPanoramaScript(). + * @param vars will be set the the optimzied variables + * @param ctrlPoints will contain the controlpoints, with distance + * information + * + * @return false on error (could not read optimizer output, parse error) + */ + virtual void readOptimizerOutput(const UIntSet & imgs, VariableMapVector & vars, CPVector & ctrlPoints) const; /// read after optimization, fills in control point errors. @@ -482,78 +489,7 @@ const UIntSet & imgs) const; - -// -- Algorithms to be modified. -- - -TODO: - - /** update control points distances. - * - * updates control distances and position in final panorama - * usually used to set the changes from the optimization. - * The control points must be the same as in - */ - virtual void updateCtrlPointErrors(const CPVector & controlPoints); - - /** update control points for a subset of images. - * - * Usually, the control point subset is created using subset() - * The number and ordering and control points must not be changed - * between the call to subset() and this function. - */ - void updateCtrlPointErrors(const UIntSet & imgs, const CPVector & cps); - - -// -- Algorithms to be moved out. -- - -TODO: - - /** calculates the horizontal and vertial FOV of the complete panorama - * - * @return HFOV,VFOV - */ - FDiff2D calcFOV() const; - - /** calculate the HFOV and height so that the whole input - * fits in into the output panorama */ - void fitPano(double & HFOV, double & height); - - /** calculate the optimal width for this panorama - * - * Optimal means that the pixel density at the panorama and - * image center of the image with the highest resolution - * are the same. - */ - unsigned calcOptimalWidth() const; - - /** calculate control point error distance statistics */ - void calcCtrlPntsErrorStats(double & min, double & max, double & mean, double & std, int imgNr=-1) const; - - /** calculate control point radial distance statistics. q10 and q90 are the 10% and 90% quantile */ - void calcCtrlPntsRadiStats(double & min, double & max, double & mean, double & var, - double & q10, double & q90, int imgNr=-1) const; - - - /** center panorama horizontically */ - void centerHorizontically(); - - /** rotate the complete panorama - * - * Will modify the position of all images. - */ - void rotate(double yaw, double pitch, double roll); - - /** rotate the complete panorama. - * - * Will modify the position of all images. - */ - void rotate(const Matrix3 & rot); - - /** try to automatically straighten the panorama */ - void straighten(); - - -// -- document interface (to be moved out) -- +// -- document interface [TODO: to be moved out] -- /** clear dirty flag. call after save */ void clearDirty() @@ -570,27 +506,7 @@ }; -/** Memento class for a PanoramaData object - * - * Preserves the internal state of a PanoramaData. - * Used when other objects need to get/set the state without - * knowing anything about the internals. - * - */ -class AbstractPanoramaMemento -{ -public: - - virtual ~PanoramaMemento(); - -// virtual PanoramaMemento & operator=(const PanoramaMemento & o); - -}; - - - - } // namespace Copied: hugin/branches/ippei/src/hugin_base/panodata/PanoramaDataLegacySupport.h (from rev 2049, hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h) =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/PanoramaDataLegacySupport.h (rev 0) +++ hugin/branches/ippei/src/hugin_base/panodata/PanoramaDataLegacySupport.h 2007-06-04 17:47:55 UTC (rev 2050) @@ -0,0 +1,123 @@ +// -*- c-basic-offset: 4 -*- +/** @file PanoramaDataLegacySupport.h + * + * @author Pablo d'Angelo <pab...@we...> + * + * $Id: Panorama.h 1947 2007-04-15 20:46:00Z dangelo $ + * + * !! from Panorama.h 1947 + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _PANORAMA_H +#define _PANORAMA_H + +#include "common/math.h" +#include "common/utils.h" + +#include <vector> +#include <set> +#include <sstream> + +#include "PT/PanoImage.h" +#include "PT/PanoramaMemento.h" + + + +namespace PT { + + +class PanoramaDataLegacySupport +{ +public: + + virtual ~PanoramaDataLegacySupport(); + + +// -- Algorithms to be modified. -- + + /** update control points distances. + * + * updates control distances and position in final panorama + * usually used to set the changes from the optimization. + * The control points must be the same as in + */ + virtual void updateCtrlPointErrors(const CPVector & controlPoints); + + /** update control points for a subset of images. + * + * Usually, the control point subset is created using subset() + * The number and ordering and control points must not be changed + * between the call to subset() and this function. + */ + void updateCtrlPointErrors(const UIntSet & imgs, const CPVector & cps); + + +// -- Algorithms to be moved out. -- + + /** calculates the horizontal and vertial FOV of the complete panorama + * + * @return HFOV,VFOV + */ + FDiff2D calcFOV() const; + + /** calculate the HFOV and height so that the whole input + * fits in into the output panorama */ + void fitPano(double & HFOV, double & height); + + /** calculate the optimal width for this panorama + * + * Optimal means that the pixel density at the panorama and + * image center of the image with the highest resolution + * are the same. + */ + unsigned calcOptimalWidth() const; + + /** calculate control point error distance statistics */ + void calcCtrlPntsErrorStats(double & min, double & max, double & mean, double & std, int imgNr=-1) const; + + /** calculate control point radial distance statistics. q10 and q90 are the 10% and 90% quantile */ + void calcCtrlPntsRadiStats(double & min, double & max, double & mean, double & var, + double & q10, double & q90, int imgNr=-1) const; + + /** center panorama horizontically */ + void centerHorizontically(); + + /** rotate the complete panorama + * + * Will modify the position of all images. + */ + void rotate(double yaw, double pitch, double roll); + + /** rotate the complete panorama. + * + * Will modify the position of all images. + */ + void rotate(const Matrix3 & rot); + + /** try to automatically straighten the panorama */ + void straighten(); + +} + + +} // namespace + + + + +#endif // _PANORAMA_H Modified: hugin/branches/ippei/src/hugin_base/panodata/PanoramaVariable.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/PanoramaVariable.h 2007-06-04 16:41:51 UTC (rev 2049) +++ hugin/branches/ippei/src/hugin_base/panodata/PanoramaVariable.h 2007-06-04 17:47:55 UTC (rev 2050) @@ -34,49 +34,7 @@ #include <set> #include <math.h> -#ifdef HasPANO13 -extern "C" { -#ifdef __INTEL__ -#define __INTELMEMO__ -#undef __INTEL__ -#endif - -#include "pano13/panorama.h" - -#ifdef __INTELMEMO__ -#define __INTEL__ -#undef __INTELMEMO__ -#endif - -// remove stupid #defines from the evil windows.h - -#ifdef DIFFERENCE -#undef DIFFERENCE -#endif - -#ifdef MIN -#undef MIN -#endif - -#ifdef MAX -#undef MAX -#endif - -#ifdef min -#undef min -#endif - -#ifdef max -#undef max -#endif -} -#endif - -#include "PT/PanoImage.h" - -#include "vigra_ext/Interpolators.h" - namespace PT { /** a variable has a value and a name. @@ -132,8 +90,6 @@ - - /** A lens variable can be linked. * * It is only used in the lens class, not directly in the images. @@ -161,15 +117,12 @@ /** functor to print a variable. */ struct PrintVar : public std::unary_function<Variable, void> { - PrintVar(std::ostream & o) : os(o) { } - void operator() (Variable x) const { x.print(os) << " "; } + PrintVar(std::ostream & o) : os(o) { }; + void operator() (Variable x) const { x.print(os) << " "; }; std::ostream& os; }; - - - typedef std::map<std::string,Variable> VariableMap; typedef std::vector<VariableMap> VariableMapVector; typedef std::map<std::string,LensVariable> LensVarMap; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ip...@us...> - 2007-06-04 18:10:09
|
Revision: 2051 http://hugin.svn.sourceforge.net/hugin/?rev=2051&view=rev Author: ippei Date: 2007-06-04 11:10:04 -0700 (Mon, 04 Jun 2007) Log Message: ----------- fist step in panodata reorganisation Modified Paths: -------------- hugin/branches/ippei/src/hugin_base/panodata/PanoImage.h hugin/branches/ippei/src/hugin_base/panodata/Panorama.h Added Paths: ----------- hugin/branches/ippei/src/hugin_base/panodata/DestPanoImage.h hugin/branches/ippei/src/hugin_base/panodata/SrcPanoImage.h Copied: hugin/branches/ippei/src/hugin_base/panodata/DestPanoImage.h (from rev 2045, hugin/branches/ippei/src/hugin_base/panodata/PanoImage.h) =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/DestPanoImage.h (rev 0) +++ hugin/branches/ippei/src/hugin_base/panodata/DestPanoImage.h 2007-06-04 18:10:04 UTC (rev 2051) @@ -0,0 +1,107 @@ +// -*- c-basic-offset: 4 -*- + +/** @file PanoImage.h + * + * @brief implementation of HFOVDialog Class + * + * @author Pablo d'Angelo <pab...@we...> + * + * $Id: PanoImage.h 1970 2007-04-18 22:26:56Z dangelo $ + * + * !! from PanoImage.h 1970 + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef PANOIMAGE_H +#define PANOIMAGE_H + +#include <iostream> +#include <vector> +#include <common/utils.h> +#include <common/math.h> +#include <vigra/diff2d.hxx> + +namespace PT { + +/** Holds information about the destination image. + */ +class DestPanoImage +{ +public: + enum Projection { RECTILINEAR = 0, + CYLINDRICAL = 1, + EQUIRECTANGULAR = 2, + FULL_FRAME_FISHEYE = 3}; + + DestPanoImage() + { + m_proj = EQUIRECTANGULAR; + m_hfov = 360; + m_size = vigra::Size2D(360,180); + m_roi = vigra::Rect2D(m_size); + } + + DestPanoImage(Projection proj, double hfov, vigra::Size2D sz) + : m_proj(proj), m_hfov(hfov), m_size(sz), m_roi(sz) + { + } + bool horizontalWarpNeeded() + { + switch (m_proj) + { + case CYLINDRICAL: + case EQUIRECTANGULAR: + if (m_hfov == 360) return true; + case FULL_FRAME_FISHEYE: + case RECTILINEAR: + default: + break; + } + return false; + } + // data accessors + const Projection & getProjection() const + { return m_proj; } + void setProjection(const Projection & val) + { m_proj = val; } + + const double & getHFOV() const + { return m_hfov; } + void setHFOV(const double & val) + { m_hfov = val; } + + const vigra::Size2D & getSize() const + { return m_size; } + void setSize(const vigra::Size2D & val) + { m_size = val; } + + const vigra::Rect2D & getROI() const + { return m_roi; } + void setROI(const vigra::Rect2D & val) + { m_roi = val; } + +private: + Projection m_proj; + double m_hfov; + vigra::Size2D m_size; + vigra::Rect2D m_roi; +}; + + +} // namespace + +#endif // PANOIMAGE_H Modified: hugin/branches/ippei/src/hugin_base/panodata/PanoImage.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/PanoImage.h 2007-06-04 17:47:55 UTC (rev 2050) +++ hugin/branches/ippei/src/hugin_base/panodata/PanoImage.h 2007-06-04 18:10:04 UTC (rev 2051) @@ -36,11 +36,11 @@ namespace PT { class Panorama; + /** optimization & stitching options. */ -class ImageOptions { +struct ImageOptions { -public: ImageOptions() : featherWidth(10), ignoreFrameWidth(0), @@ -61,7 +61,7 @@ /// Morph-to-fit using control points. bool morph; - // crop parameters + // crop parameters bool docrop; bool autoCenterCrop; vigra::Rect2D cropRect; @@ -85,538 +85,79 @@ -/** description of a source pano image... +/** This class holds an source image. * - * In the long term, this simplified class will replace - * PanoImage and Image options and the variables array. + * It contains information about its settings for the panorama. + * + * An image should not depend on the panorama. */ -class SrcPanoImage +class PanoImage { public: - - enum Projection { RECTILINEAR = 0, - PANORAMIC = 1, - CIRCULAR_FISHEYE = 2, - FULL_FRAME_FISHEYE = 3, - EQUIRECTANGULAR = 4 }; - - enum CropMode { NO_CROP=0, - CROP_RECTANGLE=1, - CROP_CIRCLE=2 }; - - /// vignetting correction mode (bitflags, no real enum) - enum VignettingCorrMode { - VIGCORR_NONE = 0, ///< no vignetting correction - VIGCORR_RADIAL = 1, ///< radial vignetting correction - VIGCORR_FLATFIELD = 2, ///< flatfield correction - VIGCORR_DIV = 4 ///< correct by division. - }; - - enum ResponseType { - RESPONSE_EMOR=0, ///< empirical model of response - RESPONSE_LINEAR, ///< linear response - RESPONSE_GAMMA, ///< a simple gamma response curve - RESPONSE_FILE, ///< load response curve from file (not implemented yet) - RESPONSE_ICC ///< use ICC for transformation into linear data (not implemented yet) - }; - - SrcPanoImage() + PanoImage() { - setDefaults(); - } - - SrcPanoImage(const std::string &filename, vigra::Size2D size) - { - setDefaults(); - m_filename = filename; - m_size = size ; - m_cropRect = vigra::Rect2D(size); + width=0; + height=0; + lensNr=0; }; - bool operator==(const SrcPanoImage & other) const; + PanoImage(const std::string &filename, int width,int height, + int lens); - void setDefaults() - { - m_proj = RECTILINEAR; - m_hfov = 50; - m_roll = 0; - m_pitch = 0; - m_yaw = 0; +// PanoImage(const std::string & filename); + // create from xml node +// PanoImage(QDomNode & node); - m_responseType = RESPONSE_EMOR; - m_emorParams.resize(5); - for (unsigned i=0; i < 5; i++) { - m_emorParams[i] = 0; - } - m_exposure = 1; - m_wbRed = 1; - m_wbBlue = 1; + virtual ~PanoImage(); - m_gamma = 1; + virtual const char * isA() const { return "PanoImage"; }; - m_radialDist.resize(4); - m_radialDistRed.resize(4); - m_radialDistBlue.resize(4); - for (unsigned i=0; i < 3; i++) { - m_radialDist[i] = 0; - m_radialDistRed[i] = 0; - m_radialDistBlue[i] = 0; - } - m_radialDist[3] = 1; - m_radialDistRed[3] = 1; - m_radialDistBlue[3] = 1; - m_centerShift.x = 0; - m_centerShift.y = 0; - m_shear.x = 0; - m_shear.y = 0; + std::string getFilename() const + { return filename; } - m_crop = NO_CROP; + void setFilename(std::string fn) + { filename = fn; } - m_vigCorrMode = VIGCORR_RADIAL|VIGCORR_DIV; - m_radialVigCorrCoeff.resize(4); - m_radialVigCorrCoeff[0] = 1; - for (unsigned i=1; i < 4; i++) { - m_radialVigCorrCoeff[i] = 0; - } + const ImageOptions & getOptions() const + { return options; } - m_exifCropFactor = 0; - m_exifFocalLength = 0; + void setOptions(const ImageOptions & opt) + { options = opt; } - m_lensNr = 0; - m_featherWidth = 10; - m_morph = false; - } + unsigned int getHeight() const + { return height; } + unsigned int getWidth() const + { return width; } - /** "resize" image, - * adjusts all distortion coefficients for usage with a source image - * of size @p size - */ - void resize(const vigra::Size2D & size); + void setLensNr(unsigned int l) + { lensNr = l; } + unsigned int getLensNr() const + { return lensNr; } + void setSize(const vigra::Size2D & sz) + { width =sz.x; height = sz.y; } - /** check if a coordinate is inside the source image - */ - bool isInside(vigra::Point2D p) const - { - switch(m_crop) { - case NO_CROP: - case CROP_RECTANGLE: - return m_cropRect.contains(p); - case CROP_CIRCLE: - { - if (0 > p.x || 0 > p.y || p.x >= m_size.x || p.y >= m_size.y) { - // outside image - return false; - } - FDiff2D cropCenter; - cropCenter.x = m_cropRect.left() + m_cropRect.width()/2.0; - cropCenter.y = m_cropRect.top() + m_cropRect.height()/2.0; - double radius2 = std::min(m_cropRect.width()/2.0, m_cropRect.height()/2.0); - radius2 = radius2 * radius2; - FDiff2D pf = FDiff2D(p) - cropCenter; - return (radius2 > pf.x*pf.x+pf.y*pf.y ); - } - } - // this should never be reached.. - return false; - } + void setFeatherWidth(unsigned int w) + { options.featherWidth = w; }; - bool horizontalWarpNeeded(); - - // property accessors - - const std::string & getFilename() const - { return m_filename; } - void setFilename(const std::string & file) - { m_filename = file; } - - const vigra::Size2D & getSize() const - { return m_size; } - void setSize(const vigra::Size2D & val) - { m_size = val; } - - const Projection & getProjection() const - { return m_proj; } - void setProjection(const Projection & val) - { m_proj = val; } - - const double & getHFOV() const - { return m_hfov; } - void setHFOV(const double & val) - { m_hfov = val; } - - bool getCorrectTCA() const - { - bool nr = (m_radialDistRed[0] == 0.0 && m_radialDistRed[1] == 0.0 && - m_radialDistRed[2] == 0.0 && m_radialDistRed[3] == 1); - bool nb = (m_radialDistBlue[0] == 0.0 && m_radialDistBlue[1] == 0.0 && - m_radialDistBlue[2] == 0.0 && m_radialDistBlue[3] == 1); - return !(nr && nb); - } - - const std::vector<double> & getRadialDistortion() const - { return m_radialDist; } - void setRadialDistortion(const std::vector<double> & val) - { - DEBUG_ASSERT(val.size() == 4); - m_radialDist = val; - } - const std::vector<double> & getRadialDistortionRed() const - { return m_radialDistRed; } - void setRadialDistortionRed(const std::vector<double> & val) - { - DEBUG_ASSERT(val.size() == 4); - m_radialDistRed = val; - } - const std::vector<double> & getRadialDistortionBlue() const - { return m_radialDistBlue; } - void setRadialDistortionBlue(const std::vector<double> & val) - { - DEBUG_ASSERT(val.size() == 4); - m_radialDistBlue = val; - } - - const FDiff2D & getRadialDistortionCenterShift() const - { return m_centerShift; } - void setRadialDistortionCenterShift(const FDiff2D & val) - { m_centerShift = val; } - - FDiff2D getRadialDistortionCenter() const - { return FDiff2D(m_size)/2.0 + m_centerShift; } - - const FDiff2D & getShear() const - { return m_shear; } - void setShear(const FDiff2D & val) - { m_shear = val; } - - int getVigCorrMode() const - { return m_vigCorrMode; } - void setVigCorrMode(const int & val) - { m_vigCorrMode = val; } - - const std::string & getFlatfieldFilename() const - { return m_flatfield; } - void setFlatfieldFilename(const std::string & val) - { m_flatfield = val; } - - const std::vector<double> & getRadialVigCorrCoeff() const - { return m_radialVigCorrCoeff; } - void setRadialVigCorrCoeff(const std::vector<double> & val) - { - DEBUG_ASSERT(val.size() == 4); - m_radialVigCorrCoeff = val; - } - - const FDiff2D & getRadialVigCorrCenterShift() const - { return m_radialVigCorrCenterShift; } - void setRadialVigCorrCenterShift(const FDiff2D & val) - { m_radialVigCorrCenterShift = val; } - - FDiff2D getRadialVigCorrCenter() const - { return (FDiff2D(m_size)-FDiff2D(1,1))/2.0 + m_radialVigCorrCenterShift; } - - int getLensNr() const - { return m_lensNr; } - void setLensNr(const int & val) - { m_lensNr = val; } - - CropMode getCropMode() const - { return m_crop; } - void setCropMode(CropMode val) - { - m_crop = val; - if (m_crop == NO_CROP) { - m_cropRect = vigra::Rect2D(m_size); - } - } - - const vigra::Rect2D & getCropRect() const - { return m_cropRect; } - void setCropRect(const vigra::Rect2D & val) - { m_cropRect = val; } - - const double & getRoll() const - { return m_roll; } - void setRoll(const double & val) - { m_roll = val; } - const double & getPitch() const - { return m_pitch; } - void setPitch(const double & val) - { m_pitch = val; } - const double & getYaw() const - { return m_yaw; } - void setYaw(const double & val) - { m_yaw = val; } - - /// get the exposure factor - double getExposure() const - { return 1.0/pow(2.0, m_exposure); } - void setExposure(const double & val) - { m_exposure = log2(1/val); } - - /// get the exposure value (log2 of inverse exposure factor) - double getExposureValue() const - { return m_exposure; } - void setExposureValue(const double & val) - { m_exposure = val; } - - double getGamma() const - { return m_gamma; } - void setGamma(double val) - { m_gamma = val; } - - double getWhiteBalanceRed() const - { return m_wbRed; } - void setWhiteBalanceRed(double val) - { m_wbRed = val; } - double getWhiteBalanceBlue() const - { return m_wbBlue; } - void setWhiteBalanceBlue(double val) - { m_wbBlue = val; } - - ResponseType getResponseType() const - { return m_responseType; } - void setResponseType(ResponseType val) - { m_responseType = val; } - - const std::vector<float> & getEMoRParams() const - { return m_emorParams; } - void setEMoRParams(const std::vector<float> & val) - { m_emorParams = val; } - - - const std::string & getExifModel() const - { return m_exifModel; } - void setExifModel(const std::string & val) - { m_exifModel = val; } - - const std::string & getExifMake() const - { return m_exifMake; } - void setExifMake(const std::string & val) - { m_exifMake = val; } - - const double & getExifCropFactor() const - { return m_exifCropFactor; } - void setExifCropFactor(const double & val) - { m_exifCropFactor = val; } - - const double & getExifFocalLength() const - { return m_exifFocalLength; } - void setExifFocalLength(const double & val) - { m_exifFocalLength = val; } - - double getVar(const std::string & name) const; - void setVar(const std::string & name, double val); - private: - std::string m_filename; -// VariableVector m_vars; - vigra::Size2D m_size; + /// common init for all constructors + void init(); + /// read image info (size, exif header) + bool readImageInformation(); - Projection m_proj; - double m_hfov; + // image properties needed by Panorama tools. - ResponseType m_responseType; - std::vector<float> m_emorParams; - double m_exposure; - double m_gamma; - double m_wbRed, m_wbBlue; + std::string filename; + int height,width; - // orientation in degrees - double m_roll; - double m_pitch; - double m_yaw; - - // radial lens distortion - std::vector<double> m_radialDist; - // radial lens distortion (red, blue channel), for TCA correction - std::vector<double> m_radialDistRed; - std::vector<double> m_radialDistBlue; - // Center shift - FDiff2D m_centerShift; - // shear - FDiff2D m_shear; - - // crop description - CropMode m_crop; - vigra::Rect2D m_cropRect; - - int m_vigCorrMode; - // coefficients for vignetting correction (even degrees: 0,2,4,6, ...) - std::string m_flatfield; - std::vector<double> m_radialVigCorrCoeff; - FDiff2D m_radialVigCorrCenterShift; - - // linear pixel transform - std::vector<double> m_ka; - std::vector<double> m_kb; - - - // store camera information from exif tags... - std::string m_exifModel; - std::string m_exifMake; - double m_exifCropFactor; - double m_exifFocalLength; - - unsigned m_lensNr; - // - // panotools options - // - // u10 specify width of feather for stitching. default:10 - unsigned int m_featherWidth; - // Morph-to-fit using control points. - bool m_morph; + bool imageRead; + ImageOptions options; + // the lens of this image + unsigned int lensNr; }; -/** try to fill out information about the image, by examining the exif data - * focalLength and cropFactor will be updated with the ones read from the exif data - * If no or not enought exif data was found and valid given focalLength and cropFactor - * settings where provided, they will be used for computation of the HFOV. - */ -bool initImageFromFile(SrcPanoImage & img, double & focalLength, double & cropFactor); -/** calculate hfov of an image given focal length, image size and crop factor */ -double calcHFOV(SrcPanoImage::Projection proj, double fl, double crop, vigra::Size2D imageSize); - -/** calcualte focal length, given crop factor and hfov */ -double calcFocalLength(SrcPanoImage::Projection proj, double hfov, double crop, vigra::Size2D imageSize); - -/** Holds information about the destination image. - */ -class DestPanoImage -{ -public: - enum Projection { RECTILINEAR = 0, - CYLINDRICAL = 1, - EQUIRECTANGULAR = 2, - FULL_FRAME_FISHEYE = 3}; - - DestPanoImage() - { - m_proj = EQUIRECTANGULAR; - m_hfov = 360; - m_size = vigra::Size2D(360,180); - m_roi = vigra::Rect2D(m_size); - } - - DestPanoImage(Projection proj, double hfov, vigra::Size2D sz) - : m_proj(proj), m_hfov(hfov), m_size(sz), m_roi(sz) - { - } - bool horizontalWarpNeeded() - { - switch (m_proj) - { - case CYLINDRICAL: - case EQUIRECTANGULAR: - if (m_hfov == 360) return true; - case FULL_FRAME_FISHEYE: - case RECTILINEAR: - default: - break; - } - return false; - } - // data accessors - const Projection & getProjection() const - { return m_proj; } - void setProjection(const Projection & val) - { m_proj = val; } - - const double & getHFOV() const - { return m_hfov; } - void setHFOV(const double & val) - { m_hfov = val; } - - const vigra::Size2D & getSize() const - { return m_size; } - void setSize(const vigra::Size2D & val) - { m_size = val; } - - const vigra::Rect2D & getROI() const - { return m_roi; } - void setROI(const vigra::Rect2D & val) - { m_roi = val; } - -private: - Projection m_proj; - double m_hfov; - vigra::Size2D m_size; - vigra::Rect2D m_roi; -}; - - /** This class holds an source image. - * - * It contains information about its settings for the panorama. - * - * An image should not depend on the panorama. - */ - class PanoImage - { - public: - PanoImage() - { - width=0; - height=0; - lensNr=0; - }; - - PanoImage(const std::string &filename, int width,int height, - int lens); - -// PanoImage(const std::string & filename); - // create from xml node -// PanoImage(QDomNode & node); - - virtual ~PanoImage(); - - virtual const char * isA() const { return "PanoImage"; }; - - std::string getFilename() const - { return filename; } - - void setFilename(std::string fn) - { filename = fn; } - - const ImageOptions & getOptions() const - { return options; } - - void setOptions(const ImageOptions & opt) - { options = opt; } - - unsigned int getHeight() const - { return height; } - unsigned int getWidth() const - { return width; } - - void setLensNr(unsigned int l) - { lensNr = l; } - unsigned int getLensNr() const - { return lensNr; } - - void setSize(const vigra::Size2D & sz) - { width =sz.x; height = sz.y; } - - void setFeatherWidth(unsigned int w) - { options.featherWidth = w; } - - private: - /// common init for all constructors - void init(); - /// read image info (size, exif header) - bool readImageInformation(); - - // image properties needed by Panorama tools. - - std::string filename; - int height,width; - - bool imageRead; - ImageOptions options; - // the lens of this image - unsigned int lensNr; - }; - } // namespace #endif // PANOIMAGE_H Modified: hugin/branches/ippei/src/hugin_base/panodata/Panorama.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/Panorama.h 2007-06-04 17:47:55 UTC (rev 2050) +++ hugin/branches/ippei/src/hugin_base/panodata/Panorama.h 2007-06-04 18:10:04 UTC (rev 2051) @@ -598,7 +598,7 @@ -// -- Parsing -- +// -- Parsing [TODO: move out] -- /// helper functions for parsing a script line bool getPTParam(std::string & output, const std::string & line, const std::string & parameter); Copied: hugin/branches/ippei/src/hugin_base/panodata/SrcPanoImage.h (from rev 2045, hugin/branches/ippei/src/hugin_base/panodata/PanoImage.h) =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/SrcPanoImage.h (rev 0) +++ hugin/branches/ippei/src/hugin_base/panodata/SrcPanoImage.h 2007-06-04 18:10:04 UTC (rev 2051) @@ -0,0 +1,445 @@ +// -*- c-basic-offset: 4 -*- + +/** @file PanoImage.h + * + * @brief + * + * @author Pablo d'Angelo <pab...@we...> + * + * !! from PanoImage.h 1970 + * + * $Id: PanoImage.h 1970 2007-04-18 22:26:56Z dangelo $ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef PANOIMAGE_H +#define PANOIMAGE_H + +#include <iostream> +#include <vector> +#include <common/utils.h> +#include <common/math.h> +#include <vigra/diff2d.hxx> + +namespace PT { + +class Panorama; + + +/** description of a source pano image... + * + * In the long term, this simplified class will replace + * PanoImage and Image options and the variables array. + */ +class SrcPanoImage +{ +public: + + enum Projection { RECTILINEAR = 0, + PANORAMIC = 1, + CIRCULAR_FISHEYE = 2, + FULL_FRAME_FISHEYE = 3, + EQUIRECTANGULAR = 4 }; + + enum CropMode { NO_CROP=0, + CROP_RECTANGLE=1, + CROP_CIRCLE=2 }; + + /// vignetting correction mode (bitflags, no real enum) + enum VignettingCorrMode { + VIGCORR_NONE = 0, ///< no vignetting correction + VIGCORR_RADIAL = 1, ///< radial vignetting correction + VIGCORR_FLATFIELD = 2, ///< flatfield correction + VIGCORR_DIV = 4 ///< correct by division. + }; + + enum ResponseType { + RESPONSE_EMOR=0, ///< empirical model of response + RESPONSE_LINEAR, ///< linear response + RESPONSE_GAMMA, ///< a simple gamma response curve + RESPONSE_FILE, ///< load response curve from file (not implemented yet) + RESPONSE_ICC ///< use ICC for transformation into linear data (not implemented yet) + }; + + SrcPanoImage() + { + setDefaults(); + } + + SrcPanoImage(const std::string &filename, vigra::Size2D size) + { + setDefaults(); + m_filename = filename; + m_size = size ; + m_cropRect = vigra::Rect2D(size); + }; + + bool operator==(const SrcPanoImage & other) const; + + void setDefaults() + { + m_proj = RECTILINEAR; + m_hfov = 50; + m_roll = 0; + m_pitch = 0; + m_yaw = 0; + + m_responseType = RESPONSE_EMOR; + m_emorParams.resize(5); + for (unsigned i=0; i < 5; i++) { + m_emorParams[i] = 0; + } + m_exposure = 1; + m_wbRed = 1; + m_wbBlue = 1; + + m_gamma = 1; + + m_radialDist.resize(4); + m_radialDistRed.resize(4); + m_radialDistBlue.resize(4); + for (unsigned i=0; i < 3; i++) { + m_radialDist[i] = 0; + m_radialDistRed[i] = 0; + m_radialDistBlue[i] = 0; + } + m_radialDist[3] = 1; + m_radialDistRed[3] = 1; + m_radialDistBlue[3] = 1; + m_centerShift.x = 0; + m_centerShift.y = 0; + m_shear.x = 0; + m_shear.y = 0; + + m_crop = NO_CROP; + + m_vigCorrMode = VIGCORR_RADIAL|VIGCORR_DIV; + m_radialVigCorrCoeff.resize(4); + m_radialVigCorrCoeff[0] = 1; + for (unsigned i=1; i < 4; i++) { + m_radialVigCorrCoeff[i] = 0; + } + + m_exifCropFactor = 0; + m_exifFocalLength = 0; + + m_lensNr = 0; + m_featherWidth = 10; + m_morph = false; + } + + /** "resize" image, + * adjusts all distortion coefficients for usage with a source image + * of size @p size + */ + void resize(const vigra::Size2D & size); + + + /** check if a coordinate is inside the source image + */ + bool isInside(vigra::Point2D p) const + { + switch(m_crop) { + case NO_CROP: + case CROP_RECTANGLE: + return m_cropRect.contains(p); + case CROP_CIRCLE: + { + if (0 > p.x || 0 > p.y || p.x >= m_size.x || p.y >= m_size.y) { + // outside image + return false; + } + FDiff2D cropCenter; + cropCenter.x = m_cropRect.left() + m_cropRect.width()/2.0; + cropCenter.y = m_cropRect.top() + m_cropRect.height()/2.0; + double radius2 = std::min(m_cropRect.width()/2.0, m_cropRect.height()/2.0); + radius2 = radius2 * radius2; + FDiff2D pf = FDiff2D(p) - cropCenter; + return (radius2 > pf.x*pf.x+pf.y*pf.y ); + } + } + // this should never be reached.. + return false; + } + + bool horizontalWarpNeeded(); + + // property accessors + + const std::string & getFilename() const + { return m_filename; } + void setFilename(const std::string & file) + { m_filename = file; } + + const vigra::Size2D & getSize() const + { return m_size; } + void setSize(const vigra::Size2D & val) + { m_size = val; } + + const Projection & getProjection() const + { return m_proj; } + void setProjection(const Projection & val) + { m_proj = val; } + + const double & getHFOV() const + { return m_hfov; } + void setHFOV(const double & val) + { m_hfov = val; } + + bool getCorrectTCA() const + { + bool nr = (m_radialDistRed[0] == 0.0 && m_radialDistRed[1] == 0.0 && + m_radialDistRed[2] == 0.0 && m_radialDistRed[3] == 1); + bool nb = (m_radialDistBlue[0] == 0.0 && m_radialDistBlue[1] == 0.0 && + m_radialDistBlue[2] == 0.0 && m_radialDistBlue[3] == 1); + return !(nr && nb); + } + + const std::vector<double> & getRadialDistortion() const + { return m_radialDist; } + void setRadialDistortion(const std::vector<double> & val) + { + DEBUG_ASSERT(val.size() == 4); + m_radialDist = val; + } + const std::vector<double> & getRadialDistortionRed() const + { return m_radialDistRed; } + void setRadialDistortionRed(const std::vector<double> & val) + { + DEBUG_ASSERT(val.size() == 4); + m_radialDistRed = val; + } + const std::vector<double> & getRadialDistortionBlue() const + { return m_radialDistBlue; } + void setRadialDistortionBlue(const std::vector<double> & val) + { + DEBUG_ASSERT(val.size() == 4); + m_radialDistBlue = val; + } + + const FDiff2D & getRadialDistortionCenterShift() const + { return m_centerShift; } + void setRadialDistortionCenterShift(const FDiff2D & val) + { m_centerShift = val; } + + FDiff2D getRadialDistortionCenter() const + { return FDiff2D(m_size)/2.0 + m_centerShift; } + + const FDiff2D & getShear() const + { return m_shear; } + void setShear(const FDiff2D & val) + { m_shear = val; } + + int getVigCorrMode() const + { return m_vigCorrMode; } + void setVigCorrMode(const int & val) + { m_vigCorrMode = val; } + + const std::string & getFlatfieldFilename() const + { return m_flatfield; } + void setFlatfieldFilename(const std::string & val) + { m_flatfield = val; } + + const std::vector<double> & getRadialVigCorrCoeff() const + { return m_radialVigCorrCoeff; } + void setRadialVigCorrCoeff(const std::vector<double> & val) + { + DEBUG_ASSERT(val.size() == 4); + m_radialVigCorrCoeff = val; + } + + const FDiff2D & getRadialVigCorrCenterShift() const + { return m_radialVigCorrCenterShift; } + void setRadialVigCorrCenterShift(const FDiff2D & val) + { m_radialVigCorrCenterShift = val; } + + FDiff2D getRadialVigCorrCenter() const + { return (FDiff2D(m_size)-FDiff2D(1,1))/2.0 + m_radialVigCorrCenterShift; } + + int getLensNr() const + { return m_lensNr; } + void setLensNr(const int & val) + { m_lensNr = val; } + + CropMode getCropMode() const + { return m_crop; } + void setCropMode(CropMode val) + { + m_crop = val; + if (m_crop == NO_CROP) { + m_cropRect = vigra::Rect2D(m_size); + } + } + + const vigra::Rect2D & getCropRect() const + { return m_cropRect; } + void setCropRect(const vigra::Rect2D & val) + { m_cropRect = val; } + + const double & getRoll() const + { return m_roll; } + void setRoll(const double & val) + { m_roll = val; } + const double & getPitch() const + { return m_pitch; } + void setPitch(const double & val) + { m_pitch = val; } + const double & getYaw() const + { return m_yaw; } + void setYaw(const double & val) + { m_yaw = val; } + + /// get the exposure factor + double getExposure() const + { return 1.0/pow(2.0, m_exposure); } + void setExposure(const double & val) + { m_exposure = log2(1/val); } + + /// get the exposure value (log2 of inverse exposure factor) + double getExposureValue() const + { return m_exposure; } + void setExposureValue(const double & val) + { m_exposure = val; } + + double getGamma() const + { return m_gamma; } + void setGamma(double val) + { m_gamma = val; } + + double getWhiteBalanceRed() const + { return m_wbRed; } + void setWhiteBalanceRed(double val) + { m_wbRed = val; } + double getWhiteBalanceBlue() const + { return m_wbBlue; } + void setWhiteBalanceBlue(double val) + { m_wbBlue = val; } + + ResponseType getResponseType() const + { return m_responseType; } + void setResponseType(ResponseType val) + { m_responseType = val; } + + const std::vector<float> & getEMoRParams() const + { return m_emorParams; } + void setEMoRParams(const std::vector<float> & val) + { m_emorParams = val; } + + + const std::string & getExifModel() const + { return m_exifModel; } + void setExifModel(const std::string & val) + { m_exifModel = val; } + + const std::string & getExifMake() const + { return m_exifMake; } + void setExifMake(const std::string & val) + { m_exifMake = val; } + + const double & getExifCropFactor() const + { return m_exifCropFactor; } + void setExifCropFactor(const double & val) + { m_exifCropFactor = val; } + + const double & getExifFocalLength() const + { return m_exifFocalLength; } + void setExifFocalLength(const double & val) + { m_exifFocalLength = val; } + + double getVar(const std::string & name) const; + void setVar(const std::string & name, double val); + +private: + std::string m_filename; +// VariableVector m_vars; + vigra::Size2D m_size; + + Projection m_proj; + double m_hfov; + + ResponseType m_responseType; + std::vector<float> m_emorParams; + double m_exposure; + double m_gamma; + double m_wbRed, m_wbBlue; + + // orientation in degrees + double m_roll; + double m_pitch; + double m_yaw; + + // radial lens distortion + std::vector<double> m_radialDist; + // radial lens distortion (red, blue channel), for TCA correction + std::vector<double> m_radialDistRed; + std::vector<double> m_radialDistBlue; + // Center shift + FDiff2D m_centerShift; + // shear + FDiff2D m_shear; + + // crop description + CropMode m_crop; + vigra::Rect2D m_cropRect; + + int m_vigCorrMode; + // coefficients for vignetting correction (even degrees: 0,2,4,6, ...) + std::string m_flatfield; + std::vector<double> m_radialVigCorrCoeff; + FDiff2D m_radialVigCorrCenterShift; + + // linear pixel transform + std::vector<double> m_ka; + std::vector<double> m_kb; + + + // store camera information from exif tags... + std::string m_exifModel; + std::string m_exifMake; + double m_exifCropFactor; + double m_exifFocalLength; + + unsigned m_lensNr; + // + // panotools options + // + // u10 specify width of feather for stitching. default:10 + unsigned int m_featherWidth; + // Morph-to-fit using control points. + bool m_morph; +}; + + + +/** try to fill out information about the image, by examining the exif data + * focalLength and cropFactor will be updated with the ones read from the exif data + * If no or not enought exif data was found and valid given focalLength and cropFactor + * settings where provided, they will be used for computation of the HFOV. + */ +bool initImageFromFile(SrcPanoImage & img, double & focalLength, double & cropFactor); + +/** calculate hfov of an image given focal length, image size and crop factor */ +double calcHFOV(SrcPanoImage::Projection proj, double fl, double crop, vigra::Size2D imageSize); + +/** calcualte focal length, given crop factor and hfov */ +double calcFocalLength(SrcPanoImage::Projection proj, double hfov, double crop, vigra::Size2D imageSize); + + + +} // namespace + +#endif // PANOIMAGE_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ip...@us...> - 2007-06-05 10:19:13
|
Revision: 2055 http://hugin.svn.sourceforge.net/hugin/?rev=2055&view=rev Author: ippei Date: 2007-06-05 03:19:11 -0700 (Tue, 05 Jun 2007) Log Message: ----------- panodata reorganisation continues Modified Paths: -------------- hugin/branches/ippei/src/hugin_base/panodata/Panorama.h hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h hugin/branches/ippei/src/hugin_base/panodata/SrcPanoImage.h Modified: hugin/branches/ippei/src/hugin_base/panodata/Panorama.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/Panorama.h 2007-06-05 00:34:21 UTC (rev 2054) +++ hugin/branches/ippei/src/hugin_base/panodata/Panorama.h 2007-06-05 10:19:11 UTC (rev 2055) @@ -94,7 +94,7 @@ * implemented without too much pain. */ -class Panorama : ManagedPanoramaData, PanoramaDataLegacySupport, AppBase::Document +class Panorama : ManagedPanoramaData, AppBase::Document { public: Modified: hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h 2007-06-05 00:34:21 UTC (rev 2054) +++ hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h 2007-06-05 10:19:11 UTC (rev 2055) @@ -103,196 +103,219 @@ public: virtual ~PanoramaData(); + + /** get a subset of the panorama + * + * This returns a panorama that contains only the images specified by \imgs + * Useful for operations on a subset of the panorama + */ + virtual PanoramaData getSubset(const PT::UIntSet & imgs) const; + + /** duplicate the panorama + * + * returns a copy of the pano state, except for the listeners. + */ + virtual PanoramaData duplicate() const; + + /** clear the internal state. */ + virtual void reset(); + + // -- Data Access [TODO: clean up] -- +// = images = + /// number of images. virtual std::size_t getNrOfImages() const; /// get a panorama image, counting starts with 0 virtual const PanoImage & getImage(std::size_t nr) const; - /// get a complete description of a source image - virtual SrcPanoImage getSrcImage(unsigned imgNr) const; - /// set a panorama image, counting starts with 0 virtual void setImage(std::size_t nr, PanoImage img); /// the the number for a specific image // virtual unsigned int getImageNr(const PanoImage * image) const; - - /// number of control points - virtual std::size_t getNrOfCtrlPoints() const; - /// get a control point, counting starts with 0 - virtual const ControlPoint & getCtrlPoint(std::size_t nr) const; - - /** return all control points for a given image. */ - virtual std::vector<unsigned int> getCtrlPointsForImage(unsigned int imgNr) const; - - /// get the number of a control point -// virtual unsigned int getCtrlPointNr(const ControlPoint * point) const; - - /// get all control point of this Panorama - virtual const CPVector & getCtrlPoints() const; - - /** get the next unused line number for t3, ... control point creation */ - virtual int getNextCPTypeLineNumber() const; - - /// get variables of this panorama - virtual const VariableMapVector & getVariables() const; - - /// get variables of an image - virtual const VariableMap & getImageVariables(unsigned int imgNr) const; - - /** return the optimize settings stored inside panorama */ - virtual const OptimizeVector & getOptimizeVector() const; - - /** set optimize setting */ - virtual void setOptimizeVector(const OptimizeVector & optvec); - - /** get a lens */ - virtual const Lens & getLens(unsigned int lensNr) const; - - /** get number of lenses */ - virtual unsigned int getNrOfLenses() const; - - /** returns the options for this panorama */ - virtual const PanoramaOptions & getOptions() const; - - // iterator like interface for the images and control points -// ImageVector::const_iterator - - /** add an Image to the panorama - * - * The Image must be initialized, the Lens must exist. - * - */ + * + * The Image must be initialized, the Lens must exist. + * + */ virtual unsigned int addImage(const PanoImage &img, const VariableMap &vars); - + /** creates an image, from filename, and a Lens, if needed */ virtual int addImageAndLens(const std::string & filename, double HFOV); - + /** add an Image to the panorama - * @return image number - */ -// virtual unsigned int addImage(const std::string & filename); - + * @return image number + */ + // virtual unsigned int addImage(const std::string & filename); + /** remove an Image. - * - * also deletes/updates all associated control points - * and the Lens, if it was only used by this image. - */ + * + * also deletes/updates all associated control points + * and the Lens, if it was only used by this image. + */ virtual void removeImage(unsigned int nr); - + + /** swap images. + * + * swaps the images, image @p img1 becomes @p img2 and the other way round + */ + virtual void swapImages(unsigned int img1, unsigned int img2); + + /// get a complete description of a source image + virtual SrcPanoImage getSrcImage(unsigned imgNr) const; + /** set input image parameters */ virtual void setSrcImage(unsigned int nr, const SrcPanoImage & img); - + /** set a new image filename - * - * It is assumed that it is of the same size - * as the old image. - * - */ + * + * It is assumed that it is of the same size + * as the old image. + * + */ virtual void setImageFilename(unsigned int img, const std::string & fname); - + /** change image properties. - */ + */ virtual void setImageOptions(unsigned int i, const ImageOptions & opts); - - /** set a lens for this image. - * - * copies all lens variables into the image. - */ - virtual void setLens(unsigned int imgNr, unsigned int lensNr); - - /** swap images. - * - * swaps the images, image @p img1 becomes @p img2 and the other way round - */ - virtual void swapImages(unsigned int img1, unsigned int img2); - - //=================================== - - /** add a new control point. - */ + + /** mark an image as active or inactive. + * + * This is only a flag, that can be turned on or off. + * If an image is marked active, then it should + * be used for optimizing and stitching. + * + * However, this is not done automatically. One has + * to use getActiveImages() to get the numbers of the + * active images, and pass these to the respective + * functions that do the stitching or optimisation + */ + void activateImage(unsigned int imgNr, bool active=true); + + /** get active images */ + UIntSet getActiveImages() const; + + +// = CPs = + + /// number of control points + virtual std::size_t getNrOfCtrlPoints() const; + + /// get a control point, counting starts with 0 + virtual const ControlPoint & getCtrlPoint(std::size_t nr) const; + + /// get all control point of this Panorama + virtual const CPVector & getCtrlPoints() const; + + /** return all control points for a given image. */ + virtual std::vector<unsigned int> getCtrlPointsForImage(unsigned int imgNr) const; + + /** set all control points (Ippei: Is this supposed to be 'add' method?) */ + virtual void setCtrlPoints(const CPVector & points); + + /** add a new control point.*/ virtual unsigned int addCtrlPoint(const ControlPoint & point); - + /** remove a control point. - */ + */ virtual void removeCtrlPoint(unsigned int pNr); - + /** change a control Point. - */ + */ virtual void changeControlPoint(unsigned int pNr, const ControlPoint & point); - - /** set all control points */ - virtual void setCtrlPoints(const CPVector & points); - + + /// get the number of a control point + // virtual unsigned int getCtrlPointNr(const ControlPoint * point) const; + + /** get the next unused line number for t3, ... control point creation */ + virtual int getNextCPTypeLineNumber() const; + /** assign new mode line numbers, if required */ virtual void updateLineCtrlPoints(); - - //============================= - + + +// = Lens = + + /** get number of lenses */ + virtual unsigned int getNrOfLenses() const; + + /** get a lens */ + virtual const Lens & getLens(unsigned int lensNr) const; + + /** set a lens for this image. + * + * copies all lens variables into the image. + */ + virtual void setLens(unsigned int imgNr, unsigned int lensNr); + /** add a new lens. - * - */ + * + */ virtual unsigned int addLens(const Lens & lens); - + + /** remove a lens + * + * it is only possible when it is not used by any image. + */ + virtual void removeLens(unsigned int lensNr); + + /** remove unused lenses. + * + * some operations might create lenses that are not + * referenced by any image. This functions removes them. + * + */ + virtual void removeUnusedLenses(); + /** Change the variable for a single lens - * - * updates a lens variable, copies it into - * all images. - * - */ + * + * updates a lens variable, copies it into + * all images. + * + */ virtual void updateLensVariable(unsigned int lensNr, const LensVariable &var); - + /** update a lens - * - * Changes the lens variables in all images of this lens. - */ + * + * Changes the lens variables in all images of this lens. + */ virtual void updateLens(unsigned int lensNr, const Lens & lens); - /** remove a lens - * - * it is only possible when it is not used by any image. - */ - virtual void removeLens(unsigned int lensNr); + +// = Variables = + + /// get variables of this panorama + virtual const VariableMapVector & getVariables() const; - /** remove unused lenses. - * - * some operations might create lenses that are not - * referenced by any image. This functions removes them. - * - */ - virtual void removeUnusedLenses(); + /// get variables of an image + virtual const VariableMap & getImageVariables(unsigned int imgNr) const; - //============================= + +// = Optimise Vector = + /** return the optimize settings stored inside panorama */ + virtual const OptimizeVector & getOptimizeVector() const; + + /** set optimize setting */ + virtual void setOptimizeVector(const OptimizeVector & optvec); + + +// = Panorama options = + + /** returns the options for this panorama */ + virtual const PanoramaOptions & getOptions() const; + /** set new output settings * This is not used directly for optimizing/stiching, but it can * be feed into runOptimizer() and runStitcher(). */ virtual void setOptions(const PanoramaOptions & opt); - //============================= - - /** mark an image as active or inactive. - * - * This is only a flag, that can be turned on or off. - * If an image is marked active, then it should - * be used for optimizing and stitching. - * - * However, this is not done automatically. One has - * to use getActiveImages() to get the numbers of the - * active images, and pass these to the respective - * functions that do the stitching or optimisation - */ - void activateImage(unsigned int imgNr, bool active=true); - - /** get active images */ - UIntSet getActiveImages() const; // -- script interface -- @@ -326,6 +349,25 @@ /// create the stitcher script virtual void printStitcherScript(std::ostream & o, const PanoramaOptions & target, const UIntSet & imgs) const; + + +// -- Algorithms to be modified. -- + + /** update control points distances. + * + * updates control distances and position in final panorama + * usually used to set the changes from the optimization. + * The control points must be the same as in + */ + virtual void updateCtrlPointErrors(const CPVector & controlPoints); + + /** update control points for a subset of images. + * + * Usually, the control point subset is created using subset() + * The number and ordering and control points must not be changed + * between the call to subset() and this function. + */ + void updateCtrlPointErrors(const UIntSet & imgs, const CPVector & cps); }; @@ -421,23 +463,7 @@ virtual ~ManagedPanoramaData(); - /** get a subset of the panorama - * - * This returns a panorama that contains only the images specified by \imgs - * Useful for operations on a subset of the panorama - */ - virtual Panorama getSubset(const PT::UIntSet & imgs) const; - /** duplicate the panorama - * - * returns a copy of the pano state, except for the listeners. - */ - virtual Panorama duplicate() const; - - /** clear the internal state. */ - virtual void reset(); - - // -- document interface [TODO: to be moved out] -- /** clear dirty flag. call after save */ Modified: hugin/branches/ippei/src/hugin_base/panodata/SrcPanoImage.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/SrcPanoImage.h 2007-06-05 00:34:21 UTC (rev 2054) +++ hugin/branches/ippei/src/hugin_base/panodata/SrcPanoImage.h 2007-06-05 10:19:11 UTC (rev 2055) @@ -424,6 +424,7 @@ }; +// -- [TODO: move out] -- /** try to fill out information about the image, by examining the exif data * focalLength and cropFactor will be updated with the ones read from the exif data This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ip...@us...> - 2007-06-05 10:45:49
|
Revision: 2056 http://hugin.svn.sourceforge.net/hugin/?rev=2056&view=rev Author: ippei Date: 2007-06-05 03:45:47 -0700 (Tue, 05 Jun 2007) Log Message: ----------- panodata reorganisation continues Modified Paths: -------------- hugin/branches/ippei/src/hugin_base/panodata/Panorama.h hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h hugin/branches/ippei/src/hugin_base/panodata/SrcPanoImage.h Removed Paths: ------------- hugin/branches/ippei/src/hugin_base/panodata/PanoramaDataLegacySupport.h Modified: hugin/branches/ippei/src/hugin_base/panodata/Panorama.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/Panorama.h 2007-06-05 10:19:11 UTC (rev 2055) +++ hugin/branches/ippei/src/hugin_base/panodata/Panorama.h 2007-06-05 10:45:47 UTC (rev 2056) @@ -577,75 +577,7 @@ }; -// -- algorithms [TODO: move out!] -- -/** function to calculate the scaling factor so that the distances - in the input image and panorama image are similar at the panorama center - */ -double calcOptimalPanoScale(const SrcPanoImage & src, - const PanoramaOptions & dest); - -double calcMeanExposure(const Panorama & pano); - - - -// helper functions, workaround for gcc 3.3, which doesn't find -// the map_get template functions. -PT::LensVariable & map_get(PT::LensVarMap &m, const std::string & key); -const PT::LensVariable & const_map_get(const PT::LensVarMap &m, const std::string & key); -PT::Variable & map_get(PT::VariableMap &m, const std::string & key); -const PT::Variable & const_map_get(const PT::VariableMap &m, const std::string & key); - - - -// -- Parsing [TODO: move out] -- - -/// helper functions for parsing a script line -bool getPTParam(std::string & output, const std::string & line, const std::string & parameter); - -#if 0 -template <class T> -bool getParam(T & value, const std::string & line, const std::string & name) -{ - std::string s; - if (!getPTParam(s, line, name)) { - return false; - } - std::istringstream is(s); - is >> value; - return true; -} -#endif - -template <class T> -bool getIntParam(T & value, const std::string & line, const std::string & name) -{ - std::string s; - if (!getPTParam(s, line, name)) { - return false; - } - std::istringstream is(s); - is >> value; - return true; -} - -bool readVar(Variable & var, int & link, const std::string & line); - -bool getPTStringParam(std::string & output, const std::string & line, - const std::string & parameter); - -bool getPTStringParamColon(std::string & output, const std::string & line, const std::string & parameter); - -bool getDoubleParam(double & d, const std::string & line, const std::string & name); - -bool getPTDoubleParam(double & value, int & link, - const std::string & line, const std::string & var); - - - - - - typedef std::vector<PanoImage> ImageVector; typedef std::vector<std::set<std::string> > OptimizeVector; @@ -662,6 +594,9 @@ */ class PanoramaMemento { + + friend class PT::Panorama; + public: PanoramaMemento() : needsOptimization(false) @@ -675,15 +610,16 @@ /** enum for supported PTScript syntax bastards */ enum PTFileFormat { PTFILE_HUGIN, PTFILE_PTGUI, PTFILE_PTA }; - + +private: + /** load a PTScript file - * - * initializes the PanoramaMemento from a PTScript file - */ + * + * initializes the PanoramaMemento from a PTScript file + */ bool loadPTScript(std::istream & i, const std::string & prefix = ""); + -private: - enum PTParseState { P_NONE, P_OUTPUT, P_MODIFIER, @@ -692,10 +628,6 @@ P_CP }; - - friend class PT::Panorama; - // state members for the state - ImageVector images; VariableMapVector variables; @@ -714,8 +646,62 @@ +namespace PTScriptParcing +{ + + /// helper functions for parsing a script line + bool getPTParam(std::string & output, const std::string & line, const std::string & parameter); + #if 0 + template <class T> + bool getParam(T & value, const std::string & line, const std::string & name) + { + std::string s; + if (!getPTParam(s, line, name)) { + return false; + } + std::istringstream is(s); + is >> value; + return true; + } + #endif + template <class T> + bool getIntParam(T & value, const std::string & line, const std::string & name) + { + std::string s; + if (!getPTParam(s, line, name)) { + return false; + } + std::istringstream is(s); + is >> value; + return true; + } + + bool readVar(Variable & var, int & link, const std::string & line); + + bool getPTStringParam(std::string & output, const std::string & line, + const std::string & parameter); + + bool getPTStringParamColon(std::string & output, const std::string & line, const std::string & parameter); + + bool getDoubleParam(double & d, const std::string & line, const std::string & name); + + bool getPTDoubleParam(double & value, int & link, + const std::string & line, const std::string & var); + +} + + + +// helper functions, workaround for gcc 3.3, which doesn't find +// the map_get template functions. +PT::LensVariable & map_get(PT::LensVarMap &m, const std::string & key); +const PT::LensVariable & const_map_get(const PT::LensVarMap &m, const std::string & key); +PT::Variable & map_get(PT::VariableMap &m, const std::string & key); +const PT::Variable & const_map_get(const PT::VariableMap &m, const std::string & key); + + } // namespace Modified: hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h 2007-06-05 10:19:11 UTC (rev 2055) +++ hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h 2007-06-05 10:45:47 UTC (rev 2056) @@ -337,7 +337,8 @@ virtual void parseOptimizerScript(std::istream & i, const UIntSet & imgs, VariableMapVector & imgVars, CPVector & ctrlPoints) const; - + + /// create an optimizer script virtual void printPanoramaScript(std::ostream & o, const OptimizeVector & optvars, Deleted: hugin/branches/ippei/src/hugin_base/panodata/PanoramaDataLegacySupport.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/PanoramaDataLegacySupport.h 2007-06-05 10:19:11 UTC (rev 2055) +++ hugin/branches/ippei/src/hugin_base/panodata/PanoramaDataLegacySupport.h 2007-06-05 10:45:47 UTC (rev 2056) @@ -1,123 +0,0 @@ -// -*- c-basic-offset: 4 -*- -/** @file PanoramaDataLegacySupport.h - * - * @author Pablo d'Angelo <pab...@we...> - * - * $Id: Panorama.h 1947 2007-04-15 20:46:00Z dangelo $ - * - * !! from Panorama.h 1947 - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef _PANORAMA_H -#define _PANORAMA_H - -#include "common/math.h" -#include "common/utils.h" - -#include <vector> -#include <set> -#include <sstream> - -#include "PT/PanoImage.h" -#include "PT/PanoramaMemento.h" - - - -namespace PT { - - -class PanoramaDataLegacySupport -{ -public: - - virtual ~PanoramaDataLegacySupport(); - - -// -- Algorithms to be modified. -- - - /** update control points distances. - * - * updates control distances and position in final panorama - * usually used to set the changes from the optimization. - * The control points must be the same as in - */ - virtual void updateCtrlPointErrors(const CPVector & controlPoints); - - /** update control points for a subset of images. - * - * Usually, the control point subset is created using subset() - * The number and ordering and control points must not be changed - * between the call to subset() and this function. - */ - void updateCtrlPointErrors(const UIntSet & imgs, const CPVector & cps); - - -// -- Algorithms to be moved out. -- - - /** calculates the horizontal and vertial FOV of the complete panorama - * - * @return HFOV,VFOV - */ - FDiff2D calcFOV() const; - - /** calculate the HFOV and height so that the whole input - * fits in into the output panorama */ - void fitPano(double & HFOV, double & height); - - /** calculate the optimal width for this panorama - * - * Optimal means that the pixel density at the panorama and - * image center of the image with the highest resolution - * are the same. - */ - unsigned calcOptimalWidth() const; - - /** calculate control point error distance statistics */ - void calcCtrlPntsErrorStats(double & min, double & max, double & mean, double & std, int imgNr=-1) const; - - /** calculate control point radial distance statistics. q10 and q90 are the 10% and 90% quantile */ - void calcCtrlPntsRadiStats(double & min, double & max, double & mean, double & var, - double & q10, double & q90, int imgNr=-1) const; - - /** center panorama horizontically */ - void centerHorizontically(); - - /** rotate the complete panorama - * - * Will modify the position of all images. - */ - void rotate(double yaw, double pitch, double roll); - - /** rotate the complete panorama. - * - * Will modify the position of all images. - */ - void rotate(const Matrix3 & rot); - - /** try to automatically straighten the panorama */ - void straighten(); - -} - - -} // namespace - - - - -#endif // _PANORAMA_H Modified: hugin/branches/ippei/src/hugin_base/panodata/SrcPanoImage.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/SrcPanoImage.h 2007-06-05 10:19:11 UTC (rev 2055) +++ hugin/branches/ippei/src/hugin_base/panodata/SrcPanoImage.h 2007-06-05 10:45:47 UTC (rev 2056) @@ -48,7 +48,8 @@ class SrcPanoImage { public: - + + enum Projection { RECTILINEAR = 0, PANORAMIC = 1, CIRCULAR_FISHEYE = 2, @@ -75,6 +76,13 @@ RESPONSE_ICC ///< use ICC for transformation into linear data (not implemented yet) }; + + + + + + + SrcPanoImage() { setDefaults(); @@ -142,6 +150,11 @@ m_morph = false; } + + + + + /** "resize" image, * adjusts all distortion coefficients for usage with a source image * of size @p size @@ -362,6 +375,23 @@ double getVar(const std::string & name) const; void setVar(const std::string & name, double val); + + + + /** try to fill out information about the image, by examining the exif data + * focalLength and cropFactor will be updated with the ones read from the exif data + * If no or not enought exif data was found and valid given focalLength and cropFactor + * settings where provided, they will be used for computation of the HFOV. + */ + static bool initImageFromFile(SrcPanoImage & img, double & focalLength, double & cropFactor); + + /** calculate hfov of an image given focal length, image size and crop factor */ + static double calcHFOV(SrcPanoImage::Projection proj, double fl, double crop, vigra::Size2D imageSize); + + /** calcualte focal length, given crop factor and hfov */ + static double calcFocalLength(SrcPanoImage::Projection proj, double hfov, double crop, vigra::Size2D imageSize); + + private: std::string m_filename; @@ -424,23 +454,8 @@ }; -// -- [TODO: move out] -- -/** try to fill out information about the image, by examining the exif data - * focalLength and cropFactor will be updated with the ones read from the exif data - * If no or not enought exif data was found and valid given focalLength and cropFactor - * settings where provided, they will be used for computation of the HFOV. - */ -bool initImageFromFile(SrcPanoImage & img, double & focalLength, double & cropFactor); -/** calculate hfov of an image given focal length, image size and crop factor */ -double calcHFOV(SrcPanoImage::Projection proj, double fl, double crop, vigra::Size2D imageSize); - -/** calcualte focal length, given crop factor and hfov */ -double calcFocalLength(SrcPanoImage::Projection proj, double hfov, double crop, vigra::Size2D imageSize); - - - } // namespace #endif // PANOIMAGE_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ip...@us...> - 2007-06-05 10:59:14
|
Revision: 2058 http://hugin.svn.sourceforge.net/hugin/?rev=2058&view=rev Author: ippei Date: 2007-06-05 03:59:13 -0700 (Tue, 05 Jun 2007) Log Message: ----------- panodata reorganisation continues Modified Paths: -------------- hugin/branches/ippei/src/hugin_base/panodata/Panorama.h hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h Modified: hugin/branches/ippei/src/hugin_base/panodata/Panorama.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/Panorama.h 2007-06-05 10:46:01 UTC (rev 2057) +++ hugin/branches/ippei/src/hugin_base/panodata/Panorama.h 2007-06-05 10:59:13 UTC (rev 2058) @@ -105,415 +105,372 @@ /** dtor. */ virtual ~Panorama(); - - /** add a panorama observer. - * - * It will recieve all change messages. - * An observer can only be added once. if its added twice, - * the second addObserver() will have no effect. - */ - void addObserver(PanoramaObserver *o); - - /** remove a panorama observer. - * - * Observers must be removed before they are destroyed, - * else Panorama will try to notify them after they have been - * destroyed - * - * @return true if observer was known, false otherwise. - */ - bool removeObserver(PanoramaObserver *observer); - - /** remove all panorama observers. - * - * @warning this is a hack. it must not be used on normal Panorama's. - */ - void clearObservers(); - - // query interface, used by the view to get information about - // the panorama. - + + /** get a subset of the panorama + * + * This returns a panorama that contains only the images specified by \imgs + * Useful for operations on a subset of the panorama + */ + PanoramaData getSubset(const PT::UIntSet & imgs) const; + + /** duplicate the panorama + * + * returns a copy of the pano state, except for the listeners. + */ + PanoramaData duplicate() const; + + /** clear the internal state. */ + void reset(); + + +// -- Data Access -- + +// = images = + /// number of images. std::size_t getNrOfImages() const - { return state.images.size(); }; + { + return state.images.size(); + }; + /// get a panorama image, counting starts with 0 - const PanoImage & getImage(std::size_t nr) const - { - assert(nr < state.images.size()); - return state.images[nr]; - }; + const PanoImage & getImage(std::size_t nr) const; + { + assert(nr < state.images.size()); + return state.images[nr]; + }; - /// get a complete description of a source image - SrcPanoImage getSrcImage(unsigned imgNr) const; - /// set a panorama image, counting starts with 0 void setImage(std::size_t nr, PanoImage img) - { - assert(nr < state.images.size()); - state.images[nr] = img; - }; + { + assert(nr < state.images.size()); + state.images[nr] = img; + }; + /// the the number for a specific image // unsigned int getImageNr(const PanoImage * image) const; - - - /// number of control points - std::size_t getNrOfCtrlPoints() const - { return state.ctrlPoints.size(); }; - /// get a control point, counting starts with 0 - const ControlPoint & getCtrlPoint(std::size_t nr) const - { - assert(nr < state.ctrlPoints.size()); - return state.ctrlPoints[nr]; - }; - /** return all control points for a given image. */ - std::vector<unsigned int> getCtrlPointsForImage(unsigned int imgNr) const; - /// get the number of a control point -// unsigned int getCtrlPointNr(const ControlPoint * point) const; - - /// get all control point of this Panorama - const CPVector & getCtrlPoints() const - { return state.ctrlPoints; } - - /// get the next unused line number for t3, ... control point creation - int getNextCPTypeLineNumber() const; - - /// get variables of this panorama - const VariableMapVector & getVariables() const; - - /// get variables of an image - const VariableMap & getImageVariables(unsigned int imgNr) const; - - - /** return the optimize settings stored inside panorama */ - const OptimizeVector & getOptimizeVector() const - { return state.optvec; }; - - /** set optimize setting */ - void setOptimizeVector(const OptimizeVector & optvec); - - /** get a lens - */ - const Lens & getLens(unsigned int lensNr) const; - - /** get number of lenses */ - unsigned int getNrOfLenses() const - { return unsigned(state.lenses.size()); } - - /** returns the options for this panorama */ - const PanoramaOptions & getOptions() const - { return state.options; } - - /** calculates the horizontal and vertial FOV of the complete panorama - * - * @return HFOV,VFOV - */ - FDiff2D calcFOV() const; - - /** calculate the HFOV and height so that the whole input - * fits in into the output panorama */ - void fitPano(double & HFOV, double & height); - - /** calculate the optimal width for this panorama - * - * Optimal means that the pixel density at the panorama and - * image center of the image with the highest resolution - * are the same. - */ - unsigned calcOptimalWidth() const; - - /** calculate control point error distance statistics */ - void calcCtrlPntsErrorStats(double & min, double & max, double & mean, double & std, int imgNr=-1) const; - - /** calculate control point radial distance statistics. q10 and q90 are the 10% and 90% quantile */ - void calcCtrlPntsRadiStats(double & min, double & max, double & mean, double & var, - double & q10, double & q90, int imgNr=-1) const; - - // iterator like interface for the images and control points -// ImageVector::const_iterator - - - /** parse optimzier output - * - * @param set of image numbers that where used during by - * printPanoramaScript(). - * @param vars will be set the the optimzied variables - * @param ctrlPoints will contain the controlpoints, with distance - * information - * - * @return false on error (could not read optimizer output, parse error) - */ - void readOptimizerOutput(const UIntSet & imgs, VariableMapVector & vars, CPVector & ctrlPoints) const; - - // ============================================================ - // - // function that modifies the internal state. - // should not be used directly, but through command objects. - // ============================================================ - - - /** clear the internal state. */ - void reset(); - - - /** Set the variables. - * - * Usually used when the optimizer results should be applied. - * - */ - void updateVariables(const VariableMapVector & vars); - - /** update variables for some specific images */ - void updateVariables(const UIntSet & imgs, const VariableMapVector & var); - - /** Set variables for a single picture. - * - */ - void updateVariables(unsigned int imgNr, const VariableMap & var); - - /** update a single variable - * - * It knows lenses etc and updates other images when the - * variable is linked - */ - void updateVariable(unsigned int imgNr, const Variable &var); - - /** center panorama horizontically */ - void centerHorizontically(); - - /** rotate the complete panorama - * - * Will modify the position of all images. - */ - void rotate(double yaw, double pitch, double roll); - - /** rotate the complete panorama. - * - * Will modify the position of all images. - */ - void rotate(const Matrix3 & rot); - - /** try to automatically straighten the panorama */ - void straighten(); - - /** update control points distances. - * - * updates control distances and position in final panorama - * usually used to set the changes from the optimization. - * The control points must be the same as in - */ - void updateCtrlPointErrors(const CPVector & controlPoints); - - /** update control points for a subset of images. - * - * Usually, the control point subset is created using subset() - * The number and ordering and control points must not be changed - * between the call to subset() and this function. - */ - void updateCtrlPointErrors(const UIntSet & imgs, const CPVector & cps); - + /** add an Image to the panorama - * - * The Image must be initialized, the Lens must exist. - * - */ + * + * The Image must be initialized, the Lens must exist. + * + */ unsigned int addImage(const PanoImage &img, const VariableMap &vars); - + /** creates an image, from filename, and a Lens, if needed */ int addImageAndLens(const std::string & filename, double HFOV); - + /** add an Image to the panorama - * @return image number - */ -// unsigned int addImage(const std::string & filename); - + * @return image number + */ + // unsigned int addImage(const std::string & filename); + /** remove an Image. - * - * also deletes/updates all associated control points - * and the Lens, if it was only used by this image. - */ + * + * also deletes/updates all associated control points + * and the Lens, if it was only used by this image. + */ void removeImage(unsigned int nr); - + + /** swap images. + * + * swaps the images, image @p img1 becomes @p img2 and the other way round + */ + void swapImages(unsigned int img1, unsigned int img2); + + /// get a complete description of a source image + SrcPanoImage getSrcImage(unsigned imgNr) const; + /** set input image parameters */ void setSrcImage(unsigned int nr, const SrcPanoImage & img); - + /** set a new image filename - * - * It is assumed that it is of the same size - * as the old image. - * - */ + * + * It is assumed that it is of the same size + * as the old image. + * + */ void setImageFilename(unsigned int img, const std::string & fname); - + /** change image properties. - */ + */ void setImageOptions(unsigned int i, const ImageOptions & opts); - - /** set a lens for this image. - * - * copies all lens variables into the image. - */ - void setLens(unsigned int imgNr, unsigned int lensNr); - - /** swap images. - * - * swaps the images, image @p img1 becomes @p img2 and the other way round - */ - void swapImages(unsigned int img1, unsigned int img2); - - //=================================== - - /** add a new control point. - */ + + /** mark an image as active or inactive. + * + * This is only a flag, that can be turned on or off. + * If an image is marked active, then it should + * be used for optimizing and stitching. + * + * However, this is not done automatically. One has + * to use getActiveImages() to get the numbers of the + * active images, and pass these to the respective + * functions that do the stitching or optimisation + */ + void activateImage(unsigned int imgNr, bool active=true); + + /** get active images */ + UIntSet getActiveImages() const; + + +// = CPs = + + /// number of control points + std::size_t getNrOfCtrlPoints() const + { + return state.ctrlPoints.size(); + }; + + /// get a control point, counting starts with 0 + const ControlPoint & getCtrlPoint(std::size_t nr) const + { + assert(nr < state.ctrlPoints.size()); + return state.ctrlPoints[nr]; + }; + + /// get all control point of this Panorama + const CPVector & getCtrlPoints() const + { return state.ctrlPoints; }; + + /** return all control points for a given image. */ + std::vector<unsigned int> getCtrlPointsForImage(unsigned int imgNr) const; + + /** set all control points (Ippei: Is this supposed to be 'add' method?) */ + void setCtrlPoints(const CPVector & points); + + /** add a new control point.*/ unsigned int addCtrlPoint(const ControlPoint & point); - + /** remove a control point. - */ + */ void removeCtrlPoint(unsigned int pNr); - + /** change a control Point. - */ + */ void changeControlPoint(unsigned int pNr, const ControlPoint & point); - - /** set all control points */ - void setCtrlPoints(const CPVector & points); - + + /// get the number of a control point + // unsigned int getCtrlPointNr(const ControlPoint * point) const; + + /** get the next unused line number for t3, ... control point creation */ + int getNextCPTypeLineNumber() const; + /** assign new mode line numbers, if required */ void updateLineCtrlPoints(); - - //============================= - + + +// = Lens = + + /** get number of lenses */ + unsigned int getNrOfLenses() const + { return unsigned(state.lenses.size()); }; + + /** get a lens */ + const Lens & getLens(unsigned int lensNr) const; + + /** set a lens for this image. + * + * copies all lens variables into the image. + */ + void setLens(unsigned int imgNr, unsigned int lensNr); + /** add a new lens. - * - */ + * + */ unsigned int addLens(const Lens & lens); - - + + /** remove a lens + * + * it is only possible when it is not used by any image. + */ + void removeLens(unsigned int lensNr); + + /** remove unused lenses. + * + * some operations might create lenses that are not + * referenced by any image. This functions removes them. + * + */ + void removeUnusedLenses(); + /** Change the variable for a single lens - * - * updates a lens variable, copies it into - * all images. - * - */ + * + * updates a lens variable, copies it into + * all images. + * + */ void updateLensVariable(unsigned int lensNr, const LensVariable &var); - - + /** update a lens - * - * Changes the lens variables in all images of this lens. - */ + * + * Changes the lens variables in all images of this lens. + */ void updateLens(unsigned int lensNr, const Lens & lens); - /** remove a lens - * - * it is only possible when it is not used by any image. - */ - void removeLens(unsigned int lensNr); + +// = Variables = + + /// get variables of this panorama + const VariableMapVector & getVariables() const; + /// get variables of an image + const VariableMap & getImageVariables(unsigned int imgNr) const; - /** remove unused lenses. - * - * some operations might create lenses that are not - * referenced by any image. This functions removes them. - * - */ - void removeUnusedLenses(); + +// = Optimise Vector = - //============================= + /** return the optimize settings stored inside panorama */ + const OptimizeVector & getOptimizeVector() const + { return state.optvec; }; + /** set optimize setting */ + void setOptimizeVector(const OptimizeVector & optvec); + + +// = Panorama options = + + /** returns the options for this panorama */ + const PanoramaOptions & getOptions() const + { return state.options; }; + /** set new output settings * This is not used directly for optimizing/stiching, but it can * be feed into runOptimizer() and runStitcher(). */ void setOptions(const PanoramaOptions & opt); + - - /// get the internal state - PanoramaMemento getMemento() const; - - /// set the internal state - void setMemento(PanoramaMemento & state); - + +// -- script interface -- + + /** parse optimzier output + * + * @param set of image numbers that where used during by + * printPanoramaScript(). + * @param vars will be set the the optimzied variables + * @param ctrlPoints will contain the controlpoints, with distance + * information + * + * @return false on error (could not read optimizer output, parse error) + */ + void readOptimizerOutput(const UIntSet & imgs, VariableMapVector & vars, CPVector & ctrlPoints) const; + + /// read after optimization, fills in control point errors. void parseOptimizerScript(std::istream & i, const UIntSet & imgs, - VariableMapVector & imgVars, - CPVector & ctrlPoints) const; + VariableMapVector & imgVars, + CPVector & ctrlPoints) const; + /// create an optimizer script void printPanoramaScript(std::ostream & o, - const OptimizeVector & optvars, - const PanoramaOptions & options, - const UIntSet & imgs, - bool forPTOptimizer, - const std::string & stripPrefix="") const; - + const OptimizeVector & optvars, + const PanoramaOptions & options, + const UIntSet & imgs, + bool forPTOptimizer, + const std::string & stripPrefix="") const; + /// create the stitcher script void printStitcherScript(std::ostream & o, const PanoramaOptions & target, - const UIntSet & imgs) const; + const UIntSet & imgs) const; + + +// -- Algorithms to be modified. -- + + /** update control points distances. + * + * updates control distances and position in final panorama + * usually used to set the changes from the optimization. + * The control points must be the same as in + */ + void updateCtrlPointErrors(const CPVector & controlPoints); + + /** update control points for a subset of images. + * + * Usually, the control point subset is created using subset() + * The number and ordering and control points must not be changed + * between the call to subset() and this function. + */ + void updateCtrlPointErrors(const UIntSet & imgs, const CPVector & cps); - // subject interface - /** notify observers about changes in this class - * - * This needs to be called explicitly by somebody after - * changes have been made. - * Allows to compress multiple changes into one notification. - * - * @param keepDirty do not set dirty flag. useful for changing - * the dirty flag itself - */ - void changeFinished(bool keepDirty=false); - /** clear dirty flag. call after save */ - void clearDirty() - { - dirty = false; - changeFinished(true); - } - /** true if there are unsaved changes */ - bool isDirty() const - { return dirty; } - +// -- Observing -- + + /** add a panorama observer. + * + * It will recieve all change messages. + * An observer can only be added once. if its added twice, + * the second addObserver() will have no effect. + */ + void addObserver(PanoramaObserver *o); + + /** remove a panorama observer. + * + * Observers must be removed before they are destroyed, + * else Panorama will try to notify them after they have been + * destroyed + * + * @return true if observer was known, false otherwise. + */ + bool removeObserver(PanoramaObserver *observer); + + /** remove all panorama observers. + * + * @warning this is a hack. it must not be used on normal Panorama's. + */ + void clearObservers(); + + /** notify observers about changes in this class + * + * This needs to be called explicitly by somebody after + * changes have been made. + * Allows to compress multiple changes into one notification. + * + * @param keepDirty do not set dirty flag. useful for changing + * the dirty flag itself + */ + void changeFinished(bool keepDirty=false); + + +// -- Memento interface -- + + /// get the internal state + PanoramaMemento getMemento() const; + + /// set the internal state + void setMemento(PanoramaMemento & state); + + +// -- Optimization Status -- + /** true if control points or lens variables - * have been changed after the last optimisation - */ + * have been changed after the last optimisation + */ bool needsOptimization() { return state.needsOptimization; }; void markAsOptimized(bool optimized=true) { state.needsOptimization = !optimized; }; + + +// -- document interface [TODO: to be moved out] -- + + /** clear dirty flag. call after save */ + void clearDirty() + { + dirty = false; + changeFinished(true); + } + + /** true if there are unsaved changes */ + bool isDirty() const + { return dirty; } - /** mark an image as active or inactive. - * - * This is only a flag, that can be turned on or off. - * If an image is marked active, then it should - * be used for optimizing and stitching. - * - * However, this is not done automatically. One has - * to use getActiveImages() to get the numbers of the - * active images, and pass these to the respective - * functions that do the stitching or optimisation - */ - void activateImage(unsigned int imgNr, bool active=true); - /** get active images */ - UIntSet getActiveImages() const; - - /** get a subset of the panorama - * - * This returns a panorama that contains only the images specified by \imgs - * Useful for operations on a subset of the panorama - */ - Panorama getSubset(const PT::UIntSet & imgs) const; - /** duplicate the panorama - * - * returns a copy of the pano state, except for the listeners. - */ - Panorama duplicate() const; - protected: - /// adjust the links of the linked variables, must be called /// when a lens has been changed. void adjustVarLinks(); Modified: hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h 2007-06-05 10:46:01 UTC (rev 2057) +++ hugin/branches/ippei/src/hugin_base/panodata/PanoramaData.h 2007-06-05 10:59:13 UTC (rev 2058) @@ -122,7 +122,7 @@ virtual void reset(); -// -- Data Access [TODO: clean up] -- +// -- Data Access -- // = images = @@ -465,20 +465,6 @@ virtual ~ManagedPanoramaData(); - // -- document interface [TODO: to be moved out] -- - - /** clear dirty flag. call after save */ - void clearDirty() - { - dirty = false; - changeFinished(true); - } - - /** true if there are unsaved changes */ - bool isDirty() const - { return dirty; } - - // -- Observing -- /** add a panorama observer. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <da...@us...> - 2007-10-24 19:28:25
|
Revision: 2489 http://hugin.svn.sourceforge.net/hugin/?rev=2489&view=rev Author: dangelo Date: 2007-10-24 12:28:24 -0700 (Wed, 24 Oct 2007) Log Message: ----------- properly added EXR output to functions querying file extensions for formats Modified Paths: -------------- hugin/branches/ippei/src/hugin_base/panodata/PanoramaOptions.cpp hugin/branches/ippei/src/hugin_base/panodata/PanoramaOptions.h Modified: hugin/branches/ippei/src/hugin_base/panodata/PanoramaOptions.cpp =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/PanoramaOptions.cpp 2007-10-24 17:25:37 UTC (rev 2488) +++ hugin/branches/ippei/src/hugin_base/panodata/PanoramaOptions.cpp 2007-10-24 19:28:24 UTC (rev 2489) @@ -42,28 +42,28 @@ const std::string & PanoramaOptions::getFormatName(FileFormat f) { - assert((int)f <= (int)HDR_m); + assert((int)f <= (int)FILEFORMAT_NULL); return fileformatNames[(int) f]; } const std::string & PanoramaOptions::getOutputExtension() const { - assert((int)outputFormat <= (int)HDR_m); + assert((int)outputFormat < (int)FILEFORMAT_NULL); return fileformatExt[(int) outputFormat]; } PanoramaOptions::FileFormat PanoramaOptions::getFormatFromName(const std::string & name) { - int max = (int) HDR_m; + int max = (int) FILEFORMAT_NULL; int i; for (i=0; i<max; i++) { if (name == fileformatNames[i]) { break; } } - if (i == max) { + if (i+1 == max) { DEBUG_ERROR("could not parse format " << name ); - return TIFF; + return TIFF_m; } return (FileFormat) i; } Modified: hugin/branches/ippei/src/hugin_base/panodata/PanoramaOptions.h =================================================================== --- hugin/branches/ippei/src/hugin_base/panodata/PanoramaOptions.h 2007-10-24 17:25:37 UTC (rev 2488) +++ hugin/branches/ippei/src/hugin_base/panodata/PanoramaOptions.h 2007-10-24 19:28:24 UTC (rev 2489) @@ -135,7 +135,8 @@ HDR, HDR_m, EXR, - EXR_m + EXR_m, + FILEFORMAT_NULL }; /** output mode */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |