57 void OnOk(wxCommandEvent & e);
75 wxXmlResource::Get()->LoadDialog(
this, parent,
"load_lens_dlg");
78 wxConfigBase * config = wxConfigBase::Get();
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)
93 int x = config->Read(
"/LoadLensDialog/positionX",-1l);
94 int y = config->Read(
"/LoadLensDialog/positionY",-1l);
95 if ( y >= 0 && x >= 0)
104 config->Read(
"/LoadLensDialog/loadDistortion", &b,
true);
108 config->Read(
"/LoadLensDialog/loadVignetting", &b,
true);
112 m_lenslist=XRCCTRL(*
this,
"load_lens_lenschoice", wxChoice);
122 wxArrayString lensnames;
125 wxString s((*it).c_str(), wxConvLocal);
126 wxString cam = s.AfterFirst(
'|');
129 s = wxString::Format(_(
"Camera %s (%s)"), cam.c_str(), s.BeforeFirst(
'|').c_str());
141 HuginBase::LensDB::LensList::const_iterator it=std::find(
m_lensNames.begin(),
m_lensNames.end(), lensname);
147 wxCommandEvent dummy;
204 hugin_utils::HuginMessageBox(wxString::Format(_(
"The input \"%s\" is not a valid number."), s), _(
"Hugin"), wxOK | wxICON_ERROR, parent);
221 if(!
str2double(
this,XRCCTRL(*
this,
"load_lens_focallength",wxTextCtrl)->GetValue(),
m_focal))
227 wxString val = XRCCTRL(*
this,
"load_lens_aperture", wxTextCtrl)->GetValue().Trim();
239 val = XRCCTRL(*
this,
"load_lens_distance", wxTextCtrl)->GetValue().Trim();
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());
280 if(dlg.ShowModal()==wxID_OK)
285 std::vector<PanoCommand::PanoCommand*> cmds;
289 cmds.push_back(
new PanoCommand::ChangeImageProjectionCmd(*pano,images,proj));
291 vigra::Rect2D cropRect;
292 if(lensDB.
GetCrop(lensname, focal, img.getSize(), cropRect))
295 cmds.push_back(
new PanoCommand::ChangeImageCropRectCmd(*pano, images, cropRect));
301 if (lensDB.
GetFov(lensname, focal, hfov))
306 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
307 linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_HFOV);
310 cmds.push_back(
new PanoCommand::ChangeImageHFOVCmd(*pano, images, newFov));
312 std::vector<double> dist;
315 if (dist.size() == 3)
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);
322 cmds.push_back(
new PanoCommand::ChangeImageRadialDistortionCmd(*pano, images, dist));
328 std::vector<double> vig;
333 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
334 linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_RadialVigCorrCoeff);
337 cmds.push_back(
new PanoCommand::ChangeImageRadialVigCorrCoeffCmd(*pano, images, vig));
372 void OnOk(wxCommandEvent & e);
387 wxXmlResource::Get()->LoadDialog(
this, parent,
"save_lens_dlg");
390 wxConfigBase * config = wxConfigBase::Get();
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)
405 int x = config->Read(
"/SaveLensDialog/positionX",-1l);
406 int y = config->Read(
"/SaveLensDialog/positionY",-1l);
407 if ( y >= 0 && x >= 0)
416 config->Read(
"/SaveLensDialog/saveDistortion",&b,
true);
420 config->Read(
"/SaveLensDialog/saveVignetting",&b,
true);
431 XRCCTRL(*
this,
"save_lens_camera_maker",wxTextCtrl)->SetValue(wxString(maker.c_str(), wxConvLocal));
437 return std::string(XRCCTRL(*
this,
"save_lens_camera_maker",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
444 XRCCTRL(*
this,
"save_lens_camera_model",wxTextCtrl)->SetValue(wxString(model.c_str(), wxConvLocal));
450 return std::string(XRCCTRL(*
this,
"save_lens_camera_model",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
455 if(!lensname.empty())
457 XRCCTRL(*
this,
"save_lens_name",wxTextCtrl)->SetValue(wxString(lensname.c_str(), wxConvLocal));
463 return std::string(XRCCTRL(*
this,
"save_lens_name",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
468 return std::string(XRCCTRL(*
this,
"save_lens_maker",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
528 hugin_utils::HuginMessageBox(_(
"There is too little information for saving data into database. Please check your input!"), _(
"Hugin"), wxOK | wxICON_ERROR,
this);
531 if(!
str2double(
this,XRCCTRL(*
this,
"save_lens_focallength",wxTextCtrl)->GetValue(),
m_focal))
537 wxString val = XRCCTRL(*
this,
"save_lens_aperture", wxTextCtrl)->GetValue().Trim();
549 val = XRCCTRL(*
this,
"save_lens_distance", wxTextCtrl)->GetValue().Trim();
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());
573 config->Write(
"/SaveLensDialog/saveVignetting",
m_saveVignetting->GetValue());
595 if (!includeVignetting)
599 if (lensDlg.ShowModal() != wxID_OK)
607 if (lensname.empty())
610 lensname = camMaker +
"|" + camModel;
613 if (img.getExifCropFactor() < 0.1 && !camMaker.empty() && !camModel.empty())
627 if (!lensDB.
SaveDistortion(lensname, focal, img.getRadialDistortion(), 75))
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)
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
wxCheckBox * m_loadDistortion
bool str2double(wxWindow *parent, wxString s, double &d)
bool GetLoadDistortion() const
double GetFocalLength() const
std::string GetLensName() const