Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StandardImageVariableGroups.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
24 #include <set>
26 #include "hugin_utils/utils.h"
27 #include "hugin_utils/stl_utils.h"
28 #include "ImageVariableTranslate.h"
29 
30 namespace HuginBase {
31 
39  = {ImageVariableGroup::IVE_Size,
40  ImageVariableGroup::IVE_Projection,
41  ImageVariableGroup::IVE_HFOV,
42  ImageVariableGroup::IVE_ResponseType,
43  ImageVariableGroup::IVE_EMoRParams,
44  ImageVariableGroup::IVE_Gamma,
45  ImageVariableGroup::IVE_RadialDistortion,
46  ImageVariableGroup::IVE_RadialDistortionRed,
47  ImageVariableGroup::IVE_RadialDistortionBlue,
48  ImageVariableGroup::IVE_RadialDistortionCenterShift,
49  ImageVariableGroup::IVE_Shear,
50  ImageVariableGroup::IVE_VigCorrMode,
51  ImageVariableGroup::IVE_FlatfieldFilename,
52  ImageVariableGroup::IVE_RadialVigCorrCoeff,
53  ImageVariableGroup::IVE_RadialVigCorrCenterShift
54  };
55 
60 const std::set<ConstImageVariableGroup::ImageVariableEnum> lens_variables_set =
61  std::set<ConstImageVariableGroup::ImageVariableEnum>(lens_variables_array,
63 
64 
72  = {ImageVariableGroup::IVE_Yaw,
73  ImageVariableGroup::IVE_Pitch,
74  ImageVariableGroup::IVE_Roll,
75  ImageVariableGroup::IVE_Stack,
76  ImageVariableGroup::IVE_X,
77  ImageVariableGroup::IVE_Y,
78  ImageVariableGroup::IVE_Z,
79  ImageVariableGroup::IVE_TranslationPlaneYaw,
80  ImageVariableGroup::IVE_TranslationPlanePitch
81  };
82 
87 const std::set<ConstImageVariableGroup::ImageVariableEnum> stack_variables_set =
88  std::set<ConstImageVariableGroup::ImageVariableEnum>(stack_variables_array,
90 
91 // constructor
93  : m_lenses (lens_variables_set, pano), // initialise lenses.
94  m_stacks (stack_variables_set, pano), // initalise stacks.
95  m_pano (pano)
96 {
97 }
98 
99 const std::set<ConstImageVariableGroup::ImageVariableEnum> &
101 {
102  return lens_variables_set;
103 }
104 
105 const std::set<ConstImageVariableGroup::ImageVariableEnum> &
107 {
108  return stack_variables_set;
109 }
110 
112 {
113  // find an image with the requested lens number.
114  DEBUG_ASSERT(lens_number < m_lenses.getNumberOfParts());
115  std::size_t image_number;
116  std::size_t number_of_images = m_pano.getNrOfImages();
117  for (image_number = 0; image_number < number_of_images; image_number++)
118  {
119  if (m_lenses.getPartNumber(image_number) == lens_number)
120  {
121  return getLensForImage(image_number);
122  }
123  }
124  DEBUG_ERROR("Cannot find an image with requested lens number.");
125  DEBUG_ASSERT(false);
126  return getLensForImage(0);
127 }
128 
130 {
131  Lens result;
132  const SrcPanoImage & image = m_pano.getImage(image_number);
133  result.setProjection((Lens::LensProjectionFormat) image.getProjection());
134  result.setImageSize(image.getSize());
135  // set the sensor size by using the crop factor
136  result.setCropFactor(image.getCropFactor());
137  /* Convert the lens image variables into a map of lens variables.
138  * We make a tempory VariableMap for rach lens image variable. The Panorama
139  * tools script codes map to the values in this. We then use the name and
140  * value to set the apropriate value in the lens' variables field. If the
141  * variable has any links, they must be links to the same lens, so we
142  * specify this as a linked variable.
143  */
144 #define image_variable( name, type, default_value)\
145  {\
146  VariableMap temp_vars;\
147  if (set_contains(lens_variables_set, ImageVariableGroup::IVE_##name))\
148  {\
149  PTOVariableConverterFor##name::addToVariableMap(image.get##name##IV(), temp_vars);\
150  for (VariableMap::iterator tvi = temp_vars.begin(); tvi != temp_vars.end(); tvi++)\
151  {\
152  LensVariable & lens_var = map_get(result.variables, tvi->first);\
153  lens_var.setValue(tvi->second.getValue());\
154  lens_var.setLinked(image.name##isLinked());\
155  }\
156  }\
157  }
158 #include "image_variables.h"
159 #undef image_variable
160  return result;
161 }
162 
164 {
165  // update all the ImageVariablesGroup object's part numbers.
168 }
169 
171 {
172  // update all the ImageVariablesGroup object's part numbers.
175  /* There are two m_lenses objects, one ConstImageVariablesGroup and one
176  * ImageVariableGroup. We should update both of them so the inherited
177  * functions can continue using Const version.
178  */
180 }
181 
182 
185  m_lenses (lens_variables_set, pano), // initialise lenses.
186  m_stacks (stack_variables_set, pano), // initialise stacks.
187  m_pano (pano)
188 {
189 }
190 
191 }// namespace HuginBase
static const std::set< ConstImageVariableGroup::ImageVariableEnum > & getLensVariables()
Get the set of lens image variables.
void setImageSize(const vigra::Size2D &sz)
set image size in pixels
Definition: Lens.h:93
unsigned int getPartNumber(unsigned int imageNr) const
Get a part number from an image number.
Somewhere to specify what variables belong to what.
void setProjection(LensProjectionFormat l)
set projection type
Definition: Lens.h:60
#define DEBUG_ASSERT(cond)
Definition: utils.h:80
ConstImageVariableGroup m_stacks
the stack ImageVariableGroup.
Make an ImageVariableGroup for lenses and other common concepts.
const ConstImageVariableGroup::ImageVariableEnum lens_variables_array[]
The image variables that are specific to lenses.
Model for a panorama.
Definition: PanoramaData.h:81
virtual const SrcPanoImage & getImage(std::size_t nr) const =0
get a panorama image, counting starts with 0
#define DEBUG_ERROR(msg)
Definition: utils.h:76
void setCropFactor(double newCropFactor)
sets the crop factor
Definition: Lens.h:77
ConstImageVariableGroup m_lenses
the lens ImageVariableGroup.
const std::set< ConstImageVariableGroup::ImageVariableEnum > lens_variables_set
A set containing the lens image variables.
Convenience functions for SrcPanoImage to use on the image variables.
const std::set< ConstImageVariableGroup::ImageVariableEnum > stack_variables_set
A set containing the stack image variables.
void updatePartNumbers()
Update the part numbers, call this when the panorama changes.
void update()
Update part numbers for each variable group.
const ConstImageVariableGroup::ImageVariableEnum stack_variables_array[]
The image variables that are specific to stack.
void update()
Update part numbers for each variable group.
ConstStandardImageVariableGroups(const PanoramaData &pano)
constructor.
virtual std::size_t getNrOfImages() const =0
number of images.
std::size_t getNumberOfParts() const
get the number of parts.
All variables of a source image.
Definition: SrcPanoImage.h:194
This file specifies what image variables SrcPanoImg should have.
static const std::set< ConstImageVariableGroup::ImageVariableEnum > & getStackVariables()
Get the set of stack image variables.
Lens getLensForImage(std::size_t imgNr)
Get the lens object for a specific image, also not for new code.
Lens getLens(std::size_t lens_number)
A panorama.getLens equivalent, not for new code.