Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImageVariableTranslate.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
24 #ifndef _PANODATA_IMAGEVARIABLETRANSLATE_H
25 #define _PANODATA_IMAGEVARIABLETRANSLATE_H
26 
27 namespace HuginBase
28 {
29 /* We define stuff to use the PTO codes i image_variables.h
30  */
42 {
43 public:
51  inline static bool checkApplicability(const std::string& name)
52  {
53  return false;
54  }
55 
69  template <class T>
70  inline static double getValueFromVariable(
71  const std::string& name,
72  const ImageVariable<T> & var
73  )
74  {
75  return 0;
76  }
77 
88  template <class T>
89  inline static void setValueFromVariable(
90  const std::string& name,
91  ImageVariable<T> & var,
92  const double value
93  )
94  {
95  }
96 
104  template <class T>
105  inline static void addToVariableMap(
106  const ImageVariable<T> & var,
107  VariableMap & map
108  )
109  {
110  }
111 };
112 
121 template <char code1, char code2 = '\0', char code3 = '\0', class T = double>
123 {
124 public:
125  inline static bool checkApplicability(const std::string& name)
126  {
127  static const char code[] = {code1, code2, code3, '\0'};
128  return ((std::string)code) == name;
129  }
130 
131  inline static double getValueFromVariable(const std::string& name, const ImageVariable<T> & var)
132  {
133  return var.getData();
134  }
135 
136  inline static void setValueFromVariable(const std::string& name, ImageVariable<T> & var, const double value)
137  {
138  var.setData((T)value);
139  }
140 
141  inline static void addToVariableMap(const ImageVariable<T> & var, VariableMap & map)
142  {
143  static const char code[] = {code1, code2, code3, '\0'};
144  map.insert(std::make_pair(code, Variable(code, (double)var.getData())));
145  }
146 };
147 
148 
161 template <char base_code, class T = double, size_t size = 4>
163 {
164 public:
165  inline static bool checkApplicability(const std::string& name)
166  {
167  return name.size() == 2 && name[0] == base_code && name[1] >= 'a' && name[1] < 'a' + char(size);
168  }
169 
170  inline static double getValueFromVariable(const std::string& name, const ImageVariable<std::vector<T> > & var)
171  {
172  return var.getData()[name[1]-'a'];
173  }
174 
175  inline static void setValueFromVariable(const std::string& name, ImageVariable<std::vector<T> > & var, const double value)
176  {
177  std::vector<T> temp = var.getData();
178  temp[name[1]-'a'] = value;
179  var.setData(temp);
180  }
181 
182  inline static void addToVariableMap(const ImageVariable<std::vector<T> > & var, VariableMap & map)
183  {
184  char s[3] = {base_code, 'a', '\0'};
185  for (size_t index = 0; index < size; index++, s[1]++)
186  {
187  map.insert(std::make_pair(s, Variable(s, (double)var.getData()[index])));
188  }
189  }
190 };
191 
202 template <class T = double, size_t size = 3>
204 {
205 public:
206  inline static bool checkApplicability(const std::string& name)
207  {
208  return name[0] >= 'a' && name[0] < 'a' + char(size);
209  }
210 
211  inline static double getValueFromVariable(const std::string& name, const ImageVariable<std::vector<T> > & var)
212  {
213  return var.getData()[name[0]-'a'];
214  }
215 
216  inline static void setValueFromVariable(const std::string& name, ImageVariable<std::vector<T> > & var, const double value)
217  {
218  std::vector<T> temp = var.getData();
219  temp[name[0]-'a'] = value;
220  var.setData(temp);
221  }
222 
223  inline static void addToVariableMap(const ImageVariable<std::vector<T> > & var, VariableMap & map)
224  {
225  char s[] = "a";
226  for (size_t index = 0; index < size; index++, s[0]++)
227  {
228  map.insert(std::make_pair(s, Variable(s, (double)var.getData()[index])));
229  }
230  }
231 };
232 
240 template <char code_x1, char code_y1, char code_x2 = '\0', char code_y2 = '\0'>
242 {
243 public:
244  inline static bool checkApplicability(const std::string& name)
245  {
246  static const char code_x[] = {code_x1, code_x2, '\0'};
247  static const char code_y[] = {code_y1, code_y2, '\0'};
248  return name == (std::string) code_x || name == (std::string) code_y;
249  }
250 
251  inline static double getValueFromVariable(const std::string& name, const ImageVariable<hugin_utils::FDiff2D> & var)
252  {
253  static const char code_x[] = {code_x1, code_x2, '\0'};
254  return name == (std::string) code_x ? var.getData().x : var.getData().y;
255  }
256 
257  inline static void setValueFromVariable(const std::string& name, ImageVariable<hugin_utils::FDiff2D> & var, const double value)
258  {
259  hugin_utils::FDiff2D temp = var.getData();
260  static const char code_x[] = {code_x1, code_x2, '\0'};
261  (name == (std::string)code_x ? temp.x : temp.y) = value;
262  var.setData(temp);
263  }
264 
265  inline static void addToVariableMap(const ImageVariable<hugin_utils::FDiff2D> & var, VariableMap & map)
266  {
267  static const char s_x[] = {code_x1, code_x2, '\0'};
268  static const char s_y[] = {code_y1, code_y2, '\0'};
269  map.insert(std::make_pair(s_x, Variable(s_x, var.getData().x)));
270  map.insert(std::make_pair(s_y, Variable(s_y, var.getData().y)));
271  }
272 };
273 
274 // Now we can define a type to use for every PanoramaVariable.
275 // We should make sure that any given code is only applicable to one of these.
277 
281 //typedef PTOVariableConverterSingle<'f','\0', '\0', SrcPanoImage::Projection> PTOVariableConverterForProjection;
285 
292 
296 
302 
304 
310 
315 
318 //typedef PTOVariableConverterSingle<'V', 'm', '\0', int> PTOVariableConverterForVigCorrMode;
322 
339 
340 #if 0
341 //panotools variables, currently not used
342 typedef PTOVariableConverterNoOp PTOVariableConverterForFeatherWidth;
343 typedef PTOVariableConverterNoOp PTOVariableConverterForMorph;
344 #endif
349 }
350 
351 #endif
Object to group conversion functions for PTO format variables representing a std::vector variable in ...
PTOVariableConverterSingle<'T','p','y'> PTOVariableConverterForTranslationPlaneYaw
PTOVariableConverterSingle<'j'> PTOVariableConverterForStack
static double getValueFromVariable(const std::string &name, const ImageVariable< hugin_utils::FDiff2D > &var)
static void addToVariableMap(const ImageVariable< std::vector< T > > &var, VariableMap &map)
PTOVariableConverterNoOp PTOVariableConverterForExifBlueBalance
Object to group conversion functions for PTO format variables of up to three characters representing ...
PTOVariableConverterNoOp PTOVariableConverterForActive
PTOVariableConverterNoOp PTOVariableConverterForMasks
PTOVariableConverterVectorChar<'V', double, 4 > PTOVariableConverterForRadialVigCorrCoeff
An ImageVariable stores a value that can be linked to other ImageVariables of the same type...
Definition: ImageVariable.h:48
static double getValueFromVariable(const std::string &name, const ImageVariable< T > &var)
PTOVariableConverterSingle<'E', 'e', 'v'> PTOVariableConverterForExposureValue
static bool checkApplicability(const std::string &name)
PTOVariableConverterNoOp PTOVariableConverterForAutoCenterCrop
PTOVariableConverterSingle<'E', 'b'> PTOVariableConverterForWhiteBalanceBlue
static void setValueFromVariable(const std::string &name, ImageVariable< std::vector< T > > &var, const double value)
static void addToVariableMap(const ImageVariable< std::vector< T > > &var, VariableMap &map)
PTOVariableConverterNoOp PTOVariableConverterForActiveMasks
a variable has a value and a name.
PTOVariableConverterNoOp PTOVariableConverterForExifOrientation
PTOVariableConverterNoOp PTOVariableConverterForExifLens
PTOVariableConverterSingle<'T','r','Z'> PTOVariableConverterForZ
static bool checkApplicability(const std::string &name)
Check if a given pto format variable name applies to this image variable.
PTOVariableConverterNoOp PTOVariableConverterForExifModel
static bool checkApplicability(const std::string &name)
PTOVariableConverterNoOp PTOVariableConverterForFileMetadata
PTOVariableConverterNoOp PTOVariableConverterForExifRedBalance
PTOVariableConverterFDiff2D<'V','V', 'x','y'> PTOVariableConverterForRadialVigCorrCenterShift
Parent class to anything that aids conversion between PTO file variables and the image variables of S...
PTOVariableConverterVector< double, 3 > PTOVariableConverterForRadialDistortion
PTOVariableConverterSingle<'r'> PTOVariableConverterForRoll
PTOVariableConverterNoOp PTOVariableConverterForProjection
void setData(const Type data)
Set the variable groups&#39; value.
static void addToVariableMap(const ImageVariable< T > &var, VariableMap &map)
Add all PTO format variables specifed by an image variable in SrcPanoImg to a VariableMap.
PTOVariableConverterNoOp PTOVariableConverterForExifExposureTime
static bool checkApplicability(const std::string &name)
PTOVariableConverterNoOp PTOVariableConverterForFilename
PTOVariableConverterNoOp PTOVariableConverterForVigCorrMode
PTOVariableConverterNoOp PTOVariableConverterForCropMode
PTOVariableConverterNoOp PTOVariableConverterForRadialDistortionRed
static double getValueFromVariable(const std::string &name, const ImageVariable< T > &var)
Get a pto format variable&#39;s value, given its name and a reference to the variable in SrcPanoImg...
Type getData() const
get the variable&#39;s value
static void setValueFromVariable(const std::string &name, ImageVariable< T > &var, const double value)
Set a ImageVariable in SrcPanoImg given the pto format variable.
PTOVariableConverterNoOp PTOVariableConverterForFlatfieldFilename
PTOVariableConverterNoOp PTOVariableConverterForExifFocalLength
Object to group conversion functions for PTO format variables representing a std::vector variable in ...
PTOVariableConverterNoOp PTOVariableConverterForLensNr
PTOVariableConverterNoOp PTOVariableConverterForExifDate
static void addToVariableMap(const ImageVariable< T > &var, VariableMap &map)
static double getValueFromVariable(const std::string &name, const ImageVariable< std::vector< T > > &var)
static void setValueFromVariable(const std::string &name, ImageVariable< hugin_utils::FDiff2D > &var, const double value)
PTOVariableConverterNoOp PTOVariableConverterForExifExposureMode
PTOVariableConverterNoOp PTOVariableConverterForExifFocalLength35
PTOVariableConverterSingle<'E', 'r'> PTOVariableConverterForWhiteBalanceRed
#define IMPEX
Definition: hugin_shared.h:39
PTOVariableConverterSingle<'T','r','X'> PTOVariableConverterForX
Object to group conversion functions for PTO format variables representing a hugin_utils::FDiff2D var...
PTOVariableConverterNoOp PTOVariableConverterForExifMake
std::map< std::string, Variable > VariableMap
PTOVariableConverterNoOp PTOVariableConverterForExifCropFactor
static void setValueFromVariable(const std::string &name, ImageVariable< std::vector< T > > &var, const double value)
PTOVariableConverterFDiff2D<'g', 't'> PTOVariableConverterForShear
PTOVariableConverterNoOp PTOVariableConverterForExifISO
PTOVariableConverterNoOp PTOVariableConverterForCropFactor
PTOVariableConverterNoOp PTOVariableConverterForRadialDistortionBlue
static double getValueFromVariable(const std::string &name, const ImageVariable< std::vector< T > > &var)
PTOVariableConverterNoOp PTOVariableConverterForGamma
PTOVariableConverterSingle<'v'> PTOVariableConverterForHFOV
static void addToVariableMap(const ImageVariable< hugin_utils::FDiff2D > &var, VariableMap &map)
PTOVariableConverterNoOp PTOVariableConverterForExifDistance
PTOVariableConverterNoOp PTOVariableConverterForResponseType
PTOVariableConverterSingle<'T','r','Y'> PTOVariableConverterForY
PTOVariableConverterFDiff2D<'d', 'e'> PTOVariableConverterForRadialDistortionCenterShift
PTOVariableConverterNoOp PTOVariableConverterForExifAperture
PTOVariableConverterVectorChar<'R', float, 5 > PTOVariableConverterForEMoRParams
PTOVariableConverterSingle<'T','p','p'> PTOVariableConverterForTranslationPlanePitch
static void setValueFromVariable(const std::string &name, ImageVariable< T > &var, const double value)
PTOVariableConverterNoOp PTOVariableConverterForSize
PTOVariableConverterSingle<'y'> PTOVariableConverterForYaw
PTOVariableConverterSingle<'p'> PTOVariableConverterForPitch
static bool checkApplicability(const std::string &name)
PTOVariableConverterNoOp PTOVariableConverterForCropRect