27 #include <wx/msgdlg.h>
39 for (
auto& lensInfo : lensInfoVector)
41 list->Append(lensInfo.name, (
void*)lensInfo.id);
43 list->SetSelection(0);
51 lensInfo.
name = _(
"Normal (rectilinear)");
52 lensInfoVector.push_back(lensInfo);
54 lensInfo.
name = _(
"Panoramic (cylindrical)");
55 lensInfoVector.push_back(lensInfo);
57 lensInfo.
name = _(
"Circular fisheye");
58 lensInfoVector.push_back(lensInfo);
60 lensInfo.
name = _(
"Full frame fisheye");
61 lensInfoVector.push_back(lensInfo);
63 lensInfo.
name = _(
"Equirectangular");
64 lensInfoVector.push_back(lensInfo);
66 lensInfo.
name = _(
"Orthographic");
67 lensInfoVector.push_back(lensInfo);
69 lensInfo.
name = _(
"Stereographic");
70 lensInfoVector.push_back(lensInfo);
72 lensInfo.
name = _(
"Equisolid");
73 lensInfoVector.push_back(lensInfo);
75 lensInfo.
name = _(
"Fisheye Thoby");
76 lensInfoVector.push_back(lensInfo);
77 return lensInfoVector;
86 list->SetSelection(0);
91 for(
unsigned int i=0;i<list->GetCount();i++)
93 if((
size_t)list->GetClientData(i)==newValue)
95 list->SetSelection(i);
99 list->SetSelection(0);
104 return (
size_t)(list->GetClientData(list->GetSelection()));
110 switch (img.getProjection())
128 switch (img.getResponseType())
131 s = _(
"custom (EMoR)");
149 char * p = setlocale(LC_NUMERIC,NULL);
150 char * old_locale = strdup(p);
151 setlocale(LC_NUMERIC,
"C");
152 wxFileConfig cfg(wxT(
"hugin lens file"),wxT(
""),filename);
153 cfg.Write(wxT(
"Lens/image_width"), (
long) lens.
getImageSize().x);
154 cfg.Write(wxT(
"Lens/image_height"), (
long) lens.
getImageSize().y);
156 cfg.Write(wxT(
"Lens/hfov"),
const_map_get(vars,
"v").getValue());
165 if (std::string(*varname) ==
"v")
170 wxString key(wxT(
"Lens/"));
171 key.append(wxString(*varname, wxConvLocal));
173 key.append(wxT(
"_link"));
180 cfg.Write(wxT(
"Lens/crop/autoCenter"), image.getAutoCenterCrop() ? 1l : 0l);
181 const vigra::Rect2D cropRect=image.getCropRect();
182 cfg.Write(wxT(
"Lens/crop/left"), cropRect.left());
183 cfg.Write(wxT(
"Lens/crop/top"), cropRect.top());
184 cfg.Write(wxT(
"Lens/crop/right"), cropRect.right());
185 cfg.Write(wxT(
"Lens/crop/bottom"), cropRect.bottom());
187 if (!image.getExifMake().empty() && !image.getExifModel().empty() && image.getExifFocalLength()>0)
190 cfg.Write(wxT(
"EXIF/CameraMake"), wxString(image.getExifMake().c_str(), wxConvLocal));
191 cfg.Write(wxT(
"EXIF/CameraModel"), wxString(image.getExifModel().c_str(), wxConvLocal));
192 cfg.Write(wxT(
"EXIF/FocalLength"), image.getExifFocalLength());
193 cfg.Write(wxT(
"EXIF/Aperture"), image.getExifAperture());
194 cfg.Write(wxT(
"EXIF/ISO"), image.getExifISO());
195 cfg.Write(wxT(
"EXIF/CropFactor"), image.getCropFactor());
196 cfg.Write(wxT(
"EXIF/Distance"), image.getExifDistance());
201 setlocale(LC_NUMERIC,old_locale);
210 bool autoCenterCrop=
false;
211 vigra::Rect2D cropRect;
217 for(HuginBase::UIntSet::const_iterator it=images.begin();it!=images.end();++it,++i)
220 for (HuginBase::LensVarMap::iterator it2 = lens.
variables.begin(); it2 != lens.
variables.end(); ++it2)
222 if (it2->second.getName() ==
"Eev" || it2->second.getName() ==
"Er" || it2->second.getName() ==
"Eb")
226 vars[i].find(it2->first)->second.setValue(it2->second.getValue());
233 std::vector<PanoCommand::PanoCommand*> cmds;
235 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
236 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> unlinkedVariables;
237 for (HuginBase::LensVarMap::iterator it = lens.
variables.begin(); it != lens.
variables.end(); ++it)
239 if(it->second.getName()==
"Eev" || it->second.getName() ==
"Er" || it->second.getName() ==
"Eb")
243 #define image_variable( name, type, default_value ) \
244 if (HuginBase::PTOVariableConverterFor##name::checkApplicability(it->second.getName()))\
246 if(it->second.isLinked())\
247 linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_##name);\
249 unlinkedVariables.insert(HuginBase::ImageVariableGroup::IVE_##name);\
252 #undef image_variable
254 if (!linkedVariables.empty())
259 if (!unlinkedVariables.empty())
270 cmds.push_back(
new PanoCommand::ChangeImageCropFactorCmd(*pano,images,lens.
getCropFactor()));
272 cmds.push_back(
new PanoCommand::ChangeImageAutoCenterCropCmd(*pano,images,autoCenterCrop));
275 cmds.push_back(
new PanoCommand::ChangeImageCropRectCmd(*pano,images,cropRect));
291 bool & cropped,
bool & autoCenterCrop, vigra::Rect2D & cropRect)
294 wxFileDialog dlg(parent,
295 _(
"Load lens parameters"),
296 wxConfigBase::Get()->Read(wxT(
"/lensPath"),wxT(
"")), wxT(
""),
297 _(
"Lens Project Files (*.ini)|*.ini|All files (*.*)|*.*"),
298 wxFD_OPEN, wxDefaultPosition);
299 dlg.SetDirectory(wxConfigBase::Get()->Read(wxT(
"/lensPath"),wxT(
"")));
300 if (dlg.ShowModal() == wxID_OK)
302 fname = dlg.GetPath();
303 wxConfig::Get()->Write(wxT(
"/lensPath"), dlg.GetDirectory());
305 char * p = setlocale(LC_NUMERIC,NULL);
306 char * old_locale = strdup(p);
307 setlocale(LC_NUMERIC,
"C");
309 wxFileConfig cfg(wxT(
"hugin lens file"),wxT(
""),fname);
311 cfg.Read(wxT(
"Lens/image_width"), &w);
313 cfg.Read(wxT(
"Lens/image_height"), &h);
316 if (w != sz.x || h != sz.y) {
317 std::cerr <<
"Image size: " << sz <<
" size in lens parameter file: " << w <<
"x" << h << std::endl;
318 int ret = wxMessageBox(_(
"Incompatible lens parameter file, image sizes do not match\nApply settings anyway?"), _(
"Error loading lens parameters"), wxICON_QUESTION |wxYES_NO);
320 setlocale(LC_NUMERIC,old_locale);
330 if(cfg.Read(wxT(
"Lens/type"), &integer))
335 if(cfg.Read(wxT(
"Lens/crop"), &d))
341 if(cfg.Read(wxT(
"Lens/hfov"), &d))
346 if(cfg.Read(wxT(
"Lens/hfov_linked"), &integer))
355 wxString key(wxT(
"Lens/"));
356 key.append(wxString(*varname, wxConvLocal));
358 if (cfg.Read(key,&d))
363 key.append(wxT(
"_link"));
364 if(cfg.Read(key, &integer))
374 cfg.Read(wxT(
"Lens/crop/enabled"), &v);
382 if(cfg.Read(wxT(
"Lens/crop/left"), &left) && cfg.Read(wxT(
"Lens/crop/top"), &top) &&
383 cfg.Read(wxT(
"Lens/crop/right"), &right) && cfg.Read(wxT(
"Lens/crop/bottom"), &bottom))
386 cropRect=vigra::Rect2D(left,top,right,bottom);
394 if(cfg.Read(wxT(
"Lens/crop/autoCenter"), &v))
396 autoCenterCrop=(v!=0);
400 setlocale(LC_NUMERIC,old_locale);
412 if (images.size() == 1)
414 unsigned int imgNr = *(images.begin());
415 wxFileDialog dlg(parent,
416 _(
"Save lens parameters file"),
417 wxConfigBase::Get()->Read(wxT(
"/lensPath"),wxT(
"")), wxT(
""),
418 _(
"Lens Project Files (*.ini)|*.ini|All files (*)|*"),
419 wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
420 dlg.SetDirectory(wxConfigBase::Get()->Read(wxT(
"/lensPath"),wxT(
"")));
421 if (dlg.ShowModal() == wxID_OK)
423 wxFileName filename(dlg.GetPath());
424 if(!filename.HasExt())
426 filename.SetExt(wxT(
"ini"));
427 if (filename.Exists())
429 int d = wxMessageBox(wxString::Format(_(
"File %s exists. Overwrite?"), filename.GetFullPath().c_str()),
430 _(
"Save project"), wxYES_NO | wxICON_QUESTION);
436 wxConfig::Get()->Write(wxT(
"/lensPath"), dlg.GetDirectory());
442 wxLogError(_(
"Please select an image and try again"));
453 bool stacksCorrectLinked =
true;
454 for (
size_t i = 0; i < nrImages - 1; ++i)
457 if (image1.YawisLinked())
459 for (
size_t j = i + 1; j < nrImages && stacksCorrectLinked; ++j)
462 if (image1.YawisLinkedWith(image2))
464 stacksCorrectLinked = stacksCorrectLinked &&
465 image1.HFOVisLinkedWith(image2) &&
466 image1.RadialDistortionisLinkedWith(image2) &&
467 image1.RadialDistortionCenterShiftisLinkedWith(image2) &&
468 image1.ShearisLinkedWith(image2);
473 if (stacksCorrectLinked)
479 int flags = wxICON_EXCLAMATION | wxOK;
482 flags = flags | wxCANCEL;
484 if (wxMessageBox(_(
"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."),
501 namespace FormatString
506 struct tm exifdatetime;
509 wxDateTime s_datetime = wxDateTime(exifdatetime);
510 s = s_datetime.Format();
514 s = wxString(img->getExifDate().c_str(), wxConvLocal);
522 if (img->getExifFocalLength() > 0.0)
524 if (img->getExifFocalLength35() > 0.0)
526 s = wxString::Format(wxT(
"%0.1f mm (%0.0f mm)"), img->getExifFocalLength(), img->getExifFocalLength35());
530 s = wxString::Format(wxT(
"%0.1f mm"), img->getExifFocalLength());
543 if (img->getExifAperture() > 0)
545 s = wxString::Format(wxT(
"F%.1f"), img->getExifAperture());
557 const double exposureTime = img->getExifExposureTime();
558 if (exposureTime > 0.5)
560 if (exposureTime >= 1.0)
562 if (exposureTime >= 10.0)
564 s = wxString::Format(wxT(
"%3.0f s"), exposureTime);
568 s = wxString::Format(wxT(
"%1.1f s"), exposureTime);
573 s = wxString::Format(wxT(
"%1.2f s"), exposureTime);
578 if (exposureTime > 1e-9)
580 s = wxString::Format(wxT(
"1/%0.0f s"), 1.0 / exposureTime);
594 if (img->getExifISO() > 0)
596 s = wxString::Format(wxT(
"%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
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.
Lens getLensForImage(std::size_t imgNr)
Get the lens object for a specific image, also not for new code.