00001
00024 #include <set>
00025 #include "StandardImageVariableGroups.h"
00026 #include "hugin_utils/utils.h"
00027 #include "hugin_utils/stl_utils.h"
00028 #include "ImageVariableTranslate.h"
00029
00030 namespace HuginBase {
00031
00038 const ConstImageVariableGroup::ImageVariableEnum lens_variables_array[]
00039 = {ImageVariableGroup::IVE_Size,
00040 ImageVariableGroup::IVE_Projection,
00041 ImageVariableGroup::IVE_HFOV,
00042 ImageVariableGroup::IVE_ResponseType,
00043 ImageVariableGroup::IVE_EMoRParams,
00044 ImageVariableGroup::IVE_ExposureValue,
00045 ImageVariableGroup::IVE_Gamma,
00046 ImageVariableGroup::IVE_WhiteBalanceRed,
00047 ImageVariableGroup::IVE_WhiteBalanceBlue,
00048 ImageVariableGroup::IVE_RadialDistortion,
00049 ImageVariableGroup::IVE_RadialDistortionRed,
00050 ImageVariableGroup::IVE_RadialDistortionBlue,
00051 ImageVariableGroup::IVE_RadialDistortionCenterShift,
00052 ImageVariableGroup::IVE_Shear,
00053 ImageVariableGroup::IVE_VigCorrMode,
00054 ImageVariableGroup::IVE_FlatfieldFilename,
00055 ImageVariableGroup::IVE_RadialVigCorrCoeff,
00056 ImageVariableGroup::IVE_RadialVigCorrCenterShift
00057 };
00058
00063 const std::set<ConstImageVariableGroup::ImageVariableEnum> lens_variables_set =
00064 std::set<ConstImageVariableGroup::ImageVariableEnum>(lens_variables_array,
00065 lens_variables_array + 18);
00066
00067
00074 const ConstImageVariableGroup::ImageVariableEnum stack_variables_array[]
00075 = {ImageVariableGroup::IVE_Yaw,
00076 ImageVariableGroup::IVE_Pitch,
00077 ImageVariableGroup::IVE_Roll,
00078 ImageVariableGroup::IVE_Stack,
00079 ImageVariableGroup::IVE_X,
00080 ImageVariableGroup::IVE_Y,
00081 ImageVariableGroup::IVE_Z,
00082 ImageVariableGroup::IVE_TranslationPlaneYaw,
00083 ImageVariableGroup::IVE_TranslationPlanePitch
00084 };
00085
00090 const std::set<ConstImageVariableGroup::ImageVariableEnum> stack_variables_set =
00091 std::set<ConstImageVariableGroup::ImageVariableEnum>(stack_variables_array,
00092 stack_variables_array + 9);
00093
00094
00095 ConstStandardImageVariableGroups::ConstStandardImageVariableGroups(const PanoramaData &pano)
00096 : m_lenses (lens_variables_set, pano),
00097 m_stacks (stack_variables_set, pano),
00098 m_pano (pano)
00099 {
00100 }
00101
00102 const std::set<ConstImageVariableGroup::ImageVariableEnum> &
00103 ConstStandardImageVariableGroups::getLensVariables()
00104 {
00105 return lens_variables_set;
00106 }
00107
00108 const std::set<ConstImageVariableGroup::ImageVariableEnum> &
00109 ConstStandardImageVariableGroups::getStackVariables()
00110 {
00111 return stack_variables_set;
00112 }
00113
00114 Lens ConstStandardImageVariableGroups::getLens(std::size_t lens_number)
00115 {
00116
00117 DEBUG_ASSERT(lens_number < m_lenses.getNumberOfParts());
00118 std::size_t image_number;
00119 std::size_t number_of_images = m_pano.getNrOfImages();
00120 for (image_number = 0; image_number < number_of_images; image_number++)
00121 {
00122 if (m_lenses.getPartNumber(image_number) == lens_number)
00123 {
00124 return getLensForImage(image_number);
00125 }
00126 }
00127 DEBUG_ERROR("Cannot find an image with requested lens number.");
00128 DEBUG_ASSERT(false);
00129 return getLensForImage(0);
00130 }
00131
00132 Lens ConstStandardImageVariableGroups::getLensForImage(std::size_t image_number)
00133 {
00134 Lens result;
00135 const SrcPanoImage & image = m_pano.getImage(image_number);
00136 result.setProjection((Lens::LensProjectionFormat) image.getProjection());
00137 result.setImageSize(image.getSize());
00138
00139 result.setCropFactor(image.getExifCropFactor());
00140
00141
00142
00143
00144
00145
00146
00147 #define image_variable( name, type, default_value)\
00148 {\
00149 VariableMap temp_vars;\
00150 if (set_contains(lens_variables_set, ImageVariableGroup::IVE_##name))\
00151 {\
00152 PTOVariableConverterFor##name::addToVariableMap(image.get##name##IV(), temp_vars);\
00153 for (VariableMap::iterator tvi = temp_vars.begin(); tvi != temp_vars.end(); tvi++)\
00154 {\
00155 LensVariable & lens_var = map_get(result.variables, tvi->first);\
00156 lens_var.setValue(tvi->second.getValue());\
00157 lens_var.setLinked(image.name##isLinked());\
00158 }\
00159 }\
00160 }
00161 #include "image_variables.h"
00162 #undef image_variable
00163 return result;
00164 }
00165
00166 void ConstStandardImageVariableGroups::update()
00167 {
00168
00169 m_lenses.updatePartNumbers();
00170 m_stacks.updatePartNumbers();
00171 }
00172
00173 void StandardImageVariableGroups::update()
00174 {
00175
00176 m_lenses.updatePartNumbers();
00177 m_stacks.updatePartNumbers();
00178
00179
00180
00181
00182 ConstStandardImageVariableGroups::update();
00183 }
00184
00185
00186 StandardImageVariableGroups::StandardImageVariableGroups(PanoramaData &pano)
00187 : ConstStandardImageVariableGroups(pano),
00188 m_lenses (lens_variables_set, pano),
00189 m_stacks (stack_variables_set, pano),
00190 m_pano (pano)
00191 {
00192 }
00193
00194 }