[1fab1b]: src / hugin_base / panodata / StandardImageVariableGroups.cpp  Maximize  Restore  History

Download this file

196 lines (178 with data), 7.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// -*- c-basic-offset: 4 -*-
/** @file StandardImageVariableGroups.cpp
*
* @author James Legg
*
* @brief Implement the StandardImageVariableGroups object.
*
* 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
*
*/
#include <set>
#include "StandardImageVariableGroups.h"
#include "hugin_utils/utils.h"
#include "hugin_utils/stl_utils.h"
#include "ImageVariableTranslate.h"
namespace HuginBase {
/** The image variables that are specific to lenses. These are by default linked
* across images in the same lens.
*
* If you wish to change this, you'll need to set the ending offset in
* lens_variables_set below.
*/
const ConstImageVariableGroup::ImageVariableEnum lens_variables_array[]
= {ImageVariableGroup::IVE_Size,
ImageVariableGroup::IVE_Projection,
ImageVariableGroup::IVE_HFOV,
ImageVariableGroup::IVE_ResponseType,
ImageVariableGroup::IVE_EMoRParams,
ImageVariableGroup::IVE_ExposureValue,
ImageVariableGroup::IVE_Gamma,
ImageVariableGroup::IVE_WhiteBalanceRed,
ImageVariableGroup::IVE_WhiteBalanceBlue,
ImageVariableGroup::IVE_RadialDistortion,
ImageVariableGroup::IVE_RadialDistortionRed,
ImageVariableGroup::IVE_RadialDistortionBlue,
ImageVariableGroup::IVE_RadialDistortionCenterShift,
ImageVariableGroup::IVE_Shear,
ImageVariableGroup::IVE_VigCorrMode,
ImageVariableGroup::IVE_FlatfieldFilename,
ImageVariableGroup::IVE_RadialVigCorrCoeff,
ImageVariableGroup::IVE_RadialVigCorrCenterShift
};
/** A set containing the lens image variables.
*
* the offset on the second construtor argument is the size of the array.
*/
const std::set<ConstImageVariableGroup::ImageVariableEnum> lens_variables_set =
std::set<ConstImageVariableGroup::ImageVariableEnum>(lens_variables_array,
lens_variables_array + 18);
/** The image variables that are specific to stack. These are by default linked
* across images in the same stack.
*
* If you wish to change this, you'll need to set the ending offset in
* stack_variables_set below.
*/
const ConstImageVariableGroup::ImageVariableEnum stack_variables_array[]
= {ImageVariableGroup::IVE_Yaw,
ImageVariableGroup::IVE_Pitch,
ImageVariableGroup::IVE_Roll,
ImageVariableGroup::IVE_Stack,
ImageVariableGroup::IVE_X,
ImageVariableGroup::IVE_Y,
ImageVariableGroup::IVE_Z,
ImageVariableGroup::IVE_Spin,
ImageVariableGroup::IVE_Tilt,
ImageVariableGroup::IVE_Rotate
};
/** A set containing the stack image variables.
*
* the offset on the second construtor argument is the size of the array.
*/
const std::set<ConstImageVariableGroup::ImageVariableEnum> stack_variables_set =
std::set<ConstImageVariableGroup::ImageVariableEnum>(stack_variables_array,
stack_variables_array + 7);
// constructor
ConstStandardImageVariableGroups::ConstStandardImageVariableGroups(const PanoramaData &pano)
: m_lenses (lens_variables_set, pano), // initialise lenses.
m_stacks (stack_variables_set, pano), // initalise stacks.
m_pano (pano)
{
}
const std::set<ConstImageVariableGroup::ImageVariableEnum> &
ConstStandardImageVariableGroups::getLensVariables()
{
return lens_variables_set;
}
const std::set<ConstImageVariableGroup::ImageVariableEnum> &
ConstStandardImageVariableGroups::getStackVariables()
{
return stack_variables_set;
}
Lens ConstStandardImageVariableGroups::getLens(std::size_t lens_number)
{
// find an image with the requested lens number.
DEBUG_ASSERT(lens_number < m_lenses.getNumberOfParts());
std::size_t image_number;
std::size_t number_of_images = m_pano.getNrOfImages();
for (image_number = 0; image_number < number_of_images; image_number++)
{
if (m_lenses.getPartNumber(image_number) == lens_number)
{
return getLensForImage(image_number);
}
}
DEBUG_ERROR("Cannot find an image with requested lens number.");
DEBUG_ASSERT(false);
return getLensForImage(0);
}
Lens ConstStandardImageVariableGroups::getLensForImage(std::size_t image_number)
{
Lens result;
const SrcPanoImage & image = m_pano.getImage(image_number);
result.setProjection((Lens::LensProjectionFormat) image.getProjection());
result.setImageSize(image.getSize());
// set the sensor size by using the crop factor
result.setCropFactor(image.getExifCropFactor());
/* Convert the lens image variables into a map of lens variables.
* We make a tempory VariableMap for rach lens image variable. The Panorama
* tools script codes map to the values in this. We then use the name and
* value to set the apropriate value in the lens' variables field. If the
* variable has any links, they must be links to the same lens, so we
* specify this as a linked variable.
*/
#define image_variable( name, type, default_value)\
{\
VariableMap temp_vars;\
if (set_contains(lens_variables_set, ImageVariableGroup::IVE_##name))\
{\
PTOVariableConverterFor##name::addToVariableMap(image.get##name##IV(), temp_vars);\
for (VariableMap::iterator tvi = temp_vars.begin(); tvi != temp_vars.end(); tvi++)\
{\
LensVariable & lens_var = map_get(result.variables, tvi->first);\
lens_var.setValue(tvi->second.getValue());\
lens_var.setLinked(image.name##isLinked());\
}\
}\
}
#include "image_variables.h"
#undef image_variable
return result;
}
void ConstStandardImageVariableGroups::update()
{
// update all the ImageVariablesGroup object's part numbers.
m_lenses.updatePartNumbers();
m_stacks.updatePartNumbers();
}
void StandardImageVariableGroups::update()
{
// update all the ImageVariablesGroup object's part numbers.
m_lenses.updatePartNumbers();
m_stacks.updatePartNumbers();
/* There are two m_lenses objects, one ConstImageVariablesGroup and one
* ImageVariableGroup. We should update both of them so the inherited
* functions can continue using Const version.
*/
ConstStandardImageVariableGroups::update();
}
StandardImageVariableGroups::StandardImageVariableGroups(PanoramaData &pano)
: ConstStandardImageVariableGroups(pano),
m_lenses (lens_variables_set, pano), // initialise lenses.
m_stacks (stack_variables_set, pano), // initialise stacks.
m_pano (pano)
{
}
}// namespace HuginBase

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks