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