57 void OnOk(wxCommandEvent & e);
75 wxXmlResource::Get()->LoadDialog(
this, parent,
"load_lens_dlg");
78 wxConfigBase * config = wxConfigBase::Get();
82 config->Read(
"/LoadLensDialog/loadDistortion", &b,
true);
86 config->Read(
"/LoadLensDialog/loadVignetting", &b,
true);
90 m_lenslist=XRCCTRL(*
this,
"load_lens_lenschoice", wxChoice);
100 wxArrayString lensnames;
103 wxString s((*it).c_str(), wxConvLocal);
104 wxString cam = s.AfterFirst(
'|');
107 s = wxString::Format(_(
"Camera %s (%s)"), cam.c_str(), s.BeforeFirst(
'|').c_str());
119 HuginBase::LensDB::LensList::const_iterator it=std::find(
m_lensNames.begin(),
m_lensNames.end(), lensname);
125 wxCommandEvent dummy;
182 hugin_utils::HuginMessageBox(wxString::Format(_(
"The input \"%s\" is not a valid number."), s), _(
"Hugin"), wxOK | wxICON_ERROR, parent);
199 if(!
str2double(
this,XRCCTRL(*
this,
"load_lens_focallength",wxTextCtrl)->GetValue(),
m_focal))
205 wxString val = XRCCTRL(*
this,
"load_lens_aperture", wxTextCtrl)->GetValue().Trim();
217 val = XRCCTRL(*
this,
"load_lens_distance", wxTextCtrl)->GetValue().Trim();
232 wxConfigBase * config = wxConfigBase::Get();
233 config->Write(
"/LoadLensDialog/loadDistortion",
m_loadDistortion->GetValue());
234 config->Write(
"/LoadLensDialog/loadVignetting",
m_loadVignetting->GetValue());
253 if(dlg.ShowModal()==wxID_OK)
258 std::vector<PanoCommand::PanoCommand*> cmds;
262 cmds.push_back(
new PanoCommand::ChangeImageProjectionCmd(*pano,images,proj));
264 vigra::Rect2D cropRect;
265 if(lensDB.
GetCrop(lensname, focal, img.getSize(), cropRect))
268 cmds.push_back(
new PanoCommand::ChangeImageCropRectCmd(*pano, images, cropRect));
274 if (lensDB.
GetFov(lensname, focal, hfov))
279 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
280 linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_HFOV);
283 cmds.push_back(
new PanoCommand::ChangeImageHFOVCmd(*pano, images, newFov));
285 std::vector<double> dist;
288 if (dist.size() == 3)
290 dist.push_back(1.0 - dist[0] - dist[1] - dist[2]);
291 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
292 linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_RadialDistortion);
295 cmds.push_back(
new PanoCommand::ChangeImageRadialDistortionCmd(*pano, images, dist));
301 std::vector<double> vig;
306 std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> linkedVariables;
307 linkedVariables.insert(HuginBase::ImageVariableGroup::IVE_RadialVigCorrCoeff);
310 cmds.push_back(
new PanoCommand::ChangeImageRadialVigCorrCoeffCmd(*pano, images, vig));
345 void OnOk(wxCommandEvent & e);
360 wxXmlResource::Get()->LoadDialog(
this, parent,
"save_lens_dlg");
363 wxConfigBase * config = wxConfigBase::Get();
366 config->Read(
"/SaveLensDialog/saveDistortion",&b,
true);
370 config->Read(
"/SaveLensDialog/saveVignetting",&b,
true);
381 XRCCTRL(*
this,
"save_lens_camera_maker",wxTextCtrl)->SetValue(wxString(maker.c_str(), wxConvLocal));
387 return std::string(XRCCTRL(*
this,
"save_lens_camera_maker",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
394 XRCCTRL(*
this,
"save_lens_camera_model",wxTextCtrl)->SetValue(wxString(model.c_str(), wxConvLocal));
400 return std::string(XRCCTRL(*
this,
"save_lens_camera_model",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
405 if(!lensname.empty())
407 XRCCTRL(*
this,
"save_lens_name",wxTextCtrl)->SetValue(wxString(lensname.c_str(), wxConvLocal));
413 return std::string(XRCCTRL(*
this,
"save_lens_name",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
418 return std::string(XRCCTRL(*
this,
"save_lens_maker",wxTextCtrl)->GetValue().Trim().mb_str(wxConvLocal));
478 hugin_utils::HuginMessageBox(_(
"There is too little information for saving data into database. Please check your input!"), _(
"Hugin"), wxOK | wxICON_ERROR,
this);
481 if(!
str2double(
this,XRCCTRL(*
this,
"save_lens_focallength",wxTextCtrl)->GetValue(),
m_focal))
487 wxString val = XRCCTRL(*
this,
"save_lens_aperture", wxTextCtrl)->GetValue().Trim();
499 val = XRCCTRL(*
this,
"save_lens_distance", wxTextCtrl)->GetValue().Trim();
514 wxConfigBase * config = wxConfigBase::Get();
515 config->Write(
"/SaveLensDialog/saveDistortion",
m_saveDistortion->GetValue());
518 config->Write(
"/SaveLensDialog/saveVignetting",
m_saveVignetting->GetValue());
540 if (!includeVignetting)
544 if (lensDlg.ShowModal() != wxID_OK)
552 if (lensname.empty())
555 lensname = camMaker +
"|" + camModel;
558 if (img.getExifCropFactor() < 0.1 && !camMaker.empty() && !camModel.empty())
572 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
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
Change the linking of some variables across parts of an ImageVariableGroup containing some specified ...
double GetFocalLength() const
bool GetSaveVignetting() const
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
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