Hugin trunk 0.1
Loading...
Searching...
No Matches
SrcPanoImage.h
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
30#ifndef _PANODATA_SRCPANOIMAGE_H
31#define _PANODATA_SRCPANOIMAGE_H
32
33// if this file is preprocessed for SWIG, we want to ignore
34// all the header inclusions that follow:
35
36#ifndef _HSI_IGNORE_SECTION
37
38#include <hugin_shared.h>
39#include <hugin_config.h>
40#include <iostream>
41#include <vector>
42#include <vigra/diff2d.hxx>
43
44#include <hugin_utils/utils.h>
46#include "PanoramaVariable.h"
47#include "ImageVariable.h"
48#include "Mask.h"
49#include <map>
50
51#endif // _HSI_IGNORE_SECTION
52
53namespace HuginBase {
54
55class Panorama;
56
58typedef std::map<std::string, std::string> FileMetaData;
59
68{
69public:
72 RECTILINEAR = 0,
73 PANORAMIC = 1,
74 CIRCULAR_FISHEYE = 2,
75 FULL_FRAME_FISHEYE = 3,
76 EQUIRECTANGULAR = 4,
77 FISHEYE_ORTHOGRAPHIC = 8,
78 FISHEYE_STEREOGRAPHIC = 10,
79 FISHEYE_EQUISOLID = 21,
80 FISHEYE_THOBY = 20
81 };
82
84 enum CropMode {
85 NO_CROP=0,
86 CROP_RECTANGLE=1,
87 CROP_CIRCLE=2
88 };
89
92 VIGCORR_NONE = 0,
93 VIGCORR_RADIAL = 1,
94 VIGCORR_FLATFIELD = 2,
95 VIGCORR_DIV = 4
96 };
97
100 RESPONSE_EMOR=0,
104 RESPONSE_ICC
105 };
106
108 bool operator==(const BaseSrcPanoImage & other) const;
109
110
111public:
115
116 virtual ~BaseSrcPanoImage() {};
117
118 // property accessors
119public:
120 // get[variable name] functions. Return the value stored in the ImageVariable.
121#define image_variable( name, type, default_value ) \
122 type get##name() const { return m_##name.getData(); }
123#include "image_variables.h"
124#undef image_variable
125
126 // get[variable name]IV functions. Return a const reference to the ImageVariable.
127#define image_variable( name, type, default_value ) \
128 const ImageVariable<type > & get##name##IV() const { return m_##name; }
129#include "image_variables.h"
130#undef image_variable
131
132 // set[variable name] functions
133#define image_variable( name, type, default_value ) \
134 void set##name(type data) { m_##name.setData(data); }
135#include "image_variables.h"
136#undef image_variable
137
138 /* The link[variable name] functions
139 * Pass a pointer to another SrcPanoImg and the respective image variable
140 * will be shared between the images. Afterwards, changing the variable with
141 * set[variable name] on either image also sets the other image.
142 */
143#define image_variable( name, type, default_value ) \
144 void link##name (BaseSrcPanoImage * target) \
145 { m_##name.linkWith(&(target->m_##name)); }
146#include "image_variables.h"
147#undef image_variable
148
149 /* The unlink[variable name] functions
150 * Unlinking a variable makes it unique to this image. Then changing it will
151 * not affect the other images.
152 */
153#define image_variable( name, type, default_value ) \
154 void unlink##name () \
155 { m_##name.removeLinks(); }
156#include "image_variables.h"
157#undef image_variable
158
159 /* The [variable name]isLinked functions
160 * Returns true if the variable has links, or false if it is independant.
161 */
162#define image_variable( name, type, default_value ) \
163 bool name##isLinked () const \
164 { return m_##name.isLinked(); }
165#include "image_variables.h"
166#undef image_variable
167
168 /* The [variable name]isLinkedWith functions
169 * Returns true if the variable is linked with the equivalent variable in
170 * the specified image, false otherwise.
171 */
172#define image_variable( name, type, default_value ) \
173 bool name##isLinkedWith (const BaseSrcPanoImage & image) const \
174 { return m_##name.isLinkedWith(&(image.m_##name)); }
175#include "image_variables.h"
176#undef image_variable
177
178protected:
179 // the image variables m_[variable name]
180#define image_variable( name, type, default_value ) \
181 ImageVariable<type> m_##name {ImageVariable<type>(default_value)};
182#include "image_variables.h"
183#undef image_variable
184};
185
186
195{
196public:
200
201 SrcPanoImage(const BaseSrcPanoImage::Projection projection, const double hfov, const vigra::Size2D size) :BaseSrcPanoImage()
202 {
203 setProjection(projection);
204 setHFOV(hfov);
205 setSize(size);
206 };
207
208 virtual ~SrcPanoImage() {};
209public:
217 void resize(const vigra::Size2D & size, VariableMap* potentialLinkedVars);
218
221 bool isInside(vigra::Point2D p, bool ignoreMasks=false) const;
222
224 bool horizontalWarpNeeded();
225
226 // Accessors
227 // These are either:
228 // #- extra ones that are derived from image varibles, or
229 // #- replacements where we need extra processing.
230public:
231 bool getCorrectTCA() const;
232
238 void setCropMode(CropMode val);
239
241 bool isCircularCrop() const;
242
247 void setSize(vigra::Size2D val);
248
249 hugin_utils::FDiff2D getRadialDistortionCenter() const;
250
251 hugin_utils::FDiff2D getRadialVigCorrCenter() const;
252
253 // these are linked to ExposureValue, which is done with the above.
254 // exposure value is log2 of inverse exposure factor.
255 double getExposure() const;
256 void setExposure(const double & val);
257
258
266 int getWidth() const
267 { return getSize().width(); }
268
276 int getHeight() const
277 { return getSize().height(); }
278
279 double getVar(const std::string & name) const;
280
281 void setVar(const std::string & name, double val);
282
292 VariableMap getVariableMap() const;
293
296 const int getExifDateTime(struct tm* datetime) const;
297
301 {
302 m_RadialVigCorrCoeff.removeLinks();
303 m_VigCorrMode.removeLinks();
304 }
305
309 {
310 m_RadialVigCorrCenterShift.removeLinks();
311 m_VigCorrMode.removeLinks();
312 }
313
317 {
318 m_EMoRParams.removeLinks();
319 m_ResponseType.removeLinks();
320 }
321
325 {
326 m_RadialVigCorrCoeff.linkWith(&(target->m_RadialVigCorrCoeff));
327 m_VigCorrMode.linkWith(&(target->m_VigCorrMode));
328 }
329
333 {
334 m_RadialVigCorrCenterShift.linkWith(&(target->m_RadialVigCorrCenterShift));
335 m_VigCorrMode.linkWith(&(target->m_VigCorrMode));
336 }
337
341 {
342 m_EMoRParams.linkWith(&(target->m_EMoRParams));
343 m_ResponseType.linkWith(&(target->m_ResponseType));
344 }
345
346 void linkStack (SrcPanoImage * target)
347 { m_Stack.linkWith(&(target->m_Stack)); }
348
350 bool checkImageSizeKnown();
353 bool readEXIF();
355 bool applyEXIFValues(bool applyEVValue=true);
356
358 static double calcHFOV(SrcPanoImage::Projection proj, double fl, double crop, vigra::Size2D imageSize);
359
361 static double calcFocalLength(SrcPanoImage::Projection proj, double hfov, double crop, vigra::Size2D imageSize);
362
364 static double calcCropFactor(SrcPanoImage::Projection proj, double hfov, double focalLength, vigra::Size2D imageSize);
365
367 double calcExifExposureValue();
368
370 void updateFocalLength(double newFocalLength);
372 void updateCropFactor(double focalLength, double newCropFactor);
373
377 bool readCropfactorFromDB();
384 bool readProjectionFromDB(const bool ignoreFovRectilinear=true);
388 bool readDistortionFromDB();
392 bool readVignettingFromDB();
395 std::string getDBLensName() const;
396
398 bool hasMasks() const;
400 bool hasPositiveMasks() const;
402 bool hasActiveMasks() const;
404 void addMask(MaskPolygon newMask);
406 void addActiveMask(MaskPolygon newMask);
408 void clearActiveMasks();
410 void changeMaskType(unsigned int index, HuginBase::MaskPolygon::MaskType newType);
412 void deleteMask(unsigned int index);
414 void deleteAllMasks();
416 void printMaskLines(std::ostream &o, unsigned int newImgNr) const;
418 bool isInsideMasks(vigra::Point2D p) const;
419
420private:
421
423 bool trustExivOrientation();
424};
425
426typedef std::vector<SrcPanoImage> ImageVector;
427
428} // namespace
429
430#endif // PANOIMAGE_H
options getSize().area()) int wxCALLBACK SortFieldOfViewAscending(wxIntPtr item1
Define & Implement the ImageVariable class.
declaration of classes to work with mask
Base class containing all the variables, but missing some of the other important functions and with s...
VignettingCorrMode
vignetting correction mode (bitflags, no real enum)
@ RESPONSE_GAMMA
a simple gamma response curve
@ RESPONSE_LINEAR
linear response
@ RESPONSE_FILE
load response curve from file (not implemented yet)
base class, which stores one mask polygon
Definition Mask.h:53
MaskType
enumeration with type of possible masks
Definition Mask.h:57
All variables of a source image.
void linkEMoRParams(SrcPanoImage *target)
linking the EMOR parameters should link the correction mode.
void linkStack(SrcPanoImage *target)
void unlinkRadialVigCorrCenterShift()
unlinking vignetting parameters should unlink the vignetting correction mode
void linkRadialVigCorrCoeff(SrcPanoImage *target)
linking vignetting parameters should link the vignetting correction mode
int getWidth() const
Get the width of the image in pixels.
void linkRadialVigCorrCenterShift(SrcPanoImage *target)
linking vignetting parameters should link the vignetting correction mode
void unlinkEMoRParams()
unlinking the EMOR parameters should unlink the correction mode.
SrcPanoImage(const BaseSrcPanoImage::Projection projection, const double hfov, const vigra::Size2D size)
void unlinkRadialVigCorrCoeff()
unlinking vignetting parameters should unlink the vignetting correction mode
int getHeight() const
Get the height of the image in pixels.
misc math function & classes used by other parts of the program
#define IMPEX
This file specifies what image variables SrcPanoImg should have.
HuginBase::BaseSrcPanoImage::CropMode CropMode
mainly consists of wrapper around the pano tools library, to assist in ressource management and to pr...
Definition wxcms.cpp:39
std::map< std::string, Variable > VariableMap
std::vector< SrcPanoImage > ImageVector
std::map< std::string, std::string > FileMetaData
typedef for general map for storing metadata in files
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41