Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
wxLensDB.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
10 /* This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This software is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public
21  * License along with this software. If not, see
22  * <http://www.gnu.org/licenses/>.
23  *
24  */
25 
26 #include "panoinc_WX.h"
27 #include "panoinc.h"
28 #include "wxLensDB.h"
29 #include "lensdb/LensDB.h"
30 #include "platform.h"
31 #include "base_wx/wxPlatform.h"
34 #include "base_wx/PanoCommand.h"
35 #include <set>
36 #include "base_wx/wxutils.h"
37 
39 class LoadLensDBDialog : public wxDialog
40 {
41 public:
43  explicit LoadLensDBDialog(wxWindow *parent);
44  void SetLensName(std::string lensname);
45  std::string GetLensName() const;
46  void SetFocalLength(double focal);
47  double GetFocalLength() const;
48  void SetAperture(double aperture);
49  double GetAperture() const;
50  void SetSubjectDistance(double distance);
51  double GetSubjectDistance() const;
52  bool GetLoadDistortion() const;
53  bool GetLoadVignetting() const;
54 
55 protected:
57  void OnOk(wxCommandEvent & e);
58  void OnCheckChanged(wxCommandEvent & e);
59 
60 private:
61  void FillLensList();
62  wxChoice *m_lenslist;
63  wxCheckBox *m_loadDistortion;
64  wxCheckBox *m_loadVignetting;
65  double m_focal{ 0 };
66  double m_aperture{ 0 };
67  double m_distance{ 0 };
69 };
70 
72 {
73  // load our children. some children might need special
74  // initialization. this will be done later.
75  wxXmlResource::Get()->LoadDialog(this, parent, "load_lens_dlg");
76 
77  //set parameters
78  wxConfigBase * config = wxConfigBase::Get();
79  // get display size
80  int dx,dy;
81  wxDisplaySize(&dx,&dy);
82  int w = config->Read("/LoadLensDialog/width",-1l);
83  int h = config->Read("/LoadLensDialog/height",-1l);
84  if (w>0 && w<=dx && h>0 && h<=dy)
85  {
86  SetClientSize(w,h);
87  }
88  else
89  {
90  Fit();
91  }
92  //position
93  int x = config->Read("/LoadLensDialog/positionX",-1l);
94  int y = config->Read("/LoadLensDialog/positionY",-1l);
95  if ( y >= 0 && x >= 0)
96  {
97  this->Move(x, y);
98  }
99  else
100  {
101  this->Move(0, 44);
102  };
103  bool b;
104  config->Read("/LoadLensDialog/loadDistortion", &b, true);
105  m_loadDistortion = XRCCTRL(*this, "load_lens_distortion", wxCheckBox);
106  m_loadDistortion->SetValue(b);
107  m_loadDistortion->Bind(wxEVT_CHECKBOX, &LoadLensDBDialog::OnCheckChanged, this);
108  config->Read("/LoadLensDialog/loadVignetting", &b, true);
109  m_loadVignetting = XRCCTRL(*this, "load_lens_vignetting", wxCheckBox);
110  m_loadVignetting->SetValue(b);
111  m_loadVignetting->Bind(wxEVT_CHECKBOX, &LoadLensDBDialog::OnCheckChanged, this);
112  m_lenslist=XRCCTRL(*this,"load_lens_lenschoice", wxChoice);
113  FillLensList();
114  m_lenslist->Bind(wxEVT_CHOICE, &LoadLensDBDialog::OnCheckChanged, this);
115  Bind(wxEVT_BUTTON, &LoadLensDBDialog::OnOk, this, wxID_OK);
116 };
117 
119 {
120  if (HuginBase::LensDB::LensDB::GetSingleton().GetLensNames(true, true, false, m_lensNames))
121  {
122  wxArrayString lensnames;
123  for (HuginBase::LensDB::LensList::const_iterator it = m_lensNames.begin(); it != m_lensNames.end(); ++it)
124  {
125  wxString s((*it).c_str(), wxConvLocal);
126  wxString cam = s.AfterFirst('|');
127  if (!cam.empty())
128  {
129  s = wxString::Format(_("Camera %s (%s)"), cam.c_str(), s.BeforeFirst('|').c_str());
130  };
131  lensnames.Add(s);
132  };
133  m_lenslist->Append(lensnames);
134  };
135 };
136 
137 void LoadLensDBDialog::SetLensName(std::string lensname)
138 {
139  if (!lensname.empty() && !m_lensNames.empty())
140  {
141  HuginBase::LensDB::LensList::const_iterator it=std::find(m_lensNames.begin(), m_lensNames.end(), lensname);
142  if (it != m_lensNames.end())
143  {
144  m_lenslist->SetSelection(it - m_lensNames.begin());
145  };
146  };
147  wxCommandEvent dummy;
148  OnCheckChanged(dummy);
149 };
150 
151 std::string LoadLensDBDialog::GetLensName() const
152 {
153  return m_lensNames[m_lenslist->GetSelection()];
154 };
155 
157 {
158  m_focal=focal;
159  XRCCTRL(*this,"load_lens_focallength",wxTextCtrl)->SetValue(hugin_utils::doubleTowxString(m_focal,1));
160 };
161 
163 {
164  return m_focal;
165 };
166 
167 void LoadLensDBDialog::SetAperture(double aperture)
168 {
169  m_aperture=aperture;
170  XRCCTRL(*this,"load_lens_aperture",wxTextCtrl)->SetValue(hugin_utils::doubleTowxString(m_aperture,1));
171 };
172 
174 {
175  return m_aperture;
176 };
177 
179 {
180  m_distance=distance;
181  XRCCTRL(*this,"load_lens_distance",wxTextCtrl)->SetValue(hugin_utils::doubleTowxString(m_distance,0));
182 };
183 
185 {
186  return m_distance;
187 };
188 
190 {
191  return m_loadDistortion->GetValue();
192 };
193 
195 {
196  return m_loadVignetting->GetValue();
197 };
198 
199 // utility functions
200 bool str2double(wxWindow* parent, wxString s, double & d)
201 {
202  if (!hugin_utils::stringToDouble(std::string(s.mb_str(wxConvLocal)), d))
203  {
204  hugin_utils::HuginMessageBox(wxString::Format(_("The input \"%s\" is not a valid number."), s), _("Hugin"), wxOK | wxICON_ERROR, parent);
205  return false;
206  }
207  return true;
208 }
209 
210 void LoadLensDBDialog::OnOk(wxCommandEvent & e)
211 {
212  if(!m_loadDistortion->GetValue() && !m_loadVignetting->GetValue())
213  {
214  return;
215  };
216  if(m_lenslist->GetSelection()==wxNOT_FOUND)
217  {
218  wxBell();
219  return;
220  };
221  if(!str2double(this,XRCCTRL(*this,"load_lens_focallength",wxTextCtrl)->GetValue(),m_focal))
222  {
223  return;
224  };
225  if(m_loadVignetting->GetValue())
226  {
227  wxString val = XRCCTRL(*this, "load_lens_aperture", wxTextCtrl)->GetValue().Trim();
228  if (val.empty())
229  {
230  m_aperture = 0;
231  }
232  else
233  {
234  if (!str2double(this, val, m_aperture))
235  {
236  return;
237  };
238  };
239  val = XRCCTRL(*this, "load_lens_distance", wxTextCtrl)->GetValue().Trim();
240  if (val.empty())
241  {
242  m_distance = 0;
243  }
244  else
245  {
246  if (!str2double(this, val, m_distance))
247  {
248  return;
249  };
250  };
251  };
252  //store selected options
253  wxConfigBase * config = wxConfigBase::Get();
254  wxSize sz = this->GetClientSize();
255  config->Write("/LoadLensDialog/width", sz.GetWidth());
256  config->Write("/LoadLensDialog/height", sz.GetHeight());
257  wxPoint ps = this->GetPosition();
258  config->Write("/LoadLensDialog/positionX", ps.x);
259  config->Write("/LoadLensDialog/positionY", ps.y);
260  config->Write("/LoadLensDialog/loadDistortion",m_loadDistortion->GetValue());
261  config->Write("/LoadLensDialog/loadVignetting",m_loadVignetting->GetValue());
262  config->Flush();
263  e.Skip();
264 };
265 
266 void LoadLensDBDialog::OnCheckChanged(wxCommandEvent & e)
267 {
268  const int sel = m_lenslist->GetSelection();
269  XRCCTRL(*this,"wxID_OK",wxButton)->Enable(sel!=wxNOT_FOUND && (m_loadDistortion->GetValue() || m_loadVignetting->GetValue()));
270 };
271 
273 {
274  LoadLensDBDialog dlg(parent);
275  const HuginBase::SrcPanoImage & img=pano->getImage(*images.begin());
276  dlg.SetLensName(img.getDBLensName());
277  dlg.SetFocalLength(img.getExifFocalLength());
278  dlg.SetAperture(img.getExifAperture());
279  dlg.SetSubjectDistance(img.getExifDistance());
280  if(dlg.ShowModal()==wxID_OK)
281  {
283  const double focal=dlg.GetFocalLength();
284  const std::string lensname = dlg.GetLensName();
285  std::vector<PanoCommand::PanoCommand*> cmds;
287  if(lensDB.GetProjection(lensname, proj))
288  {
289  cmds.push_back(new PanoCommand::ChangeImageProjectionCmd(*pano,images,proj));
290  };
291  vigra::Rect2D cropRect;
292  if(lensDB.GetCrop(lensname, focal, img.getSize(), cropRect))
293  {
294  cmds.push_back(new PanoCommand::ChangeImageCropModeCmd(*pano, images, img.isCircularCrop() ? HuginBase::BaseSrcPanoImage::CROP_CIRCLE : HuginBase::BaseSrcPanoImage::CROP_RECTANGLE));
295  cmds.push_back(new PanoCommand::ChangeImageCropRectCmd(*pano, images, cropRect));
296  };
297  //load lens distortion from database
298  if(dlg.GetLoadDistortion())
299  {
300  double hfov;
301  if (lensDB.GetFov(lensname, focal, hfov))
302  {
303  // calculate FOV for given image, take different aspect ratios into account
304  const double newFocal = HuginBase::SrcPanoImage::calcFocalLength(img.getProjection(), hfov, img.getCropFactor(), vigra::Size2D(3000, 2000));
305  const double newFov = HuginBase::SrcPanoImage::calcHFOV(img.getProjection(), newFocal, img.getCropFactor(), img.getSize());
306  std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
307  linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_HFOV);
308  cmds.push_back(new PanoCommand::ChangePartImagesLinkingCmd(*pano, images, linkedVariables,
310  cmds.push_back(new PanoCommand::ChangeImageHFOVCmd(*pano, images, newFov));
311  };
312  std::vector<double> dist;
313  if(lensDB.GetDistortion(lensname, focal, dist))
314  {
315  if (dist.size() == 3)
316  {
317  dist.push_back(1.0 - dist[0] - dist[1] - dist[2]);
318  std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
319  linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_RadialDistortion);
320  cmds.push_back(new PanoCommand::ChangePartImagesLinkingCmd(*pano, images, linkedVariables,
322  cmds.push_back(new PanoCommand::ChangeImageRadialDistortionCmd(*pano, images, dist));
323  };
324  };
325  };
326  if(dlg.GetLoadVignetting())
327  {
328  std::vector<double> vig;
329  if (lensDB.GetVignetting(lensname, focal, dlg.GetAperture(), dlg.GetSubjectDistance(), vig))
330  {
331  if (vig.size() == 4)
332  {
333  std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
334  linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_RadialVigCorrCoeff);
335  cmds.push_back(new PanoCommand::ChangePartImagesLinkingCmd(*pano, images, linkedVariables,
337  cmds.push_back(new PanoCommand::ChangeImageRadialVigCorrCoeffCmd(*pano, images, vig));
338  };
339  };
340  };
341  cmd=new PanoCommand::CombinedPanoCommand(*pano, cmds);
342  return true;
343  };
344  return false;
345 };
346 
348 class SaveLensDBDialog : public wxDialog
349 {
350 public:
352  explicit SaveLensDBDialog(wxWindow *parent);
353  void SetCameraMaker(std::string maker);
354  std::string GetCameraMaker() const;
355  void SetCameraModel(std::string model);
356  std::string GetCameraModel() const;
357  void SetLensName(std::string lensname);
358  std::string GetLensName() const;
359  std::string GetLensMaker() const;
360  void SetFocalLength(double focal);
361  double GetFocalLength() const;
362  void SetAperture(double aperture);
363  double GetAperture() const;
364  void SetSubjectDistance(double distance);
365  double GetSubjectDistance() const;
366  bool GetSaveDistortion() const;
367  bool GetSaveVignetting() const;
369 
370 protected:
372  void OnOk(wxCommandEvent & e);
373  void OnCheckChanged(wxCommandEvent & e);
374 
375 private:
376  wxCheckBox *m_saveDistortion;
377  wxCheckBox *m_saveVignetting;
378  double m_focal { 0 };
379  double m_aperture{ 0 };
380  double m_distance{ 0 };
381 };
382 
384 {
385  // load our children. some children might need special
386  // initialization. this will be done later.
387  wxXmlResource::Get()->LoadDialog(this, parent, "save_lens_dlg");
388 
389  //set parameters
390  wxConfigBase * config = wxConfigBase::Get();
391  // get display size
392  int dx,dy;
393  wxDisplaySize(&dx,&dy);
394  int w = config->Read("/SaveLensDialog/width",-1l);
395  int h = config->Read("/SaveLensDialog/height",-1l);
396  if (w>0 && w<=dx && h>0 && h<=dy)
397  {
398  SetClientSize(w,h);
399  }
400  else
401  {
402  Fit();
403  }
404  //position
405  int x = config->Read("/SaveLensDialog/positionX",-1l);
406  int y = config->Read("/SaveLensDialog/positionY",-1l);
407  if ( y >= 0 && x >= 0)
408  {
409  this->Move(x, y);
410  }
411  else
412  {
413  this->Move(0, 44);
414  };
415  bool b;
416  config->Read("/SaveLensDialog/saveDistortion",&b,true);
417  m_saveDistortion=XRCCTRL(*this,"save_lens_distortion",wxCheckBox);
418  m_saveDistortion->SetValue(b);
419  m_saveDistortion->Bind(wxEVT_CHECKBOX, &SaveLensDBDialog::OnCheckChanged, this);
420  config->Read("/SaveLensDialog/saveVignetting",&b,true);
421  m_saveVignetting=XRCCTRL(*this,"save_lens_vignetting",wxCheckBox);
422  m_saveVignetting->SetValue(b);
423  m_saveVignetting->Bind(wxEVT_CHECKBOX, &SaveLensDBDialog::OnCheckChanged, this);
424  Bind(wxEVT_BUTTON, &SaveLensDBDialog::OnOk, this, wxID_OK);
425 };
426 
427 void SaveLensDBDialog::SetCameraMaker(std::string maker)
428 {
429  if(!maker.empty())
430  {
431  XRCCTRL(*this,"save_lens_camera_maker",wxTextCtrl)->SetValue(wxString(maker.c_str(), wxConvLocal));
432  };
433 };
434 
436 {
437  return std::string(XRCCTRL(*this,"save_lens_camera_maker",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
438 };
439 
440 void SaveLensDBDialog::SetCameraModel(std::string model)
441 {
442  if(!model.empty())
443  {
444  XRCCTRL(*this,"save_lens_camera_model",wxTextCtrl)->SetValue(wxString(model.c_str(), wxConvLocal));
445  };
446 };
447 
449 {
450  return std::string(XRCCTRL(*this,"save_lens_camera_model",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
451 };
452 
453 void SaveLensDBDialog::SetLensName(std::string lensname)
454 {
455  if(!lensname.empty())
456  {
457  XRCCTRL(*this,"save_lens_name",wxTextCtrl)->SetValue(wxString(lensname.c_str(), wxConvLocal));
458  };
459 };
460 
461 std::string SaveLensDBDialog::GetLensName() const
462 {
463  return std::string(XRCCTRL(*this,"save_lens_name",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
464 };
465 
467 {
468  return std::string(XRCCTRL(*this,"save_lens_maker",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
469 };
470 
472 {
473  m_focal=focal;
474  XRCCTRL(*this,"save_lens_focallength",wxTextCtrl)->SetValue(hugin_utils::doubleTowxString(m_focal,1));
475 };
476 
478 {
479  return m_focal;
480 };
481 
482 void SaveLensDBDialog::SetAperture(double aperture)
483 {
484  m_aperture=aperture;
485  XRCCTRL(*this,"save_lens_aperture",wxTextCtrl)->SetValue(hugin_utils::doubleTowxString(m_aperture,1));
486 };
487 
489 {
490  return m_aperture;
491 };
492 
494 {
495  m_distance=distance;
496  XRCCTRL(*this,"save_lens_distance",wxTextCtrl)->SetValue(hugin_utils::doubleTowxString(m_distance,0));
497 };
498 
500 {
501  return m_distance;
502 };
503 
505 {
506  return m_saveDistortion->GetValue();
507 };
508 
510 {
511  return m_saveVignetting->GetValue();
512 };
513 
515 {
516  m_saveVignetting->SetValue(false);
517  m_saveVignetting->Disable();
518 };
519 
520 void SaveLensDBDialog::OnOk(wxCommandEvent & e)
521 {
522  if(!m_saveDistortion->GetValue() && !m_saveVignetting->GetValue())
523  {
524  return;
525  };
526  if(GetLensName().empty() && (GetCameraMaker().empty() || GetCameraModel().empty()))
527  {
528  hugin_utils::HuginMessageBox(_("There is too little information for saving data into database. Please check your input!"), _("Hugin"), wxOK | wxICON_ERROR, this);
529  return;
530  };
531  if(!str2double(this,XRCCTRL(*this,"save_lens_focallength",wxTextCtrl)->GetValue(),m_focal))
532  {
533  return;
534  };
535  if(m_saveVignetting->GetValue())
536  {
537  wxString val = XRCCTRL(*this, "save_lens_aperture", wxTextCtrl)->GetValue().Trim();
538  if (val.empty())
539  {
540  m_aperture = 0;
541  }
542  else
543  {
544  if (!str2double(this, val, m_aperture))
545  {
546  return;
547  };
548  };
549  val = XRCCTRL(*this, "save_lens_distance", wxTextCtrl)->GetValue().Trim();
550  if (val.empty())
551  {
552  m_distance = 0;
553  }
554  else
555  {
556  if (!str2double(this, val, m_distance))
557  {
558  return;
559  };
560  };
561  };
562  //store selected options
563  wxConfigBase * config = wxConfigBase::Get();
564  wxSize sz = this->GetClientSize();
565  config->Write("/SaveLensDialog/width", sz.GetWidth());
566  config->Write("/SaveLensDialog/height", sz.GetHeight());
567  wxPoint ps = this->GetPosition();
568  config->Write("/SaveLensDialog/positionX", ps.x);
569  config->Write("/SaveLensDialog/positionY", ps.y);
570  config->Write("/SaveLensDialog/saveDistortion",m_saveDistortion->GetValue());
571  if(m_saveVignetting->IsEnabled())
572  {
573  config->Write("/SaveLensDialog/saveVignetting",m_saveVignetting->GetValue());
574  };
575  config->Flush();
576  e.Skip();
577 };
578 
579 void SaveLensDBDialog::OnCheckChanged(wxCommandEvent & e)
580 {
581  XRCCTRL(*this,"wxID_OK",wxButton)->Enable(m_saveDistortion->GetValue() || m_saveVignetting->GetValue());
582 };
583 
584 bool SaveLensParameters(wxWindow * parent, const HuginBase::SrcPanoImage& img, bool includeVignetting)
585 {
587  // show dialog
588  SaveLensDBDialog lensDlg(parent);
589  lensDlg.SetCameraMaker(img.getExifMake());
590  lensDlg.SetCameraModel(img.getExifModel());
591  lensDlg.SetLensName(img.getDBLensName());
592  lensDlg.SetFocalLength(img.getExifFocalLength());
593  lensDlg.SetAperture(img.getExifAperture());
594  lensDlg.SetSubjectDistance(img.getExifDistance());
595  if (!includeVignetting)
596  {
597  lensDlg.DeactivateSaveVignetting();
598  };
599  if (lensDlg.ShowModal() != wxID_OK)
600  {
601  return false;
602  };
603  const std::string camMaker = lensDlg.GetCameraMaker();
604  const std::string camModel = lensDlg.GetCameraModel();
605  std::string lensname = lensDlg.GetLensName();
606  const double focal = lensDlg.GetFocalLength();
607  if (lensname.empty())
608  {
609  //empty lensname, assuming it is a compact camera
610  lensname = camMaker + "|" + camModel;
611  };
612  // unknown crop factor, remember it
613  if (img.getExifCropFactor() < 0.1 && !camMaker.empty() && !camModel.empty())
614  {
615  lensDB.SaveCameraCrop(camMaker, camModel, img.getCropFactor());
616  };
617  if (lensDlg.GetSaveDistortion())
618  {
619  const double newFocallength = HuginBase::SrcPanoImage::calcFocalLength(img.getProjection(), img.getHFOV(), img.getCropFactor(), img.getSize());
620  const double newHFOV = HuginBase::SrcPanoImage::calcHFOV(img.getProjection(), newFocallength, img.getCropFactor(), vigra::Size2D(3000, 2000));
621  // save information with higher weight
622  if (!lensDB.SaveLensFov(lensname, lensDlg.GetFocalLength(), newHFOV, 75))
623  {
624  hugin_utils::HuginMessageBox(_("Could not save information into database."), _("Hugin"), wxOK | wxICON_ERROR, parent);
625  return false;
626  };
627  if (!lensDB.SaveDistortion(lensname, focal, img.getRadialDistortion(), 75))
628  {
629  hugin_utils::HuginMessageBox(_("Could not save information into database."), _("Hugin"), wxOK | wxICON_ERROR, parent);
630  return false;
631  };
632  };
633  if(lensDlg.GetSaveVignetting())
634  {
635  if (!lensDB.SaveVignetting(lensname, focal, lensDlg.GetAperture(), lensDlg.GetSubjectDistance(), img.getRadialVigCorrCoeff(), 75))
636  {
637  hugin_utils::HuginMessageBox(_("Could not save information into database."), _("Hugin"), wxOK | wxICON_ERROR, parent);
638  return false;
639  };
640  };
641  return true;
642 };
643 
wxCheckBox * m_saveDistortion
Definition: wxLensDB.cpp:376
Base class for all panorama commands.
Definition: Command.h:38
void SetSubjectDistance(double distance)
Definition: wxLensDB.cpp:178
void OnOk(wxCommandEvent &e)
Saves current state of all checkboxes when closing dialog with Ok.
Definition: wxLensDB.cpp:520
static const std::set< ConstImageVariableGroup::ImageVariableEnum > & getLensVariables()
Get the set of lens image variables.
implementation of huginApp Class
SaveLensDBDialog(wxWindow *parent)
Constructor, read from xrc ressource; restore last uses settings, size and position.
Definition: wxLensDB.cpp:383
bool GetLoadVignetting() const
Definition: wxLensDB.cpp:194
bool SaveVignetting(const std::string &lens, const double focal, const double aperture, const double distance, const std::vector< double > &vignetting, const int weight=10)
saves the vignetting parameters of the lens
Definition: LensDB.cpp:2490
double GetAperture() const
Definition: wxLensDB.cpp:488
Change the linking of some variables across parts of an ImageVariableGroup containing some specified ...
Definition: PanoCommand.h:524
double GetFocalLength() const
Definition: wxLensDB.cpp:162
bool GetSaveVignetting() const
Definition: wxLensDB.cpp:509
static LensDB & GetSingleton()
returns the static LensDB instance
Definition: LensDB.cpp:2001
bool isCircularCrop() const
returns true, if projection requires cicular crop
bool ApplyLensDBParameters(wxWindow *parent, HuginBase::Panorama *pano, HuginBase::UIntSet images, PanoCommand::PanoCommand *&cmd)
loads the lens parameters from lens database and create approbiate PanoCommand::PanoCommand to apply ...
Definition: wxLensDB.cpp:272
bool GetVignetting(const std::string &lens, const double focal, const double aperture, const double distance, std::vector< double > &vignetting) const
returns the vignetting parameters of the lens
Definition: LensDB.cpp:2205
std::string getDBLensName() const
constructs the lens name for the database it is the lensname if known, for compact cameras it is cons...
bool GetProjection(const std::string &lens, BaseSrcPanoImage::Projection &projection) const
returns the projection of the lens
Definition: LensDB.cpp:2040
bool GetCrop(const std::string &lens, const double focal, const vigra::Size2D &imageSize, vigra::Rect2D &cropRect) const
returns the crop of the lens the information for landscape and portrait images are stored separately ...
Definition: LensDB.cpp:2073
void SetFocalLength(double focal)
Definition: wxLensDB.cpp:156
double GetSubjectDistance() const
Definition: wxLensDB.cpp:499
wxString doubleTowxString(double d, int digits)
Definition: wxPlatform.cpp:31
include file for the hugin project
HuginBase::LensDB::LensList m_lensNames
Definition: wxLensDB.cpp:68
Declare the ImageVariableGroup and ImageVariableGroupObserver classes.
bool GetDistortion(const std::string &lens, const double focal, std::vector< double > &distortion) const
returns the distortion parameters of the lens
Definition: LensDB.cpp:2162
dialog for saving lens parameter into lens database
Definition: wxLensDB.cpp:348
PanoCommand to combine other PanoCommands.
Definition: PanoCommand.h:39
std::string GetCameraMaker() const
Definition: wxLensDB.cpp:435
main database class
Definition: LensDB.h:44
dialog for loading lens parameter from lens database
Definition: wxLensDB.cpp:39
std::set< unsigned int > UIntSet
Definition: PanoramaData.h:51
bool SaveCameraCrop(const std::string &maker, const std::string &model, const double cropfactor)
save the camera with the given cropfactor into the database
Definition: LensDB.cpp:2429
class to access Hugins camera and lens database
Model for a panorama.
Definition: Panorama.h:152
double GetAperture() const
Definition: wxLensDB.cpp:173
void OnCheckChanged(wxCommandEvent &e)
Definition: wxLensDB.cpp:579
double GetSubjectDistance() const
Definition: wxLensDB.cpp:184
void SaveLensParameters(const wxString filename, HuginBase::Panorama *pano, unsigned int imgNr)
save the lens parameters of the image to a lens file named filename
Definition: LensTools.cpp:144
double m_distance
Definition: wxLensDB.cpp:67
void OnCheckChanged(wxCommandEvent &e)
Definition: wxLensDB.cpp:266
void SetAperture(double aperture)
Definition: wxLensDB.cpp:167
bool GetFov(const std::string &lens, const double focal, double &fov) const
returns the field of view of the lens the fov is always returned for a landscape image with aspect ra...
Definition: LensDB.cpp:2119
std::string GetLensName() const
Definition: wxLensDB.cpp:461
wxCheckBox * m_saveVignetting
Definition: wxLensDB.cpp:377
IMPEX double h[25][1024]
Definition: emor.cpp:169
static double calcFocalLength(SrcPanoImage::Projection proj, double hfov, double crop, vigra::Size2D imageSize)
calcualte focal length, given crop factor and hfov
void SetFocalLength(double focal)
Definition: wxLensDB.cpp:471
bool stringToDouble(const STR &str_, double &dest)
convert a string to a double, ignore localisation.
Definition: utils.h:114
dialogs for loading and saving information from/to lens database
void OnOk(wxCommandEvent &e)
Saves current state of all checkboxes when closing dialog with Ok.
Definition: wxLensDB.cpp:210
bool GetSaveDistortion() const
Definition: wxLensDB.cpp:504
include file for the hugin project
Convenience functions for SrcPanoImage to use on the image variables.
void SetLensName(std::string lensname)
Definition: wxLensDB.cpp:137
void SetSubjectDistance(double distance)
Definition: wxLensDB.cpp:493
wxCheckBox * m_loadVignetting
Definition: wxLensDB.cpp:64
void DeactivateSaveVignetting()
Definition: wxLensDB.cpp:514
bool SaveDistortion(const std::string &lens, const double focal, const std::vector< double > &distortion, const int weight=10)
saves the distortion parameters of the lens in the database
Definition: LensDB.cpp:2481
std::vector< std::string > LensList
vector storing a list of lens names
Definition: LensDB.h:41
void SetCameraMaker(std::string maker)
Definition: wxLensDB.cpp:427
std::string GetCameraModel() const
Definition: wxLensDB.cpp:448
LoadLensDBDialog(wxWindow *parent)
Constructor, read from xrc ressource; restore last uses settings, size and position.
Definition: wxLensDB.cpp:71
static double calcHFOV(SrcPanoImage::Projection proj, double fl, double crop, vigra::Size2D imageSize)
calculate hfov of an image given focal length, image size and crop factor
platform/compiler specific stuff.
void FillLensList()
Definition: wxLensDB.cpp:118
std::string GetLensMaker() const
Definition: wxLensDB.cpp:466
void SetCameraModel(std::string model)
Definition: wxLensDB.cpp:440
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
Definition: Panorama.h:211
void SetAperture(double aperture)
Definition: wxLensDB.cpp:482
All variables of a source image.
Definition: SrcPanoImage.h:194
bool SaveLensFov(const std::string &lens, const double focal, const double fov, const int weight=10)
saves the field of view of the lens the fov should always calculated for a landscape image with aspec...
Definition: LensDB.cpp:2472
double m_aperture
Definition: wxLensDB.cpp:66
void SetLensName(std::string lensname)
Definition: wxLensDB.cpp:453
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
Definition: wxutils.cpp:176
wxCheckBox * m_loadDistortion
Definition: wxLensDB.cpp:63
wxChoice * m_lenslist
Definition: wxLensDB.cpp:62
bool str2double(wxWindow *parent, wxString s, double &d)
Definition: wxLensDB.cpp:200
bool GetLoadDistortion() const
Definition: wxLensDB.cpp:189
double GetFocalLength() const
Definition: wxLensDB.cpp:477
std::string GetLensName() const
Definition: wxLensDB.cpp:151