56 void OnOk(wxCommandEvent & e);
74 EVT_CHECKBOX(XRCID("load_lens_distortion"),
LoadLensDBDialog::OnCheckChanged)
75 EVT_CHECKBOX(XRCID("load_lens_vignetting"),
LoadLensDBDialog::OnCheckChanged)
82 wxXmlResource::Get()->LoadDialog(
this, parent, wxT(
"load_lens_dlg"));
85 wxConfigBase * config = wxConfigBase::Get();
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)
100 int x = config->Read(wxT(
"/LoadLensDialog/positionX"),-1l);
101 int y = config->Read(wxT(
"/LoadLensDialog/positionY"),-1l);
102 if ( y >= 0 && x >= 0)
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);
125 wxArrayString lensnames;
128 wxString s((*it).c_str(), wxConvLocal);
129 wxString cam = s.AfterFirst(wxT(
'|'));
132 s = wxString::Format(_(
"Camera %s (%s)"), cam.c_str(), s.BeforeFirst(wxT(
'|')).c_str());
144 HuginBase::LensDB::LensList::const_iterator it=std::find(
m_lensNames.begin(),
m_lensNames.end(), lensname);
150 wxCommandEvent dummy;
207 wxMessageBox(wxString::Format(_(
"The input \"%s\" is not a valid number."),s.c_str()),_(
"Warning"), wxOK | wxICON_ERROR, parent);
224 if(!
str2double(
this,XRCCTRL(*
this,
"load_lens_focallength",wxTextCtrl)->GetValue(),
m_focal))
230 wxString val = XRCCTRL(*
this,
"load_lens_aperture", wxTextCtrl)->GetValue().Trim();
242 val = XRCCTRL(*
this,
"load_lens_distance", wxTextCtrl)->GetValue().Trim();
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());
283 if(dlg.ShowModal()==wxID_OK)
288 std::vector<PanoCommand::PanoCommand*> cmds;
292 cmds.push_back(
new PanoCommand::ChangeImageProjectionCmd(*pano,images,proj));
294 vigra::Rect2D cropRect;
295 if(lensDB.
GetCrop(lensname, focal, img.getSize(), cropRect))
298 cmds.push_back(
new PanoCommand::ChangeImageCropRectCmd(*pano, images, cropRect));
304 if (lensDB.
GetFov(lensname, focal, hfov))
309 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
310 linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_HFOV);
313 cmds.push_back(
new PanoCommand::ChangeImageHFOVCmd(*pano, images, newFov));
315 std::vector<double> dist;
318 if (dist.size() == 3)
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);
325 cmds.push_back(
new PanoCommand::ChangeImageRadialDistortionCmd(*pano, images, dist));
331 std::vector<double> vig;
336 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
337 linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_RadialVigCorrCoeff);
340 cmds.push_back(
new PanoCommand::ChangeImageRadialVigCorrCoeffCmd(*pano, images, vig));
375 void OnOk(wxCommandEvent & e);
384 DECLARE_EVENT_TABLE()
389 EVT_CHECKBOX(XRCID("save_lens_distortion"),
SaveLensDBDialog::OnCheckChanged)
390 EVT_CHECKBOX(XRCID("save_lens_vignetting"),
SaveLensDBDialog::OnCheckChanged)
397 wxXmlResource::Get()->LoadDialog(
this, parent, wxT(
"save_lens_dlg"));
400 wxConfigBase * config = wxConfigBase::Get();
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)
415 int x = config->Read(wxT(
"/SaveLensDialog/positionX"),-1l);
416 int y = config->Read(wxT(
"/SaveLensDialog/positionY"),-1l);
417 if ( y >= 0 && x >= 0)
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);
438 XRCCTRL(*
this,
"save_lens_camera_maker",wxTextCtrl)->SetValue(wxString(maker.c_str(), wxConvLocal));
444 return std::string(XRCCTRL(*
this,
"save_lens_camera_maker",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
451 XRCCTRL(*
this,
"save_lens_camera_model",wxTextCtrl)->SetValue(wxString(model.c_str(), wxConvLocal));
457 return std::string(XRCCTRL(*
this,
"save_lens_camera_model",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
462 if(!lensname.empty())
464 XRCCTRL(*
this,
"save_lens_name",wxTextCtrl)->SetValue(wxString(lensname.c_str(), wxConvLocal));
470 return std::string(XRCCTRL(*
this,
"save_lens_name",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
475 return std::string(XRCCTRL(*
this,
"save_lens_maker",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
535 wxMessageBox(_(
"There is too little information for saving data into database. Please check your input!"),_(
"Warning"),wxOK|wxICON_ERROR,
this);
538 if(!
str2double(
this,XRCCTRL(*
this,
"save_lens_focallength",wxTextCtrl)->GetValue(),
m_focal))
544 wxString val = XRCCTRL(*
this,
"save_lens_aperture", wxTextCtrl)->GetValue().Trim();
556 val = XRCCTRL(*
this,
"save_lens_distance", wxTextCtrl)->GetValue().Trim();
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());
580 config->Write(wxT(
"/SaveLensDialog/saveVignetting"),
m_saveVignetting->GetValue());
602 if (!includeVignetting)
606 if (lensDlg.ShowModal() != wxID_OK)
614 if (lensname.empty())
617 lensname = camMaker +
"|" + camModel;
620 if (img.getExifCropFactor() < 0.1 && !camMaker.empty() && !camModel.empty())
631 wxMessageBox(_(
"Could not save information into database."), _(
"Error"), wxOK | wxICON_ERROR, parent);
634 if (!lensDB.
SaveDistortion(lensname, focal, img.getRadialDistortion(), 75))
636 wxMessageBox(_(
"Could not save information into database."), _(
"Error"), wxOK | wxICON_ERROR, parent);
644 wxMessageBox(_(
"Could not save information into database."), _(
"Error"), wxOK | wxICON_ERROR, parent);
wxCheckBox * m_saveDistortion
Base class for all panorama commands.
void SetSubjectDistance(double distance)
void OnOk(wxCommandEvent &e)
Saves current state of all checkboxes when closing dialog with Ok.
static const std::set< ConstImageVariableGroup::ImageVariableEnum > & getLensVariables()
Get the set of lens image variables.
SaveLensDBDialog(wxWindow *parent)
Constructor, read from xrc ressource; restore last uses settings, size and position.
bool GetLoadVignetting() const
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
double GetAperture() const
Change the linking of some variables across parts of an ImageVariableGroup containing some specified ...
double GetFocalLength() const
bool GetSaveVignetting() const
static LensDB & GetSingleton()
returns the static LensDB instance
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 ...
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
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
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 ...
void SetFocalLength(double focal)
double GetSubjectDistance() const
wxString doubleTowxString(double d, int digits)
include file for the hugin project
HuginBase::LensDB::LensList m_lensNames
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
dialog for saving lens parameter into lens database
PanoCommand to combine other PanoCommands.
std::string GetCameraMaker() const
dialog for loading lens parameter from lens database
std::set< unsigned int > UIntSet
bool SaveCameraCrop(const std::string &maker, const std::string &model, const double cropfactor)
save the camera with the given cropfactor into the database
class to access Hugins camera and lens database
double GetAperture() const
void OnCheckChanged(wxCommandEvent &e)
double GetSubjectDistance() const
void OnCheckChanged(wxCommandEvent &e)
void SetAperture(double aperture)
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...
std::string GetLensName() const
wxCheckBox * m_saveVignetting
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)
bool stringToDouble(const STR &str_, double &dest)
convert a string to a double, ignore localisation.
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.
bool GetSaveDistortion() const
include file for the hugin project
Convenience functions for SrcPanoImage to use on the image variables.
void SetLensName(std::string lensname)
void SetSubjectDistance(double distance)
wxCheckBox * m_loadVignetting
void DeactivateSaveVignetting()
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
std::vector< std::string > LensList
vector storing a list of lens names
void SetCameraMaker(std::string maker)
std::string GetCameraModel() const
LoadLensDBDialog(wxWindow *parent)
Constructor, read from xrc ressource; restore last uses settings, size and position.
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
std::string GetLensMaker() const
void SetCameraModel(std::string model)
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
void SetAperture(double aperture)
All variables of a source image.
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...
void SetLensName(std::string lensname)
wxCheckBox * m_loadDistortion
bool str2double(wxWindow *parent, wxString s, double &d)
bool GetLoadDistortion() const
double GetFocalLength() const
std::string GetLensName() const