29 #include "wx/clrpicker.h"
41 #include "wx/stdpaths.h"
53 bool OnDropFiles(wxCoord x, wxCoord y,
const wxArrayString& filenames)
56 if (filenames.size() == 1)
58 wxFileName file(filenames[0]);
59 if (file.GetExt().CmpNoCase(
"jpg") == 0 ||
60 file.GetExt().CmpNoCase(
"jpeg") == 0 ||
61 file.GetExt().CmpNoCase(
"tif") == 0 ||
62 file.GetExt().CmpNoCase(
"tiff") == 0 ||
63 file.GetExt().CmpNoCase(
"png") == 0 ||
64 file.GetExt().CmpNoCase(
"bmp") == 0 ||
65 file.GetExt().CmpNoCase(
"gif") == 0 ||
66 file.GetExt().CmpNoCase(
"pnm") == 0)
89 wxConfigBase* config = wxConfigBase::Get();
95 if (!wxPanel::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL,
"panel"))
105 wxXmlResource::Get()->LoadPanel(
this,
"perspective_panel");
107 wxXmlResource::Get()->AttachUnknownControl(
"perspective_preview_window",
m_preview,
this);
109 wxPanel* mainPanel = XRCCTRL(*
this,
"perspective_panel", wxPanel);
110 wxBoxSizer* topsizer =
new wxBoxSizer(wxVERTICAL);
111 topsizer->Add(mainPanel, wxSizerFlags(1).Expand());
115 m_cropTextCtrl = XRCCTRL(*
this,
"perspective_cropfactor", wxTextCtrl);
117 m_zoomChoice = XRCCTRL(*
this,
"perspective_choice_zoom", wxChoice);
119 m_modeChoice = XRCCTRL(*
this,
"perspective_mode", wxChoice);
121 m_helpTextCtrl = XRCCTRL(*
this,
"perspective_help_text", wxStaticText);
125 wxConfigBase* config = wxConfigBase::Get();
127 wxColour colour, defaultColour;
129 colour = config->Read(
"/ToolboxFrame/LineColour", defaultColour.GetAsString(wxC2S_HTML_SYNTAX));
130 XRCCTRL(*
this,
"perspective_color_picker", wxColourPickerCtrl)->SetColour(colour);
132 m_degDigits = config->Read(
"/General/DegreeFractionalDigitsEdit", 3);
147 wxCommandEvent commandEvent;
165 switch (e.GetSelection())
229 XRCCTRL(*
this,
"perspective_filename", wxStaticText)->SetLabel(filename);
250 const double cropFactor =
m_srcImage.getCropFactor();
251 if (focallength > 0 && focallength < 10000)
256 if (cropFactor > 0 && cropFactor < 1000)
260 const double rotation =
m_srcImage.getExifOrientation();
289 wxConfigBase* config = wxConfigBase::Get();
290 wxString path = config->Read(
"/actualPath",
"");
291 wxFileDialog dlg(
this, _(
"Add images"), path, wxEmptyString,
GetFileDialogImageFilters(), wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_PREVIEW, wxDefaultPosition);
292 dlg.SetDirectory(path);
296 if (config->HasEntry(
"lastImageType"))
298 img_ext = config->Read(
"lastImageType").c_str();
300 if (img_ext ==
"all images")
301 dlg.SetFilterIndex(0);
302 else if (img_ext ==
"jpg")
303 dlg.SetFilterIndex(1);
304 else if (img_ext ==
"tiff")
305 dlg.SetFilterIndex(2);
306 else if (img_ext ==
"png")
307 dlg.SetFilterIndex(3);
308 else if (img_ext ==
"hdr")
309 dlg.SetFilterIndex(4);
310 else if (img_ext ==
"exr")
311 dlg.SetFilterIndex(5);
312 else if (img_ext ==
"all files")
313 dlg.SetFilterIndex(6);
316 if (dlg.ShowModal() == wxID_OK)
321 config->Write(
"/actualPath", dlg.GetDirectory());
323 switch (dlg.GetFilterIndex())
325 case 0: config->Write(
"lastImageType",
"all images");
break;
326 case 1: config->Write(
"lastImageType",
"jpg");
break;
327 case 2: config->Write(
"lastImageType",
"tiff");
break;
328 case 3: config->Write(
"lastImageType",
"png");
break;
329 case 4: config->Write(
"lastImageType",
"hdr");
break;
330 case 5: config->Write(
"lastImageType",
"exr");
break;
331 case 6: config->Write(
"lastImageType",
"all files");
break;
339 wxConfigBase::Get()->Write(
"/ToolboxFrame/LineColour", e.GetColour().GetAsString(wxC2S_HTML_SYNTAX));
363 const bool isRectMode =
m_modeChoice->GetSelection() == 0;
376 m_helpTextCtrl->Wrap(XRCCTRL(*
this,
"perspective_color_picker", wxColourPickerCtrl)->GetSize().GetWidth());
402 wxConfigBase* config = wxConfigBase::Get();
403 wxString path = config->Read(
"/actualPath",
"");
407 wxFileDialog dlg(
this, _(
"Save project file"), path, wxEmptyString,
408 _(
"Project files (*.pto)|*.pto|All files (*)|*"),
409 wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
410 if (dlg.ShowModal() == wxID_OK)
412 wxConfig::Get()->Write(
"/actualPath", dlg.GetDirectory());
413 wxString fn = dlg.GetPath();
414 if (fn.Right(4).CmpNoCase(
".pto") != 0)
417 if (wxFile::Exists(fn))
419 int d = wxMessageBox(wxString::Format(_(
"File %s exists. Overwrite?"), fn.c_str()), _(
"Save project"), wxYES_NO | wxICON_QUESTION);
438 wxConfigBase* config = wxConfigBase::Get();
439 wxString path = config->Read(
"/actualPath",
"");
440 wxFileDialog dlg(
this, _(
"Save output"), path, wxEmptyString,
GetMainImageFilters(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
441 dlg.SetDirectory(path);
445 if (config->HasEntry(
"lastImageType"))
447 img_ext = config->Read(
"lastImageType").c_str();
449 if (img_ext ==
"jpg")
451 dlg.SetFilterIndex(0);
455 if (img_ext ==
"tiff")
457 dlg.SetFilterIndex(1);
461 if (img_ext ==
"png")
463 dlg.SetFilterIndex(2);
468 wxString inputFilename = outputfilename.GetFullPath();
469 outputfilename.SetName(outputfilename.GetName() +
"_corrected");
470 dlg.SetFilename(outputfilename.GetFullPath());
472 if (dlg.ShowModal() == wxID_OK)
476 config->Write(
"/actualPath", dlg.GetDirectory());
480 const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
482 switch (dlg.GetFilterIndex())
485 config->Write(
"lastImageType",
"jpg");
486 nonaArgs.Append(
"-m JPEG ");
490 config->Write(
"lastImageType",
"tiff");
491 nonaArgs.Append(
"-m TIFF ");
494 config->Write(
"lastImageType",
"png");
495 nonaArgs.Append(
"-m PNG ");
502 wxString exiftoolArgs(
"-overwrite_original -tagsfromfile ");
505 exiftoolArgs.Append(
" -all:all --thumbnail --xposition --yposition --orientation --imagefullwidth --imagefullheight ");
523 if (wxFileExists(file))
537 return _(
"Adjust the rectangle to an area which should be rectangular in the projected image.");
541 return _(
"Create a new line by dragging with left mouse button on a free space.\nExisting lines or line end points can be moved by dragging with left mouse button.\nA line can be deleted by clicking with the right mouse button.");
549 wxMessageBox(_(
"You need to load an image first."), _(
"Hugin toolbox"), wxICON_ERROR | wxOK);
553 if (focallengthText.IsEmpty())
555 wxMessageBox(_(
"Focal length input box is empty."), _(
"Hugin toolbox"), wxICON_ERROR | wxOK);
558 double focallength, cropfactor;
561 wxMessageBox(_(
"Focal length input box contains no valid number."), _(
"Hugin toolbox"), wxICON_ERROR | wxOK);
565 if (focallength < 0.1)
567 wxMessageBox(_(
"The focal length must be positive."), _(
"Hugin toolbox"), wxICON_ERROR | wxOK);
571 if (cropfactorText.IsEmpty())
573 wxMessageBox(_(
"Crop factor input box is empty."), _(
"Hugin toolbox"), wxICON_ERROR | wxOK);
578 wxMessageBox(_(
"Crop factor input box contains no valid number."), _(
"Hugin toolbox"), wxICON_ERROR | wxOK);
582 if (cropfactor < 0.1)
584 wxMessageBox(_(
"The crop factor must be positive."), _(
"Hugin toolbox"), wxICON_ERROR | wxOK);
590 wxMessageBox(_(
"The focal length and crop factor result in a invalid value of %d for the horizontal field of view.\nPlease input a valid combination of focal length and crop factor."),
591 _(
"Hugin toolbox"), wxICON_QUESTION | wxOK);
608 wxMessageBox(_(
"You need to create at least 2 lines."), _(
"Hugin toolbox"), wxICON_ERROR | wxOK);
613 std::set<std::string> imgopt;
617 optvec.push_back(imgopt);
641 const int cropMode = XRCCTRL(*
this,
"perspective_crop", wxChoice)->GetSelection();
wxArrayString m_tempFiles
temp files, which should be deleted at end
normal command for queue, processing is stopped if an error occurred in program
wxTextCtrl * m_cropTextCtrl
bool Create(wxWindow *parent, MyExecPanel *logWindow)
create the panel and populate all controls
Dummy progress display, without output.
static double calcOptimalPanoScale(const SrcPanoImage &src, const PanoramaOptions &dest)
function to calculate the scaling factor so that the distances in the input image and panorama image ...
wxString GetStatusString()
return help text for current mode
void OnSize(wxSizeEvent &e)
void OnFindLines(wxCommandEvent &e)
bool applyEXIFValues(bool applyEVValue=true)
apply values found in EXIF data to SrcPanoImage class, call readEXIF() before to initialize some valu...
const wxString GetConfigTempDir(const wxConfigBase *config)
return the temp dir from the preferences, ensure that it ends with path separator ...
void setHeight(unsigned int h)
set panorama height
bool str2double(const wxString &s, double &d)
optional command for queue, processing of queue is always continued, also if an error occurred ...
declaration of panel for perspective correction GUI
wxButton * m_outputButton
declaration of functions for finding lines
wxStaticText * m_helpTextCtrl
void registerPTWXDlgFcn()
int ExecQueue(HuginQueue::CommandQueue *queue)
bool checkImageSizeKnown()
check if the image size is known, if try to load the information from the file
void ChangeRotation(ImageRotation newRot)
void OnModeChanged(wxCommandEvent &e)
void ClearOutput()
clear the output
void deregisterPTWXDlgFcn()
wxString doubleTowxString(double d, int digits)
wxString GetInternalProgram(const wxString &bindir, const wxString &name)
return path and name of external program, which comes bundled with Hugin
const double GetRoll() const
return the roll angle in degree
void setScale(double factor)
set the scaling factor for mask editing display.
void SetRectMode(bool newMode)
set line or rect mode
virtual void run()
runs the algorithm.
const CPVector & getCtrlPoints() const
get all control point of this Panorama
void setOptimizeVector(const OptimizeVector &optvec)
set optimize setting
PerspectivePanel * m_perspectivePanel
basic classes and function for queuing commands in wxWidgets
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name="panel")
creates the control
void setImage(const std::string &filename, ImageRotation rot)
set the current image and mask list, this loads also the image from cache
bool ReadInputs()
read the values from the input boxes
void SetRemappedMode(const HuginBase::Panorama &pano)
set the panorama object for remapping
PerspectiveImageCtrl::ImageRotation m_exifRotation
save rotation as written in EXIF
void AddLines(const HuginBase::CPVector &lines)
add the lines to the list
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
void OnProcessFinished(wxCommandEvent &e)
clean up temporary files at end
const PerspectiveImageCtrl::ImageRotation GetRotation() const
return the image rotation
~PerspectivePanel()
destructor, save position and size
void OnSaveOutput(wxCommandEvent &e)
void OnZoom(wxCommandEvent &e)
HuginBase::CPVector GetControlPoints(const unsigned int index)
return list of control points
void setCtrlPoints(const CPVector &points)
set all control points (Ippei: Is this supposed to be 'add' method?)
void OnLoadImage(wxCommandEvent &e)
virtual vigra::Rect2D getResultOptimalROI()
return the ROI structure?, for now area
virtual double getResultHeight()
void SetLineColour(wxColour newColour)
sets the colour for the lines
PerspectiveImageCtrl * m_preview
controls
IMPLEMENT_DYNAMIC_CLASS(wxTreeListHeaderWindow, wxWindow)
bool GetPanorama(HuginBase::Panorama &pano, const bool optimized=true)
return Pano object, it is optimized and the crop set when optimized=true
HuginBase::CPVector GetLines(const HuginBase::Panorama &pano, const unsigned int imgNr, vigra::UInt8RGBImage &image, vigra::BImage &mask)
searches for all lines, the same as GetVerticalLines execpt that no filtering according to roll angle...
image previewer for perspective correction
static double calcFocalLength(SrcPanoImage::Projection proj, double hfov, double crop, vigra::Size2D imageSize)
calcualte focal length, given crop factor and hfov
ImageCache::EntryPtr getCachedImage()
return pointer to ImageCache
MyExecPanel * m_logWindow
void setROI(const vigra::Rect2D &val)
!! from PTOptimise.h 1951
bool IsOriginalShown() const
unsigned int addImage(const SrcPanoImage &img)
the the number for a specific image
bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames)
void setOriginalMode()
if called, the mouse handlers are deactivated
void OnCropChanged(wxCommandEvent &e)
void OnRotationChanged(wxCommandEvent &e)
void setHFOV(double h, bool keepView=true)
set the horizontal field of view.
wxButton * m_findLineButton
unsigned int getWidth() const
ImageRotation
image rotation.
void OnColourChanged(wxColourPickerEvent &e)
virtual double getResultHorizontalFOV()
virtual vigra::Rect2D getResultOptimalROI()
returns the found crop rect
str wxEscapeFilename(const str &arg)
special escaping routine for CommandQueues
#define HUGIN_MASK_COLOUR_POINT_SELECTED
bool readEXIF()
try to fill out information about the image, by examining the exif data
file drag and drop handler method
std::vector< ControlPoint > CPVector
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
bool WritePTOFile(const std::string &filename, const std::string &prefix="")
write data to given pto file
std::vector< std::set< std::string > > OptimizeVector
void OnSavePTO(wxCommandEvent &e)
HuginBase::SrcPanoImage m_srcImage
SrcPanoImage, contains information about the 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 OnPreview(wxCommandEvent &e)
wxTextCtrl * m_focallengthTextCtrl
void SetImage(const wxString &filename)
load the given image
All variables of a source image.
void setProjection(ProjectionFormat f)
set the Projection format and adjust the hfov/vfov if nessecary
bool readCropfactorFromDB()
tries to read cropfactor from lens database you need to call SrcPanoImage::readEXIF before to fill so...
virtual bool hasRunSuccessfully()
wxString GetExternalProgram(wxConfigBase *config, const wxString &bindir, const wxString &name)
return path and name of external program, which can be overwritten by the user
std::vector< NormalCommand * > CommandQueue
void setWidth(unsigned int w, bool keepView=true)
set panorama width keep the HFOV, if keepView=true
wxChoice * m_previewChoice
PerspectiveDropTarget(PerspectivePanel *parent)
double outputExposureValue
wxChoice * m_rotationChoice