27 #include <wx/msgdlg.h>
40 for (
auto& lensInfo : lensInfoVector)
42 list->Append(lensInfo.name, (
void*)lensInfo.id);
44 list->SetSelection(0);
52 lensInfo.
name = _(
"Normal (rectilinear)");
53 lensInfoVector.push_back(lensInfo);
55 lensInfo.
name = _(
"Panoramic (cylindrical)");
56 lensInfoVector.push_back(lensInfo);
58 lensInfo.
name = _(
"Circular fisheye");
59 lensInfoVector.push_back(lensInfo);
61 lensInfo.
name = _(
"Full frame fisheye");
62 lensInfoVector.push_back(lensInfo);
64 lensInfo.
name = _(
"Equirectangular");
65 lensInfoVector.push_back(lensInfo);
67 lensInfo.
name = _(
"Orthographic");
68 lensInfoVector.push_back(lensInfo);
70 lensInfo.
name = _(
"Stereographic");
71 lensInfoVector.push_back(lensInfo);
73 lensInfo.
name = _(
"Equisolid");
74 lensInfoVector.push_back(lensInfo);
76 lensInfo.
name = _(
"Fisheye Thoby");
77 lensInfoVector.push_back(lensInfo);
78 return lensInfoVector;
87 list->SetSelection(0);
92 for(
unsigned int i=0;i<list->GetCount();i++)
94 if((
size_t)list->GetClientData(i)==newValue)
96 list->SetSelection(i);
100 list->SetSelection(0);
105 return (
size_t)(list->GetClientData(list->GetSelection()));
111 switch (img.getProjection())
129 switch (img.getResponseType())
132 s = _(
"custom (EMoR)");
150 char * p = setlocale(LC_NUMERIC,NULL);
151 char * old_locale = strdup(p);
152 setlocale(LC_NUMERIC,
"C");
153 wxFileConfig cfg(
"hugin lens file",wxEmptyString,filename);
154 cfg.Write(
"Lens/image_width", (
long) lens.
getImageSize().x);
155 cfg.Write(
"Lens/image_height", (
long) lens.
getImageSize().y);
166 if (std::string(*varname) ==
"v")
171 wxString key(
"Lens/");
172 key.append(wxString(*varname, wxConvLocal));
181 cfg.Write(
"Lens/crop/autoCenter", image.getAutoCenterCrop() ? 1l : 0l);
182 const vigra::Rect2D cropRect=image.getCropRect();
183 cfg.Write(
"Lens/crop/left", cropRect.left());
184 cfg.Write(
"Lens/crop/top", cropRect.top());
185 cfg.Write(
"Lens/crop/right", cropRect.right());
186 cfg.Write(
"Lens/crop/bottom", cropRect.bottom());
188 if (!image.getExifMake().empty() && !image.getExifModel().empty() && image.getExifFocalLength()>0)
191 cfg.Write(
"EXIF/CameraMake", wxString(image.getExifMake().c_str(), wxConvLocal));
192 cfg.Write(
"EXIF/CameraModel", wxString(image.getExifModel().c_str(), wxConvLocal));
193 cfg.Write(
"EXIF/FocalLength", image.getExifFocalLength());
194 cfg.Write(
"EXIF/Aperture", image.getExifAperture());
195 cfg.Write(
"EXIF/ISO", image.getExifISO());
196 cfg.Write(
"EXIF/CropFactor", image.getCropFactor());
197 cfg.Write(
"EXIF/Distance", image.getExifDistance());
202 setlocale(LC_NUMERIC,old_locale);
211 bool autoCenterCrop=
false;
212 vigra::Rect2D cropRect;
218 for(HuginBase::UIntSet::const_iterator it=images.begin();it!=images.end();++it,++i)
221 for (HuginBase::LensVarMap::iterator it2 = lens.
variables.begin(); it2 != lens.
variables.end(); ++it2)
223 if (it2->second.getName() ==
"Eev" || it2->second.getName() ==
"Er" || it2->second.getName() ==
"Eb")
227 vars[i].find(it2->first)->second.setValue(it2->second.getValue());
234 std::vector<PanoCommand::PanoCommand*> cmds;
236 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
237 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> unlinkedVariables;
238 for (HuginBase::LensVarMap::iterator it = lens.
variables.begin(); it != lens.
variables.end(); ++it)
240 if(it->second.getName()==
"Eev" || it->second.getName() ==
"Er" || it->second.getName() ==
"Eb")
244 #define image_variable( name, type, default_value ) \
245 if (HuginBase::PTOVariableConverterFor##name::checkApplicability(it->second.getName()))\
247 if(it->second.isLinked())\
248 linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_##name);\
250 unlinkedVariables.insert(HuginBase::ImageVariableGroup::IVE_##name);\
253 #undef image_variable
255 if (!linkedVariables.empty())
260 if (!unlinkedVariables.empty())
271 cmds.push_back(
new PanoCommand::ChangeImageCropFactorCmd(*pano,images,lens.
getCropFactor()));
273 cmds.push_back(
new PanoCommand::ChangeImageAutoCenterCropCmd(*pano,images,autoCenterCrop));
276 cmds.push_back(
new PanoCommand::ChangeImageCropRectCmd(*pano,images,cropRect));
292 bool & cropped,
bool & autoCenterCrop, vigra::Rect2D & cropRect)
295 wxFileDialog dlg(parent,
296 _(
"Load lens parameters"),
297 wxConfigBase::Get()->Read(
"/lensPath",wxEmptyString), wxEmptyString,
298 _(
"Lens Project Files (*.ini)|*.ini|All files (*.*)|*.*"),
299 wxFD_OPEN, wxDefaultPosition);
300 dlg.SetDirectory(wxConfigBase::Get()->Read(
"/lensPath",wxEmptyString));
301 if (dlg.ShowModal() == wxID_OK)
303 fname = dlg.GetPath();
304 wxConfig::Get()->Write(
"/lensPath", dlg.GetDirectory());
306 char * p = setlocale(LC_NUMERIC,NULL);
307 char * old_locale = strdup(p);
308 setlocale(LC_NUMERIC,
"C");
310 wxFileConfig cfg(
"hugin lens file",wxEmptyString,fname);
312 cfg.Read(
"Lens/image_width", &w);
314 cfg.Read(
"Lens/image_height", &h);
317 if (w != sz.x || h != sz.y) {
318 std::cerr <<
"Image size: " << sz <<
" size in lens parameter file: " << w <<
"x" << h << std::endl;
320 _(
"Hugin"), wxICON_QUESTION | wxYES_NO, wxGetActiveWindow()) == wxNO)
322 setlocale(LC_NUMERIC,old_locale);
332 if(cfg.Read(
"Lens/type", &integer))
337 if(cfg.Read(
"Lens/crop", &d))
343 if(cfg.Read(
"Lens/hfov", &d))
348 if(cfg.Read(
"Lens/hfov_linked", &integer))
357 wxString key(
"Lens/");
358 key.append(wxString(*varname, wxConvLocal));
360 if (cfg.Read(key,&d))
366 if(cfg.Read(key, &integer))
376 cfg.Read(
"Lens/crop/enabled", &v);
384 if(cfg.Read(
"Lens/crop/left", &left) && cfg.Read(
"Lens/crop/top", &top) &&
385 cfg.Read(
"Lens/crop/right", &right) && cfg.Read(
"Lens/crop/bottom", &bottom))
388 cropRect=vigra::Rect2D(left,top,right,bottom);
396 if(cfg.Read(
"Lens/crop/autoCenter", &v))
398 autoCenterCrop=(v!=0);
402 setlocale(LC_NUMERIC,old_locale);
414 if (images.size() == 1)
416 unsigned int imgNr = *(images.begin());
417 wxFileDialog dlg(parent,
418 _(
"Save lens parameters file"),
419 wxConfigBase::Get()->Read(
"/lensPath",wxEmptyString), wxEmptyString,
420 _(
"Lens Project Files (*.ini)|*.ini|All files (*)|*"),
421 wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
422 dlg.SetDirectory(wxConfigBase::Get()->Read(
"/lensPath",wxEmptyString));
423 if (dlg.ShowModal() == wxID_OK)
425 wxFileName filename(dlg.GetPath());
426 if(!filename.HasExt())
428 filename.SetExt(
"ini");
429 if (filename.Exists())
437 wxConfig::Get()->Write(
"/lensPath", dlg.GetDirectory());
443 wxLogError(_(
"Please select an image and try again"));
454 bool stacksCorrectLinked =
true;
455 for (
size_t i = 0; i < nrImages - 1; ++i)
458 if (image1.YawisLinked())
460 for (
size_t j = i + 1; j < nrImages && stacksCorrectLinked; ++j)
463 if (image1.YawisLinkedWith(image2))
465 stacksCorrectLinked = stacksCorrectLinked &&
466 image1.HFOVisLinkedWith(image2) &&
467 image1.RadialDistortionisLinkedWith(image2) &&
468 image1.RadialDistortionCenterShiftisLinkedWith(image2) &&
469 image1.ShearisLinkedWith(image2);
474 if (stacksCorrectLinked)
480 int flags = wxICON_EXCLAMATION | wxOK;
483 flags = flags | wxCANCEL;
485 if (
hugin_utils::HuginMessageBox(_(
"This project contains stacks with linked positions. But the lens parameters are not linked for these images.\nThis will result in unwanted results.\nPlease check and correct this before proceeding."),
486 _(
"Hugin"), flags, wxGetActiveWindow()) == wxOK)
497 namespace FormatString
502 struct tm exifdatetime;
505 wxDateTime s_datetime = wxDateTime(exifdatetime);
506 s = s_datetime.Format();
510 s = wxString(img->getExifDate().c_str(), wxConvLocal);
518 if (img->getExifFocalLength() > 0.0)
520 if (img->getExifFocalLength35() > 0.0)
522 s = wxString::Format(
"%0.1f mm (%0.0f mm)", img->getExifFocalLength(), img->getExifFocalLength35());
526 s = wxString::Format(
"%0.1f mm", img->getExifFocalLength());
539 if (img->getExifAperture() > 0)
541 s = wxString::Format(
"F%.1f", img->getExifAperture());
553 const double exposureTime = img->getExifExposureTime();
554 if (exposureTime > 0.5)
556 if (exposureTime >= 1.0)
558 if (exposureTime >= 10.0)
560 s = wxString::Format(
"%3.0f s", exposureTime);
564 s = wxString::Format(
"%1.1f s", exposureTime);
569 s = wxString::Format(
"%1.2f s", exposureTime);
574 if (exposureTime > 1e-9)
576 s = wxString::Format(
"1/%0.0f s", 1.0 / exposureTime);
590 if (img->getExifISO() > 0)
592 s = wxString::Format(
"%0.0f", img->getExifISO());
Base class for all panorama commands.
static const char * variableNames[]
static const std::set< ConstImageVariableGroup::ImageVariableEnum > & getLensVariables()
Get the set of lens image variables.
vigra::Size2D getImageSize() const
get the image size, in pixels
update variables of a group of images
bool AskUserOverwrite(const wxString &filename, const wxString &caption, wxWindow *parent)
ask user if the given file should be overwritten, return true if the user confirmed the overwritting ...
Change the linking of some variables across parts of an ImageVariableGroup containing some specified ...
Somewhere to specify what variables belong to what.
void setProjection(LensProjectionFormat l)
set projection type
include file for the hugin project
const Map::mapped_type & const_map_get(const Map &m, const typename Map::key_type &key)
PanoCommand to combine other PanoCommands.
std::set< unsigned int > UIntSet
std::vector< VariableMap > VariableMapVector
LensProjectionFormat getProjection() const
get projection type
empirical model of response
const VariableMap getImageVariables(unsigned int imgNr) const
Get the variables of an image.
std::size_t getNrOfImages() const
number of images.
const int getExifDateTime(struct tm *datetime) const
try to convert Exif date time string to struct tm
Map::mapped_type & map_get(Map &m, const typename Map::key_type &key)
get a map element.
void setCropFactor(double newCropFactor)
sets the crop factor
std::map< std::string, Variable > VariableMap
include file for the hugin project
Convenience functions for SrcPanoImage to use on the image variables.
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
double getCropFactor() const
get crop factor, d35mm/dreal
All variables of a source image.
This file specifies what image variables SrcPanoImg should have.
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
Lens getLensForImage(std::size_t imgNr)
Get the lens object for a specific image, also not for new code.