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 
38 class LoadLensDBDialog : public wxDialog
39 {
40 public:
42  explicit LoadLensDBDialog(wxWindow *parent);
43  void SetLensName(std::string lensname);
44  std::string GetLensName() const;
45  void SetFocalLength(double focal);
46  double GetFocalLength() const;
47  void SetAperture(double aperture);
48  double GetAperture() const;
49  void SetSubjectDistance(double distance);
50  double GetSubjectDistance() const;
51  bool GetLoadDistortion() const;
52  bool GetLoadVignetting() const;
53 
54 protected:
56  void OnOk(wxCommandEvent & e);
57  void OnCheckChanged(wxCommandEvent & e);
58 
59 private:
60  void FillLensList();
61  wxChoice *m_lenslist;
62  wxCheckBox *m_loadDistortion;
63  wxCheckBox *m_loadVignetting;
64  double m_focal;
65  double m_aperture;
66  double m_distance;
68  DECLARE_EVENT_TABLE()
69 };
70 
71 BEGIN_EVENT_TABLE(LoadLensDBDialog,wxDialog)
72  EVT_BUTTON(wxID_OK, LoadLensDBDialog::OnOk)
73  EVT_CHOICE(XRCID("load_lens_lenschoice"), LoadLensDBDialog::OnCheckChanged)
74  EVT_CHECKBOX(XRCID("load_lens_distortion"), LoadLensDBDialog::OnCheckChanged)
75  EVT_CHECKBOX(XRCID("load_lens_vignetting"), LoadLensDBDialog::OnCheckChanged)
77 
79 {
80  // load our children. some children might need special
81  // initialization. this will be done later.
82  wxXmlResource::Get()->LoadDialog(this, parent, wxT("load_lens_dlg"));
83 
84  //set parameters
85  wxConfigBase * config = wxConfigBase::Get();
86  // get display size
87  int dx,dy;
88  wxDisplaySize(&dx,&dy);
89  int w = config->Read(wxT("/LoadLensDialog/width"),-1l);
90  int h = config->Read(wxT("/LoadLensDialog/height"),-1l);
91  if (w>0 && w<=dx && h>0 && h<=dy)
92  {
93  SetClientSize(w,h);
94  }
95  else
96  {
97  Fit();
98  }
99  //position
100  int x = config->Read(wxT("/LoadLensDialog/positionX"),-1l);
101  int y = config->Read(wxT("/LoadLensDialog/positionY"),-1l);
102  if ( y >= 0 && x >= 0)
103  {
104  this->Move(x, y);
105  }
106  else
107  {
108  this->Move(0, 44);
109  };
110  bool b;
111  config->Read(wxT("/LoadLensDialog/loadDistortion"), &b, true);
112  m_loadDistortion = XRCCTRL(*this, "load_lens_distortion", wxCheckBox);
113  m_loadDistortion->SetValue(b);
114  config->Read(wxT("/LoadLensDialog/loadVignetting"), &b, true);
115  m_loadVignetting = XRCCTRL(*this, "load_lens_vignetting", wxCheckBox);
116  m_loadVignetting->SetValue(b);
117  m_lenslist=XRCCTRL(*this,"load_lens_lenschoice", wxChoice);
118  FillLensList();
119 };
120 
122 {
123  if (HuginBase::LensDB::LensDB::GetSingleton().GetLensNames(true, true, false, m_lensNames))
124  {
125  wxArrayString lensnames;
126  for (HuginBase::LensDB::LensList::const_iterator it = m_lensNames.begin(); it != m_lensNames.end(); ++it)
127  {
128  wxString s((*it).c_str(), wxConvLocal);
129  wxString cam = s.AfterFirst(wxT('|'));
130  if (!cam.empty())
131  {
132  s = wxString::Format(_("Camera %s (%s)"), cam.c_str(), s.BeforeFirst(wxT('|')).c_str());
133  };
134  lensnames.Add(s);
135  };
136  m_lenslist->Append(lensnames);
137  };
138 };
139 
140 void LoadLensDBDialog::SetLensName(std::string lensname)
141 {
142  if (!lensname.empty() && !m_lensNames.empty())
143  {
144  HuginBase::LensDB::LensList::const_iterator it=std::find(m_lensNames.begin(), m_lensNames.end(), lensname);
145  if (it != m_lensNames.end())
146  {
147  m_lenslist->SetSelection(it - m_lensNames.begin());
148  };
149  };
150  wxCommandEvent dummy;
151  OnCheckChanged(dummy);
152 };
153 
154 std::string LoadLensDBDialog::GetLensName() const
155 {
156  return m_lensNames[m_lenslist->GetSelection()];
157 };
158 
160 {
161  m_focal=focal;
162  XRCCTRL(*this,"load_lens_focallength",wxTextCtrl)->SetValue(hugin_utils::doubleTowxString(m_focal,1));
163 };
164 
166 {
167  return m_focal;
168 };
169 
170 void LoadLensDBDialog::SetAperture(double aperture)
171 {
172  m_aperture=aperture;
173  XRCCTRL(*this,"load_lens_aperture",wxTextCtrl)->SetValue(hugin_utils::doubleTowxString(m_aperture,1));
174 };
175 
177 {
178  return m_aperture;
179 };
180 
182 {
183  m_distance=distance;
184  XRCCTRL(*this,"load_lens_distance",wxTextCtrl)->SetValue(hugin_utils::doubleTowxString(m_distance,0));
185 };
186 
188 {
189  return m_distance;
190 };
191 
193 {
194  return m_loadDistortion->GetValue();
195 };
196 
198 {
199  return m_loadVignetting->GetValue();
200 };
201 
202 // utility functions
203 bool str2double(wxWindow* parent, wxString s, double & d)
204 {
205  if (!hugin_utils::stringToDouble(std::string(s.mb_str(wxConvLocal)), d))
206  {
207  wxMessageBox(wxString::Format(_("The input \"%s\" is not a valid number."),s.c_str()),_("Warning"), wxOK | wxICON_ERROR, parent);
208  return false;
209  }
210  return true;
211 }
212 
213 void LoadLensDBDialog::OnOk(wxCommandEvent & e)
214 {
215  if(!m_loadDistortion->GetValue() && !m_loadVignetting->GetValue())
216  {
217  return;
218  };
219  if(m_lenslist->GetSelection()==wxNOT_FOUND)
220  {
221  wxBell();
222  return;
223  };
224  if(!str2double(this,XRCCTRL(*this,"load_lens_focallength",wxTextCtrl)->GetValue(),m_focal))
225  {
226  return;
227  };
228  if(m_loadVignetting->GetValue())
229  {
230  wxString val = XRCCTRL(*this, "load_lens_aperture", wxTextCtrl)->GetValue().Trim();
231  if (val.empty())
232  {
233  m_aperture = 0;
234  }
235  else
236  {
237  if (!str2double(this, val, m_aperture))
238  {
239  return;
240  };
241  };
242  val = XRCCTRL(*this, "load_lens_distance", wxTextCtrl)->GetValue().Trim();
243  if (val.empty())
244  {
245  m_distance = 0;
246  }
247  else
248  {
249  if (!str2double(this, val, m_distance))
250  {
251  return;
252  };
253  };
254  };
255  //store selected options
256  wxConfigBase * config = wxConfigBase::Get();
257  wxSize sz = this->GetClientSize();
258  config->Write(wxT("/LoadLensDialog/width"), sz.GetWidth());
259  config->Write(wxT("/LoadLensDialog/height"), sz.GetHeight());
260  wxPoint ps = this->GetPosition();
261  config->Write(wxT("/LoadLensDialog/positionX"), ps.x);
262  config->Write(wxT("/LoadLensDialog/positionY"), ps.y);
263  config->Write(wxT("/LoadLensDialog/loadDistortion"),m_loadDistortion->GetValue());
264  config->Write(wxT("/LoadLensDialog/loadVignetting"),m_loadVignetting->GetValue());
265  config->Flush();
266  e.Skip();
267 };
268 
269 void LoadLensDBDialog::OnCheckChanged(wxCommandEvent & e)
270 {
271  int sel=m_lenslist->GetSelection();
272  XRCCTRL(*this,"wxID_OK",wxButton)->Enable(sel!=wxNOT_FOUND && (m_loadDistortion->GetValue() || m_loadVignetting->GetValue()));
273 };
274 
276 {
277  LoadLensDBDialog dlg(parent);
278  const HuginBase::SrcPanoImage & img=pano->getImage(*images.begin());
279  dlg.SetLensName(img.getDBLensName());
280  dlg.SetFocalLength(img.getExifFocalLength());
281  dlg.SetAperture(img.getExifAperture());
282  dlg.SetSubjectDistance(img.getExifDistance());
283  if(dlg.ShowModal()==wxID_OK)
284  {
286  const double focal=dlg.GetFocalLength();
287  const std::string lensname = dlg.GetLensName();
288  std::vector<PanoCommand::PanoCommand*> cmds;
290  if(lensDB.GetProjection(lensname, proj))
291  {
292  cmds.push_back(new PanoCommand::ChangeImageProjectionCmd(*pano,images,proj));
293  };
294  vigra::Rect2D cropRect;
295  if(lensDB.GetCrop(lensname, focal, img.getSize(), cropRect))
296  {
297  cmds.push_back(new PanoCommand::ChangeImageCropModeCmd(*pano, images, img.isCircularCrop() ? HuginBase::BaseSrcPanoImage::CROP_CIRCLE : HuginBase::BaseSrcPanoImage::CROP_RECTANGLE));
298  cmds.push_back(new PanoCommand::ChangeImageCropRectCmd(*pano, images, cropRect));
299  };
300  //load lens distortion from database
301  if(dlg.GetLoadDistortion())
302  {
303  double hfov;
304  if (lensDB.GetFov(lensname, focal, hfov))
305  {
306  // calculate FOV for given image, take different aspect ratios into account
307  const double newFocal = HuginBase::SrcPanoImage::calcFocalLength(img.getProjection(), hfov, img.getCropFactor(), vigra::Size2D(3000, 2000));
308  const double newFov = HuginBase::SrcPanoImage::calcHFOV(img.getProjection(), newFocal, img.getCropFactor(), img.getSize());
309  std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
310  linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_HFOV);
311  cmds.push_back(new PanoCommand::ChangePartImagesLinkingCmd(*pano, images, linkedVariables,
313  cmds.push_back(new PanoCommand::ChangeImageHFOVCmd(*pano, images, newFov));
314  };
315  std::vector<double> dist;
316  if(lensDB.GetDistortion(lensname, focal, dist))
317  {
318  if (dist.size() == 3)
319  {
320  dist.push_back(1.0 - dist[0] - dist[1] - dist[2]);
321  std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
322  linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_RadialDistortion);
323  cmds.push_back(new PanoCommand::ChangePartImagesLinkingCmd(*pano, images, linkedVariables,
325  cmds.push_back(new PanoCommand::ChangeImageRadialDistortionCmd(*pano, images, dist));
326  };
327  };
328  };
329  if(dlg.GetLoadVignetting())
330  {
331  std::vector<double> vig;
332  if (lensDB.GetVignetting(lensname, focal, dlg.GetAperture(), dlg.GetSubjectDistance(), vig))
333  {
334  if (vig.size() == 4)
335  {
336  std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
337  linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_RadialVigCorrCoeff);
338  cmds.push_back(new PanoCommand::ChangePartImagesLinkingCmd(*pano, images, linkedVariables,
340  cmds.push_back(new PanoCommand::ChangeImageRadialVigCorrCoeffCmd(*pano, images, vig));
341  };
342  };
343  };
344  cmd=new PanoCommand::CombinedPanoCommand(*pano, cmds);
345  return true;
346  };
347  return false;
348 };
349 
351 class SaveLensDBDialog : public wxDialog
352 {
353 public:
355  explicit SaveLensDBDialog(wxWindow *parent);
356  void SetCameraMaker(std::string maker);
357  std::string GetCameraMaker() const;
358  void SetCameraModel(std::string model);
359  std::string GetCameraModel() const;
360  void SetLensName(std::string lensname);
361  std::string GetLensName() const;
362  std::string GetLensMaker() const;
363  void SetFocalLength(double focal);
364  double GetFocalLength() const;
365  void SetAperture(double aperture);
366  double GetAperture() const;
367  void SetSubjectDistance(double distance);
368  double GetSubjectDistance() const;
369  bool GetSaveDistortion() const;
370  bool GetSaveVignetting() const;
372 
373 protected:
375  void OnOk(wxCommandEvent & e);
376  void OnCheckChanged(wxCommandEvent & e);
377 
378 private:
379  wxCheckBox *m_saveDistortion;
380  wxCheckBox *m_saveVignetting;
381  double m_focal;
382  double m_aperture;
383  double m_distance;
384  DECLARE_EVENT_TABLE()
385 };
386 
387 BEGIN_EVENT_TABLE(SaveLensDBDialog,wxDialog)
388  EVT_BUTTON(wxID_OK, SaveLensDBDialog::OnOk)
389  EVT_CHECKBOX(XRCID("save_lens_distortion"), SaveLensDBDialog::OnCheckChanged)
390  EVT_CHECKBOX(XRCID("save_lens_vignetting"), SaveLensDBDialog::OnCheckChanged)
392 
394 {
395  // load our children. some children might need special
396  // initialization. this will be done later.
397  wxXmlResource::Get()->LoadDialog(this, parent, wxT("save_lens_dlg"));
398 
399  //set parameters
400  wxConfigBase * config = wxConfigBase::Get();
401  // get display size
402  int dx,dy;
403  wxDisplaySize(&dx,&dy);
404  int w = config->Read(wxT("/SaveLensDialog/width"),-1l);
405  int h = config->Read(wxT("/SaveLensDialog/height"),-1l);
406  if (w>0 && w<=dx && h>0 && h<=dy)
407  {
408  SetClientSize(w,h);
409  }
410  else
411  {
412  Fit();
413  }
414  //position
415  int x = config->Read(wxT("/SaveLensDialog/positionX"),-1l);
416  int y = config->Read(wxT("/SaveLensDialog/positionY"),-1l);
417  if ( y >= 0 && x >= 0)
418  {
419  this->Move(x, y);
420  }
421  else
422  {
423  this->Move(0, 44);
424  };
425  bool b;
426  config->Read(wxT("/SaveLensDialog/saveDistortion"),&b,true);
427  m_saveDistortion=XRCCTRL(*this,"save_lens_distortion",wxCheckBox);
428  m_saveDistortion->SetValue(b);
429  config->Read(wxT("/SaveLensDialog/saveVignetting"),&b,true);
430  m_saveVignetting=XRCCTRL(*this,"save_lens_vignetting",wxCheckBox);
431  m_saveVignetting->SetValue(b);
432 };
433 
434 void SaveLensDBDialog::SetCameraMaker(std::string maker)
435 {
436  if(!maker.empty())
437  {
438  XRCCTRL(*this,"save_lens_camera_maker",wxTextCtrl)->SetValue(wxString(maker.c_str(), wxConvLocal));
439  };
440 };
441 
443 {
444  return std::string(XRCCTRL(*this,"save_lens_camera_maker",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
445 };
446 
447 void SaveLensDBDialog::SetCameraModel(std::string model)
448 {
449  if(!model.empty())
450  {
451  XRCCTRL(*this,"save_lens_camera_model",wxTextCtrl)->SetValue(wxString(model.c_str(), wxConvLocal));
452  };
453 };
454 
456 {
457  return std::string(XRCCTRL(*this,"save_lens_camera_model",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
458 };
459 
460 void SaveLensDBDialog::SetLensName(std::string lensname)
461 {
462  if(!lensname.empty())
463  {
464  XRCCTRL(*this,"save_lens_name",wxTextCtrl)->SetValue(wxString(lensname.c_str(), wxConvLocal));
465  };
466 };
467 
468 std::string SaveLensDBDialog::GetLensName() const
469 {
470  return std::string(XRCCTRL(*this,"save_lens_name",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
471 };
472 
474 {
475  return std::string(XRCCTRL(*this,"save_lens_maker",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
476 };
477 
479 {
480  m_focal=focal;
481  XRCCTRL(*this,"save_lens_focallength",wxTextCtrl)->SetValue(hugin_utils::doubleTowxString(m_focal,1));
482 };
483 
485 {
486  return m_focal;
487 };
488 
489 void SaveLensDBDialog::SetAperture(double aperture)
490 {
491  m_aperture=aperture;
492  XRCCTRL(*this,"save_lens_aperture",wxTextCtrl)->SetValue(hugin_utils::doubleTowxString(m_aperture,1));
493 };
494 
496 {
497  return m_aperture;
498 };
499 
501 {
502  m_distance=distance;
503  XRCCTRL(*this,"save_lens_distance",wxTextCtrl)->SetValue(hugin_utils::doubleTowxString(m_distance,0));
504 };
505 
507 {
508  return m_distance;
509 };
510 
512 {
513  return m_saveDistortion->GetValue();
514 };
515 
517 {
518  return m_saveVignetting->GetValue();
519 };
520 
522 {
523  m_saveVignetting->SetValue(false);
524  m_saveVignetting->Disable();
525 };
526 
527 void SaveLensDBDialog::OnOk(wxCommandEvent & e)
528 {
529  if(!m_saveDistortion->GetValue() && !m_saveVignetting->GetValue())
530  {
531  return;
532  };
533  if(GetLensName().empty() && (GetCameraMaker().empty() || GetCameraModel().empty()))
534  {
535  wxMessageBox(_("There is too little information for saving data into database. Please check your input!"),_("Warning"),wxOK|wxICON_ERROR,this);
536  return;
537  };
538  if(!str2double(this,XRCCTRL(*this,"save_lens_focallength",wxTextCtrl)->GetValue(),m_focal))
539  {
540  return;
541  };
542  if(m_saveVignetting->GetValue())
543  {
544  wxString val = XRCCTRL(*this, "save_lens_aperture", wxTextCtrl)->GetValue().Trim();
545  if (val.empty())
546  {
547  m_aperture = 0;
548  }
549  else
550  {
551  if (!str2double(this, val, m_aperture))
552  {
553  return;
554  };
555  };
556  val = XRCCTRL(*this, "save_lens_distance", wxTextCtrl)->GetValue().Trim();
557  if (val.empty())
558  {
559  m_distance = 0;
560  }
561  else
562  {
563  if (!str2double(this, val, m_distance))
564  {
565  return;
566  };
567  };
568  };
569  //store selected options
570  wxConfigBase * config = wxConfigBase::Get();
571  wxSize sz = this->GetClientSize();
572  config->Write(wxT("/SaveLensDialog/width"), sz.GetWidth());
573  config->Write(wxT("/SaveLensDialog/height"), sz.GetHeight());
574  wxPoint ps = this->GetPosition();
575  config->Write(wxT("/SaveLensDialog/positionX"), ps.x);
576  config->Write(wxT("/SaveLensDialog/positionY"), ps.y);
577  config->Write(wxT("/SaveLensDialog/saveDistortion"),m_saveDistortion->GetValue());
578  if(m_saveVignetting->IsEnabled())
579  {
580  config->Write(wxT("/SaveLensDialog/saveVignetting"),m_saveVignetting->GetValue());
581  };
582  config->Flush();
583  e.Skip();
584 };
585 
586 void SaveLensDBDialog::OnCheckChanged(wxCommandEvent & e)
587 {
588  XRCCTRL(*this,"wxID_OK",wxButton)->Enable(m_saveDistortion->GetValue() || m_saveVignetting->GetValue());
589 };
590 
591 bool SaveLensParameters(wxWindow * parent, const HuginBase::SrcPanoImage& img, bool includeVignetting)
592 {
594  // show dialog
595  SaveLensDBDialog lensDlg(parent);
596  lensDlg.SetCameraMaker(img.getExifMake());
597  lensDlg.SetCameraModel(img.getExifModel());
598  lensDlg.SetLensName(img.getDBLensName());
599  lensDlg.SetFocalLength(img.getExifFocalLength());
600  lensDlg.SetAperture(img.getExifAperture());
601  lensDlg.SetSubjectDistance(img.getExifDistance());
602  if (!includeVignetting)
603  {
604  lensDlg.DeactivateSaveVignetting();
605  };
606  if (lensDlg.ShowModal() != wxID_OK)
607  {
608  return false;
609  };
610  const std::string camMaker = lensDlg.GetCameraMaker();
611  const std::string camModel = lensDlg.GetCameraModel();
612  std::string lensname = lensDlg.GetLensName();
613  const double focal = lensDlg.GetFocalLength();
614  if (lensname.empty())
615  {
616  //empty lensname, assuming it is a compact camera
617  lensname = camMaker + "|" + camModel;
618  };
619  // unknown crop factor, remember it
620  if (img.getExifCropFactor() < 0.1 && !camMaker.empty() && !camModel.empty())
621  {
622  lensDB.SaveCameraCrop(camMaker, camModel, img.getCropFactor());
623  };
624  if (lensDlg.GetSaveDistortion())
625  {
626  const double newFocallength = HuginBase::SrcPanoImage::calcFocalLength(img.getProjection(), img.getHFOV(), img.getCropFactor(), img.getSize());
627  const double newHFOV = HuginBase::SrcPanoImage::calcHFOV(img.getProjection(), newFocallength, img.getCropFactor(), vigra::Size2D(3000, 2000));
628  // save information with higher weight
629  if (!lensDB.SaveLensFov(lensname, lensDlg.GetFocalLength(), newHFOV, 75))
630  {
631  wxMessageBox(_("Could not save information into database."), _("Error"), wxOK | wxICON_ERROR, parent);
632  return false;
633  };
634  if (!lensDB.SaveDistortion(lensname, focal, img.getRadialDistortion(), 75))
635  {
636  wxMessageBox(_("Could not save information into database."), _("Error"), wxOK | wxICON_ERROR, parent);
637  return false;
638  };
639  };
640  if(lensDlg.GetSaveVignetting())
641  {
642  if (!lensDB.SaveVignetting(lensname, focal, lensDlg.GetAperture(), lensDlg.GetSubjectDistance(), img.getRadialVigCorrCoeff(), 75))
643  {
644  wxMessageBox(_("Could not save information into database."), _("Error"), wxOK | wxICON_ERROR, parent);
645  return false;
646  };
647  };
648  return true;
649 };
650 
wxCheckBox * m_saveDistortion
Definition: wxLensDB.cpp:379
Base class for all panorama commands.
Definition: Command.h:38
void SetSubjectDistance(double distance)
Definition: wxLensDB.cpp:181
void OnOk(wxCommandEvent &e)
Saves current state of all checkboxes when closing dialog with Ok.
Definition: wxLensDB.cpp:527
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:393
bool GetLoadVignetting() const
Definition: wxLensDB.cpp:197
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:495
Change the linking of some variables across parts of an ImageVariableGroup containing some specified ...
Definition: PanoCommand.h:524
double GetFocalLength() const
Definition: wxLensDB.cpp:165
bool GetSaveVignetting() const
Definition: wxLensDB.cpp:516
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:275
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:159
double GetSubjectDistance() const
Definition: wxLensDB.cpp:506
wxString doubleTowxString(double d, int digits)
Definition: wxPlatform.cpp:31
END_EVENT_TABLE()
include file for the hugin project
HuginBase::LensDB::LensList m_lensNames
Definition: wxLensDB.cpp:67
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:351
PanoCommand to combine other PanoCommands.
Definition: PanoCommand.h:39
std::string GetCameraMaker() const
Definition: wxLensDB.cpp:442
main database class
Definition: LensDB.h:44
dialog for loading lens parameter from lens database
Definition: wxLensDB.cpp:38
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:176
void OnCheckChanged(wxCommandEvent &e)
Definition: wxLensDB.cpp:586
double GetSubjectDistance() const
Definition: wxLensDB.cpp:187
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:143
double m_distance
Definition: wxLensDB.cpp:66
void OnCheckChanged(wxCommandEvent &e)
Definition: wxLensDB.cpp:269
void SetAperture(double aperture)
Definition: wxLensDB.cpp:170
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:468
wxCheckBox * m_saveVignetting
Definition: wxLensDB.cpp:380
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:478
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:213
bool GetSaveDistortion() const
Definition: wxLensDB.cpp:511
include file for the hugin project
Convenience functions for SrcPanoImage to use on the image variables.
void SetLensName(std::string lensname)
Definition: wxLensDB.cpp:140
void SetSubjectDistance(double distance)
Definition: wxLensDB.cpp:500
wxCheckBox * m_loadVignetting
Definition: wxLensDB.cpp:63
void DeactivateSaveVignetting()
Definition: wxLensDB.cpp:521
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:434
std::string GetCameraModel() const
Definition: wxLensDB.cpp:455
LoadLensDBDialog(wxWindow *parent)
Constructor, read from xrc ressource; restore last uses settings, size and position.
Definition: wxLensDB.cpp:78
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:121
std::string GetLensMaker() const
Definition: wxLensDB.cpp:473
void SetCameraModel(std::string model)
Definition: wxLensDB.cpp:447
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:489
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:65
void SetLensName(std::string lensname)
Definition: wxLensDB.cpp:460
wxCheckBox * m_loadDistortion
Definition: wxLensDB.cpp:62
wxChoice * m_lenslist
Definition: wxLensDB.cpp:61
bool str2double(wxWindow *parent, wxString s, double &d)
Definition: wxLensDB.cpp:203
bool GetLoadDistortion() const
Definition: wxLensDB.cpp:192
double GetFocalLength() const
Definition: wxLensDB.cpp:484
std::string GetLensName() const
Definition: wxLensDB.cpp:154