48#define DEFAULT_LENSCAL_SCALE 2.0
49#define DEFAULT_LENSCAL_THRESHOLD 4.0
50#define DEFAULT_RESIZE_DIMENSION 1600
51#define DEFAULT_MINLINELENGTH 0.3
67 if (file.GetExt().CmpNoCase(
"jpg") == 0 ||
68 file.GetExt().CmpNoCase(
"jpeg") == 0 ||
69 file.GetExt().CmpNoCase(
"tif") == 0 ||
70 file.GetExt().CmpNoCase(
"tiff") == 0 ||
71 file.GetExt().CmpNoCase(
"png") == 0 ||
72 file.GetExt().CmpNoCase(
"bmp") == 0 ||
73 file.GetExt().CmpNoCase(
"gif") == 0 ||
74 file.GetExt().CmpNoCase(
"pnm") == 0 ||
75 file.GetExt().CmpNoCase(
"sun") == 0 ||
76 file.GetExt().CmpNoCase(
"hdr") == 0 ||
77 file.GetExt().CmpNoCase(
"viff") == 0 )
85 files.push_back(file.GetFullPath());
107 wxXmlResource::Get()->LoadFrame(
this,
parent,
"lenscal_frame");
112 wxApp::s_macExitMenuItemId =
XRCID(
"menu_quit");
147 SetTitle(
_(
"Hugin Lens calibration GUI"));
160#if defined __WXMAC__ || defined __WXMSW__
169 ImageCache::getInstance().setProgressDisplay(
this);
173 unsigned long mem_high =
config->Read(
"/ImageCache/UpperBoundHigh", (
long) 0);
180 ImageCache::getInstance().SetUpperLimit(
mem);
206 ImageCache::getInstance().setProgressDisplay(0);
207 delete & ImageCache::getInstance();
275 for (
unsigned int i=0;
i<files.GetCount();
i++)
282 HuginBase::FileMetaData::const_iterator
it =
metadata.find(
"pixeltype");
285 if (
it->second ==
"BILEVEL")
287 hugin_utils::HuginMessageBox(wxString::Format(
_(
"File \"%s\" is a black/white image.\nHugin does not support this image type. Skipping this image.\nConvert image to grayscale image and try loading again."), files[
i].
c_str()),
298 if(
image0->getSize()!=image1->getSize())
304 if(!
image0->getExifMake().empty() && !image1->getExifMake().empty() &&
305 !
image0->getExifModel().empty() && !image1->getExifModel().empty() &&
306 image0->getExifFocalLength()>0 && image1->getExifFocalLength()>0 &&
307 image0->getCropFactor()>0 && image1->getCropFactor()>0
310 if(
image0->getExifMake()!=image1->getExifMake() ||
311 image0->getExifModel()!=image1->getExifModel() ||
312 image0->getExifFocalLength()!=image1->getExifFocalLength() ||
313 image0->getCropFactor()!=image1->getCropFactor())
324 XRCCTRL(*
this,
"lenscal_focallength", wxTextCtrl)->SetValue(
330 XRCCTRL(*
this,
"lenscal_cropfactor", wxTextCtrl)->SetValue(
347 fileText.Append(filename.GetFullName());
360 fileText.Append(filename.GetFullName());
364 hugin_utils::HuginMessageBox(wxString::Format(
_(
"The EXIF information of the added images (%s) is not consistent with the already added image(s).\nPlease check the image again, if you selected the correct images."),
fileText.c_str()),
377 dlg.SetDirectory(path);
381 if (
config->HasEntry(
"lastImageType")){
385 dlg.SetFilterIndex(0);
387 dlg.SetFilterIndex(1);
389 dlg.SetFilterIndex(2);
391 dlg.SetFilterIndex(3);
393 dlg.SetFilterIndex(4);
395 dlg.SetFilterIndex(5);
396 else if (
img_ext ==
"all files")
397 dlg.SetFilterIndex(6);
412 config->Write(
"/actualPath",
dlg.GetDirectory());
433 switch (
dlg.GetFilterIndex() )
435 case 0:
config->Write(
"lastImageType",
"all images");
break;
436 case 1:
config->Write(
"lastImageType",
"jpg");
break;
437 case 2:
config->Write(
"lastImageType",
"tiff");
break;
438 case 3:
config->Write(
"lastImageType",
"png");
break;
439 case 4:
config->Write(
"lastImageType",
"hdr");
break;
440 case 5:
config->Write(
"lastImageType",
"exr");
break;
441 case 6:
config->Write(
"lastImageType",
"all files");
break;
455 m_images_list->SetString(index,wxString::Format(
_(
"%s (%d lines)"),file.GetFullName().c_str(),
m_images[index]->GetNrOfValidLines()));
465 wxString text=wxString::Format(
_(
"%s (%d lines)"),file.GetFullName().c_str(),
m_images[
i]->GetNrOfValidLines());
483 ImageCache::getInstance().removeImage(filename);
563 ImageCache::EntryPtr img=ImageCache::getInstance().getImage(filename);
582 unsigned int count=0;
617 wxWindow *
button = (wxWindow*)e.GetEventObject();
642 std::set<std::string>
imgopt;
660 for(
unsigned j=0;
j<
lines.size();
j++)
665 for(
unsigned int k=0;
k<
cpv.size();
k++)
680 img.setExposureValue(0);
681 img.setWhiteBalanceRed(1);
682 img.setWhiteBalanceBlue(1);
720 _(
"Save lens parameters file"),
722 _(
"Lens Project Files (*.ini)|*.ini|All files (*)|*"),
728 if(!filename.HasExt())
729 filename.SetExt(
"ini");
730 wxConfig::Get()->Write(
"/lensPath",
dlg.GetDirectory());
731 if (filename.FileExists())
750 unsigned int count=0;
760 choices.push_back(
_(
"Save lens parameters to ini file"));
761 choices.push_back(
_(
"Save lens parameters to lens database"));
790 wxConfig::Get()->Write(
"/actualPath",
dlg.GetDirectory());
792 if(!filename.HasExt())
793 filename.SetExt(
"pto");
794 if (filename.FileExists())
declaration of application class for lens calibrate application
#define DEFAULT_LENSCAL_SCALE
const unsigned int cps_per_line
#define DEFAULT_LENSCAL_THRESHOLD
#define DEFAULT_RESIZE_DIMENSION
#define DEFAULT_MINLINELENGTH
declaration of LensCal main frame class
class to access Hugins camera and lens database
!! from PTOptimise.h 1951
Somewhere to specify what variables belong to what.
simple class that forward the drop to the mainframe
bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames)
file drag and drop handler method
Same as above, but use a non const panorama.
static void Clean()
cleanup the static LensDB instance, must be called at the end of the program
void setProjection(ProjectionFormat f)
set the Projection format and adjust the hfov/vfov if nessecary
double outputExposureValue
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
const PanoramaOptions & getOptions() const
returns the options for this panorama
void setOptimizeVector(const OptimizeVector &optvec)
set optimize setting
SrcPanoImage getSrcImage(unsigned imgNr) const
get a description of a source image
unsigned int addCtrlPoint(const ControlPoint &point)
add a new control point.
unsigned int addImage(const SrcPanoImage &img)
the the number for a specific image
void setOptions(const PanoramaOptions &opt)
set new output settings This is not used directly for optimizing/stiching, but it can be feed into ru...
void setSrcImage(unsigned int nr, const SrcPanoImage &img)
set input image parameters
bool WritePTOFile(const std::string &filename, const std::string &prefix="")
write data to given pto file
std::size_t getNrOfImages() const
number of images.
All variables of a source image.
double getVar(const std::string &name) const
void setVar(const std::string &name, double val)
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
HuginBase::SrcPanoImage * GetPanoImage()
return the SrcPanoImage from the given filename
const wxString GetFilename()
returns the filename
bool ReadInputs(bool readFocalLength, bool readOptions, bool readLensParameter)
reads all input values into internal values
HuginBase::SrcPanoImage::Projection m_projection
void UpdateList(bool restoreSelection)
updates the list box with current values
void ParametersToDisplay()
set all parameter input wxTextField to internal values
void AddImages(wxArrayString files)
const wxString & GetXRCPath()
get the path to the xrc directory
void OnReset(wxCommandEvent &e)
void OnExit(wxCommandEvent &e)
void OnFindLines(wxCommandEvent &e)
std::vector< ImageLineList * > m_images
list of all detected lines
void OnSaveProject(wxCommandEvent &e)
LensCalFrame(wxWindow *parent)
constructor
void OnShowDistortionGraph(wxCommandEvent &e)
show distortion graph
void Optimize()
do the optimization
virtual ~LensCalFrame()
destructor
wxGraphTools::GraphPopupWindow * m_popup
wxChoice * m_choice_projection
void OnImageSelected(wxCommandEvent &e)
void updateProgressDisplay()
called when a progress message should be displayed
void OnSelectPreviewContent(wxCommandEvent &e)
unsigned int m_resize_dimension
void OnShowLines(wxCommandEvent &e)
void OnAddImage(wxCommandEvent &e)
wxListBox * m_images_list
void OnRefresh(wxCommandEvent &e)
void OnOptimize(wxCommandEvent &e)
void OnRemoveImage(wxCommandEvent &e)
void OnSaveLens(wxCommandEvent &e)
LensCalImageCtrl * m_preview
void UpdateListString(unsigned int index)
HuginBase::Panorama GetPanorama()
return panorama object with all images
void EnableButtons()
enable all buttons and menu items depending on number of active images
image previewer for lens calibration GUI
void SetShowLines(bool showLines)
void SetMode(const LensCalPreviewMode newMode)
set which image (original, edge, remapped/corrected) should be drawn
void SetLensDistortions(const double newA, const double newB, const double newC, const double newD, const double newE)
updates the internal values of the lens distortions parameters (needed only for remapped image)
void SetLens(const HuginBase::SrcPanoImage::Projection newProjection, const double newFocallength, const double newCropfactor)
updates the internal values of the lens (needed only for remapped image)
const LensCalPreviewMode GetMode()
return actual preview mode
void SetImage(ImageLineList *newList, unsigned int newIndex)
set preview setting to given ImageLineList
void SetEmptyImage()
set preview to empty image
#define HUGIN_IMGCACHE_UPPERBOUND
std::vector< ControlPoint > CPVector
std::vector< std::set< std::string > > OptimizeVector
std::map< std::string, std::string > FileMetaData
typedef for general map for storing metadata in files
Lines findLines(vigra::BImage &edge, double length_threshold, double focal_length, double crop_factor)
find straightish non-crossing lines find straightish non-crossing lines in an edge map using 8-neighb...
vigra::BImage * detectEdges(const vigra::UInt8RGBImage &input, const double scale, const double threshold, const unsigned int resize_dimension, double &size_factor)
detect and mark edges in an edge image using Canny's algorithm
std::vector< SingleLine > Lines
vector of extracted lines from image
bool str2double(const wxString &s, double &d)
wxString doubleTowxString(double d, int digits)
bool AskUserOverwrite(const wxString &filename, const wxString &caption, wxWindow *parent)
ask user if the given file should be overwritten, return true if the user confirmed the overwritting
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
include file for the hugin project
include file for the hugin project
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
dialogs for loading and saving information from/to lens database