56 void OnOk(wxCommandEvent & e);
74 wxXmlResource::Get()->LoadDialog(
this, parent, wxT(
"load_lens_dlg"));
77 wxConfigBase * config = wxConfigBase::Get();
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)
92 int x = config->Read(wxT(
"/LoadLensDialog/positionX"),-1l);
93 int y = config->Read(wxT(
"/LoadLensDialog/positionY"),-1l);
94 if ( y >= 0 && x >= 0)
103 config->Read(wxT(
"/LoadLensDialog/loadDistortion"), &b,
true);
107 config->Read(wxT(
"/LoadLensDialog/loadVignetting"), &b,
true);
111 m_lenslist=XRCCTRL(*
this,
"load_lens_lenschoice", wxChoice);
121 wxArrayString lensnames;
124 wxString s((*it).c_str(), wxConvLocal);
125 wxString cam = s.AfterFirst(wxT(
'|'));
128 s = wxString::Format(_(
"Camera %s (%s)"), cam.c_str(), s.BeforeFirst(wxT(
'|')).c_str());
140 HuginBase::LensDB::LensList::const_iterator it=std::find(
m_lensNames.begin(),
m_lensNames.end(), lensname);
146 wxCommandEvent dummy;
203 wxMessageBox(wxString::Format(_(
"The input \"%s\" is not a valid number."),s.c_str()),_(
"Warning"), wxOK | wxICON_ERROR, parent);
220 if(!
str2double(
this,XRCCTRL(*
this,
"load_lens_focallength",wxTextCtrl)->GetValue(),
m_focal))
226 wxString val = XRCCTRL(*
this,
"load_lens_aperture", wxTextCtrl)->GetValue().Trim();
238 val = XRCCTRL(*
this,
"load_lens_distance", wxTextCtrl)->GetValue().Trim();
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());
279 if(dlg.ShowModal()==wxID_OK)
284 std::vector<PanoCommand::PanoCommand*> cmds;
288 cmds.push_back(
new PanoCommand::ChangeImageProjectionCmd(*pano,images,proj));
290 vigra::Rect2D cropRect;
291 if(lensDB.
GetCrop(lensname, focal, img.getSize(), cropRect))
294 cmds.push_back(
new PanoCommand::ChangeImageCropRectCmd(*pano, images, cropRect));
300 if (lensDB.
GetFov(lensname, focal, hfov))
305 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
306 linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_HFOV);
309 cmds.push_back(
new PanoCommand::ChangeImageHFOVCmd(*pano, images, newFov));
311 std::vector<double> dist;
314 if (dist.size() == 3)
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);
321 cmds.push_back(
new PanoCommand::ChangeImageRadialDistortionCmd(*pano, images, dist));
327 std::vector<double> vig;
332 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
333 linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_RadialVigCorrCoeff);
336 cmds.push_back(
new PanoCommand::ChangeImageRadialVigCorrCoeffCmd(*pano, images, vig));
371 void OnOk(wxCommandEvent & e);
386 wxXmlResource::Get()->LoadDialog(
this, parent, wxT(
"save_lens_dlg"));
389 wxConfigBase * config = wxConfigBase::Get();
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)
404 int x = config->Read(wxT(
"/SaveLensDialog/positionX"),-1l);
405 int y = config->Read(wxT(
"/SaveLensDialog/positionY"),-1l);
406 if ( y >= 0 && x >= 0)
415 config->Read(wxT(
"/SaveLensDialog/saveDistortion"),&b,
true);
419 config->Read(wxT(
"/SaveLensDialog/saveVignetting"),&b,
true);
430 XRCCTRL(*
this,
"save_lens_camera_maker",wxTextCtrl)->SetValue(wxString(maker.c_str(), wxConvLocal));
436 return std::string(XRCCTRL(*
this,
"save_lens_camera_maker",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
443 XRCCTRL(*
this,
"save_lens_camera_model",wxTextCtrl)->SetValue(wxString(model.c_str(), wxConvLocal));
449 return std::string(XRCCTRL(*
this,
"save_lens_camera_model",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
454 if(!lensname.empty())
456 XRCCTRL(*
this,
"save_lens_name",wxTextCtrl)->SetValue(wxString(lensname.c_str(), wxConvLocal));
462 return std::string(XRCCTRL(*
this,
"save_lens_name",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
467 return std::string(XRCCTRL(*
this,
"save_lens_maker",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
527 wxMessageBox(_(
"There is too little information for saving data into database. Please check your input!"),_(
"Warning"),wxOK|wxICON_ERROR,
this);
530 if(!
str2double(
this,XRCCTRL(*
this,
"save_lens_focallength",wxTextCtrl)->GetValue(),
m_focal))
536 wxString val = XRCCTRL(*
this,
"save_lens_aperture", wxTextCtrl)->GetValue().Trim();
548 val = XRCCTRL(*
this,
"save_lens_distance", wxTextCtrl)->GetValue().Trim();
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());
572 config->Write(wxT(
"/SaveLensDialog/saveVignetting"),
m_saveVignetting->GetValue());
594 if (!includeVignetting)
598 if (lensDlg.ShowModal() != wxID_OK)
606 if (lensname.empty())
609 lensname = camMaker +
"|" + camModel;
612 if (img.getExifCropFactor() < 0.1 && !camMaker.empty() && !camModel.empty())
623 wxMessageBox(_(
"Could not save information into database."), _(
"Error"), wxOK | wxICON_ERROR, parent);
626 if (!lensDB.
SaveDistortion(lensname, focal, img.getRadialDistortion(), 75))
628 wxMessageBox(_(
"Could not save information into database."), _(
"Error"), wxOK | wxICON_ERROR, parent);
636 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