34 #include "wx/mstream.h"
39 #include <exiv2/exiv2.hpp>
65 wxXmlResource::Get()->LoadDialog(
this,batchframe,wxT(
"find_pano_dialog"));
81 m_cb_subdir=XRCCTRL(*
this,
"find_pano_subdir",wxCheckBox);
82 m_statustext=XRCCTRL(*
this,
"find_pano_label",wxStaticText);
83 m_list_pano=XRCCTRL(*
this,
"find_pano_list",wxCheckListBox);
85 m_ch_naming=XRCCTRL(*
this,
"find_pano_naming",wxChoice);
91 m_ch_blender = XRCCTRL(*
this,
"find_pano_default_blender", wxChoice);
95 wxConfigBase* config = wxConfigBase::Get();
98 wxDisplaySize(&dx,&dy);
99 bool maximized = config->Read(wxT(
"/FindPanoDialog/maximized"), 0l) != 0;
107 int w = config->Read(wxT(
"/FindPanoDialog/width"),-1l);
108 int h = config->Read(wxT(
"/FindPanoDialog/height"),-1l);
109 if (w > 0 && w <= dx)
111 this->SetClientSize(w,h);
118 int x = config->Read(wxT(
"/FindPanoDialog/positionX"),-1l);
119 int y = config->Read(wxT(
"/FindPanoDialog/positionY"),-1l);
120 if ( y >= 0 && x >= 0 && x < dx && y < dy)
129 long splitterPos = config->Read(wxT(
"/FindPanoDialog/splitterPos"), -1l);
130 if (splitterPos != -1)
132 XRCCTRL(*
this,
"find_pano_splitter", wxSplitterWindow)->SetSashPosition(splitterPos);
134 wxString path=config->Read(wxT(
"/FindPanoDialog/actualPath"),wxEmptyString);
140 config->Read(wxT(
"/FindPanoDialog/includeSubDirs"),&val,
false);
142 long i=config->Read(wxT(
"/FindPanoDialog/Naming"),0l);
144 config->Read(wxT(
"/FindPanoDialog/linkStacks"),&val,
true);
146 config->Read(wxT(
"/FindPanoDialog/loadDistortion"),&val,
false);
148 config->Read(wxT(
"/FindPanoDialog/loadVignetting"),&val,
false);
150 i=config->Read(wxT(
"/FindPanoDialog/MinNumberImages"), 2l);
152 i=config->Read(wxT(
"/FindPanoDialog/MaxTimeDiff"), 30l);
158 m_thumbsList = XRCCTRL(*
this,
"find_pano_selected_thumbslist", wxListCtrl);
174 wxConfigBase* config=wxConfigBase::Get();
175 if(!this->IsMaximized())
177 wxSize sz = this->GetClientSize();
178 config->Write(wxT(
"/FindPanoDialog/width"), sz.GetWidth());
179 config->Write(wxT(
"/FindPanoDialog/height"), sz.GetHeight());
180 wxPoint ps = this->GetPosition();
181 config->Write(wxT(
"/FindPanoDialog/positionX"), ps.x);
182 config->Write(wxT(
"/FindPanoDialog/positionY"), ps.y);
183 config->Write(wxT(
"/FindPanoDialog/maximized"), 0);
187 config->Write(wxT(
"/FindPanoDialog/maximized"), 1l);
189 config->Write(wxT(
"/FindPanoDialog/splitterPos"), XRCCTRL(*
this,
"find_pano_splitter", wxSplitterWindow)->GetSashPosition());
190 config->Write(wxT(
"/FindPanoDialog/actualPath"),
m_textctrl_dir->GetValue());
191 config->Write(wxT(
"/FindPanoDialog/includeSubDirs"),
m_cb_subdir->GetValue());
192 config->Write(wxT(
"/FindPanoDialog/Naming"),
m_ch_naming->GetSelection());
193 config->Write(wxT(
"/FindPanoDialog/linkStacks"),
m_cb_createLinks->GetValue());
197 config->Write(wxT(
"/FindPanoDialog/MaxTimeDiff"),
m_sc_maxTimeDiff->GetValue());
230 if(wxMessageBox(_(
"The list contains possibly unprocessed panoramas.\nIf you close the dialog, you will lose them.\nContinue anyway?"),
231 _(
"Question"),wxYES_NO|wxICON_WARNING,
this)==wxNO)
241 wxDirDialog dlg(
this, _(
"Specify a directory to search for projects in"),
242 m_textctrl_dir->GetValue(), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
243 if (dlg.ShowModal()==wxID_OK)
265 if (wxMessageBox(_(
"The list contains still not yet processed panoramas.\nIf you continue, they will be disregarded.\nDo you still want to continue?"),
266 _(
"Question"),wxYES_NO|wxICON_WARNING,
this)==wxNO)
278 wxCommandEvent dummy;
286 wxMessageBox(wxString::Format(_(
"Directory %s does not exist.\nPlease give an existing directory."),
m_start_dir.c_str()),
287 _(
"Warning"),wxOK | wxICON_EXCLAMATION,
this);
299 for(
unsigned int i=0; i<
m_list_pano->GetCount(); i++)
308 wxMessageBox(_(
"You have not selected a panorama.\nPlease select at least one panorama and try again."),_(
"Warning"),wxOK|wxICON_EXCLAMATION,
this);
313 for(
unsigned int i=0; i<
m_list_pano->GetCount(); i++)
319 if(!filename.IsEmpty())
331 wxMessageBox(_(
"Not all project files could be written successfully.\nMaybe you have no write permission for these directories or your disc is full."),_(
"Error"),wxOK,
this);
350 if (selected != wxNOT_FOUND)
352 XRCCTRL(*
this,
"find_pano_selected_cam", wxStaticText)->SetLabel(
m_panos[selected]->GetCameraName());
353 XRCCTRL(*
this,
"find_pano_selected_lens", wxStaticText)->SetLabel(
m_panos[selected]->GetLensName());
354 XRCCTRL(*
this,
"find_pano_selected_focallength", wxStaticText)->SetLabel(
m_panos[selected]->
GetFocalLength());
355 XRCCTRL(*
this,
"find_pano_selected_date_time", wxStaticText)->SetLabel(
m_panos[selected]->GetStartString() + wxT(
" (")+
m_panos[selected]->GetDuration() + wxT(
")"));
360 XRCCTRL(*
this,
"find_pano_selected_cam", wxStaticText)->SetLabel(wxEmptyString);
361 XRCCTRL(*
this,
"find_pano_selected_lens", wxStaticText)->SetLabel(wxEmptyString);
362 XRCCTRL(*
this,
"find_pano_selected_focallength", wxStaticText)->SetLabel(wxEmptyString);
363 XRCCTRL(*
this,
"find_pano_selected_date_time", wxStaticText)->SetLabel(wxEmptyString);
374 const int selectedPano =
m_list_pano->GetSelection();
375 if (
m_panos[selectedPano]->GetImageCount() > 2)
379 long imageIndex = -1;
380 imageIndex =
m_thumbsList->GetNextItem(imageIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
381 if(imageIndex > 1 && imageIndex <= static_cast<long>(
m_panos[selectedPano]->GetImageCount()) - 2)
383 contextMenu.Append(
ID_SPLIT_PANOS, _(
"Split here into two panoramas"));
386 if (contextMenu.GetMenuItemCount() > 0)
388 PopupMenu(&contextMenu);
394 const int selectedPano =
m_list_pano->GetSelection();
395 if (selectedPano != wxNOT_FOUND)
397 if (
m_panos[selectedPano]->GetImageCount() > 2)
399 long imageIndex = -1;
400 imageIndex =
m_thumbsList->GetNextItem(imageIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
401 if (imageIndex != wxNOT_FOUND)
404 m_panos[selectedPano]->RemoveImage(imageIndex);
410 wxCommandEvent dummy;
419 const int selectedPano =
m_list_pano->GetSelection();
420 if (selectedPano != wxNOT_FOUND)
422 long imageIndex = -1;
423 imageIndex =
m_thumbsList->GetNextItem(imageIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
424 if (imageIndex != wxNOT_FOUND)
426 if (imageIndex > 1 && imageIndex <= static_cast<long>(
m_panos[selectedPano]->GetImageCount()) - 2)
439 wxCommandEvent dummy;
460 if (item != wxNOT_FOUND && (flags&wxLIST_HITTEST_ONITEM) && item <
m_tooltips.GetCount())
472 return doj::alphanum_comp(std::string(s1.mb_str(wxConvLocal)),std::string(s2.mb_str(wxConvLocal)));
475 void FindPanoDialog::SearchInDir(wxString dirstring,
const bool includeSubdir,
const bool loadDistortion,
const bool loadVignetting,
const size_t minNumberImages,
const size_t maxTimeDiff)
477 std::vector<PossiblePano*> newPanos;
478 wxTimeSpan max_diff(0, 0, maxTimeDiff, 0);
480 wxArrayString fileList;
481 wxDir::GetAllFiles(dirstring,&fileList,wxEmptyString,wxDIR_FILES|wxDIR_HIDDEN);
484 for(
size_t j=0; j<fileList.size() && !
m_stopped; j++)
486 m_statustext->SetLabel(wxString::Format(_(
"Reading file %s"),fileList[j].c_str()));
487 wxFileName file(fileList[j]);
489 wxString ext=file.GetExt();
490 if(ext.CmpNoCase(wxT(
"jpg"))==0 || ext.CmpNoCase(wxT(
"jpeg"))==0 ||
491 ext.CmpNoCase(wxT(
"tif"))==0 || ext.CmpNoCase(wxT(
"tiff"))==0)
495 img->setFilename(filenamestr);
499 HuginBase::FileMetaData::const_iterator it = metadata.find(
"pixeltype");
500 if (it != metadata.end())
502 if (it->second ==
"BILEVEL")
504 wxGetApp().Yield(
true);
508 img->applyEXIFValues();
509 if(!img->getExifMake().empty() && !img->getExifModel().empty() &&
510 img->getExifFocalLength()!=0 && img->getCropFactor()!=0)
512 img->readProjectionFromDB(
false);
515 img->readDistortionFromDB();
519 img->readVignettingFromDB();
522 for(
unsigned int i=0; i<newPanos.size() && !
m_stopped && !found; i++)
525 if(newPanos[i]->BelongsTo(img,max_diff))
527 newPanos[i]->AddSrcPanoImage(img);
532 wxGetApp().Yield(
true);
539 newPanos.push_back(newPano);
549 wxGetApp().Yield(
true);
553 for(
size_t i=0; i<newPanos.size(); i++)
555 if(newPanos[i]->GetImageCount()>=minNumberImages)
557 m_panos.push_back(newPanos[i]);
571 wxDir dir(dirstring);
572 bool cont=dir.GetFirst(&filename,wxEmptyString,wxDIR_DIRS);
575 SearchInDir(dir.GetName()+wxFileName::GetPathSeparator()+filename,includeSubdir, loadDistortion, loadVignetting, minNumberImages, maxTimeDiff);
576 cont=dir.GetNext(&filename);
589 m_statustext->SetLabel(wxString::Format(_(
"Found %d possible panoramas"), static_cast<int>(
m_panos.size())));
593 m_statustext->SetLabel(_(
"No possible panoramas found"));
603 for(ImageSet::reverse_iterator it=
m_images.rbegin(); it!=
m_images.rend(); ++it)
612 if(
m_make.compare(img->getExifMake())!=0)
616 if(
m_camera.compare(img->getExifModel())!=0)
620 if(
m_lens.compare(img->getExifLens())!=0)
632 if(
m_size!=img->getSize())
645 struct tm exifdatetime;
648 return wxDateTime(exifdatetime);
653 return file.GetModificationTime();
662 m_make=img->getExifMake();
664 m_lens=img->getExifLens();
688 ImageSet::const_iterator it=
m_images.begin();
690 f1.MakeRelativeTo(BasePath);
691 ImageSet::const_reverse_iterator rit=
m_images.rbegin();
695 return f1.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR)+f1.GetName()+wxT(
"-")+f2.GetName();
699 return f1.GetFullPath()+wxT(
" - ")+f2.GetFullName();
705 return wxString::Format(_(
"%d images: %s"), static_cast<int>(
m_images.size()),
GetFilestring(BasePath).c_str());
712 projectFile.SetPath(basePath);
713 projectFile.SetName(wxT(
"pano"));
714 projectFile.SetExt(wxT(
"pto"));
715 if(!projectFile.IsDirWritable())
722 mask=wxT(
"panorama%d");
726 projectFile.SetName(mask);
727 if(!projectFile.FileExists())
731 mask=mask+wxT(
"_%d");
735 wxArrayString folders=projectFile.GetDirs();
736 if(folders.GetCount()==0)
741 projectFile.SetName(mask);
742 if(!projectFile.FileExists())
746 mask=mask+wxT(
"_%d");
755 mask=newProject.GetName();
756 projectFile.SetName(mask);
757 if(!projectFile.FileExists())
761 mask=mask+wxT(
"_%d");
765 mask=wxT(
"panorama%d");
768 projectFile.SetName(wxString::Format(mask,i));
769 while(projectFile.FileExists())
772 projectFile.SetName(wxString::Format(mask,i));
786 return wxEmptyString;
788 ImageSet::const_iterator it=
m_images.begin();
790 firstFile.MakeAbsolute();
791 wxFileName projectFile;
794 return wxEmptyString;
797 double redBalanceAnchor = (*
m_images.begin())->getExifRedBalance();
798 double blueBalanceAnchor = (*
m_images.begin())->getExifBlueBalance();
799 if (fabs(redBalanceAnchor)<1e-2)
801 redBalanceAnchor = 1;
803 if (fabs(blueBalanceAnchor)<1e-2)
805 blueBalanceAnchor = 1;
810 (*it)->setWhiteBalanceRed((*it)->getExifRedBalance() / redBalanceAnchor);
811 (*it)->setWhiteBalanceBlue((*it)->getExifBlueBalance() / blueBalanceAnchor);
832 wxConfigBase* config = wxConfigBase::Get();
878 opts.
verdandiOptions = config->Read(wxT(
"/VerdandiDefaultArgs"), wxEmptyString).mb_str(wxConvLocal);
885 std::string(projectFile.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR).mb_str(
HUGIN_CONV_FILENAME))))
887 return projectFile.GetFullPath();
891 return wxEmptyString;
897 return wxString(
m_camera.c_str(), wxConvLocal);
902 return wxString(
m_lens.c_str(), wxConvLocal);
926 list->DeleteAllItems();
932 #if defined EXIV2_VERSION && EXIV2_TEST_VERSION(0,27,99)
933 Exiv2::Image::UniquePtr image;
935 Exiv2::Image::AutoPtr image;
940 image = Exiv2::ImageFactory::open((*it)->getFilename().c_str());
945 std::cerr << __FILE__ <<
" " << __LINE__ <<
" Error opening file" << std::endl;
953 image->readMetadata();
955 catch (
const Exiv2::Error& e)
957 std::cerr << __FILE__ <<
" " << __LINE__ <<
" Exiv2: Error reading metadata (" << e.what() <<
")" << std::endl;
961 Exiv2::PreviewManager previews(*image);
962 Exiv2::PreviewPropertiesList lists = previews.getPreviewProperties();
966 int previewIndex = 0;
967 while (previewIndex < lists.size() - 1 && lists[previewIndex].width_ <
THUMBSIZE && lists[previewIndex].height_ <
THUMBSIZE)
973 Exiv2::PreviewImage previewImage = previews.getPreviewImage(lists[previewIndex]);
974 wxMemoryInputStream stream(previewImage.pData(), previewImage.size());
975 rawImage.LoadFile(stream, wxString(previewImage.mimeType().c_str(), wxConvLocal), -1);
978 if (previewImage.width() > previewImage.height())
981 int newHeight =
THUMBSIZE*previewImage.height() / previewImage.width();
989 int newWidth =
THUMBSIZE*previewImage.width() / previewImage.height();
995 if ((*it)->getRoll() == 90)
997 rawImage = rawImage.Rotate90();
1002 if ((*it)->getRoll() == 270)
1004 rawImage = rawImage.Rotate90(
false);
1009 if ((*it)->getRoll() == 180)
1011 rawImage = rawImage.Rotate180();
1017 wxMemoryDC dc(bitmap);
1018 dc.SetBackground(list->GetBackgroundColour());
1020 dc.DrawBitmap(rawImage, x, y);
1021 dc.SelectObject(wxNullBitmap);
1027 index = thumbs->Add(bitmap, wxBitmap(mask, 1));
1032 list->InsertItem(list->GetItemCount(), fn.GetFullName(), index);
1045 ImageSet::iterator item =
m_images.begin();
1046 std::advance(item, index);
1062 ImageSet::iterator img = allImages.begin();
1063 while (
m_images.size() < index && img != allImages.end())
1068 while (img != allImages.end())
1090 if (dt.IsLaterThan(m_dt_end))
wxString GetFocalLength()
returns the focal length as string
WXIMPEX wxString GetFormattedTimeSpan(const wxTimeSpan &timeSpan)
int alphanum_comp(const std::string &l, const std::string &r)
Compare l and r with the same semantics as strcmp(), but with the "Alphanum Algorithm" which produces...
static void swap(T &x, T &y)
#define HUGIN_NONA_CROPPEDIMAGES
unsigned int getPartNumber(unsigned int imageNr) const
Get a part number from an image number.
BlendingMechanism
blenders
bool operator()(const HuginBase::SrcPanoImage *img1, const HuginBase::SrcPanoImage *img2) const
wxSpinCtrl * m_sc_maxTimeDiff
void AddSrcPanoImage(HuginBase::SrcPanoImage *img)
adds the given SrcPanoImage to this pano-group
#define HUGIN_JPEG_QUALITY
~PossiblePano()
destructor, cleans up used variables
void setPhotometricOptimizerSwitch(const int newSwitch)
sets the photometric optimizer master switch
Somewhere to specify what variables belong to what.
void AddToList(wxString aFile, Project::Target target=Project::STITCHING, wxString userDefined=wxEmptyString)
void RemoveImage(const unsigned int index)
removes the image at given index
void EnableButtons(const bool state)
std::string enfuseOptions
wxButton * m_button_start
include file for the hugin project
wxCheckBox * m_cb_loadDistortion
std::string outputImageTypeCompression
wxString GetCameraName()
returns the camera name
void setOptimizerSwitch(const int newSwitch)
set optimizer master switch
wxCheckBox * m_cb_createLinks
Batch processor for Hugin with GUI.
int SortWxFilenames(const wxString &s1, const wxString &s2)
void OnButtonClose(wxCommandEvent &e)
closes window
wxCheckBox * m_cb_loadVignetting
void UpdateDateTimes()
updates the internal date/time representations
void linkPossibleStacks(bool linkPosition)
create automatically stacks as indicated by metadata
PossiblePano * SplitPano(const unsigned int index)
split pano into 2 subpanos, index is used as first image of second pano
BatchFrame * m_batchframe
some definitions to work with optimizer master switches
const wxString GetFilestring(const wxString BasePath, const bool stripExtension=false) const
returns a string with the filename of the first and last file
wxString GetDuration()
returns the duration as string
void PopulateListCtrl(wxListCtrl *list, wxImageList *thumbs, wxArrayString &tooltips)
add all images to wxListCtrl
std::size_t getNrOfImages() const
number of images.
void SearchInDir(wxString dirstring, const bool includeSubdir, const bool loadDistortion, const bool loadVignetting, const size_t minNumberImages, const size_t maxTimeDiff)
const int getExifDateTime(struct tm *datetime) const
try to convert Exif date time string to struct tm
void OnSplitPanos(wxCommandEvent &e)
event handler to split into 2 panos
vigra_ext::Interpolator interpolator
const unsigned int GetImageCount() const
returns number of images in this group
Definition of dialog to change user defined sequence.
wxString GetStartString()
return the start date/time as string
ImageVariableGroup & getLenses()
Get the ImageVariableGroup representing the group of lens variables.
#define HUGIN_NONA_INTERPOLATOR
#define HUGIN_TIFF_COMPRESSION
void OnListMouseMove(wxMouseEvent &e)
mouse move handler for tooltips
std::map< std::string, std::string > FileMetaData
typedef for general map for storing metadata in files
wxString GetLensName()
returns the lens name
std::set< HuginBase::SrcPanoImage *, SortFilename > ImageSet
std::string stripExtension(const std::string &basename2)
remove extension of a filename
TIFFErrorHandler m_oldtiffwarning
void OnSelectPossiblePano(wxCommandEvent &e)
event to populate information on the right
wxStaticText * m_statustext
void OnListItemRightClick(wxListEvent &e)
event handler for context menu
#define HUGIN_HDRMERGE_ARGS
#define HUGIN_LDR_OUTPUT_FORMAT
bool BelongsTo(HuginBase::SrcPanoImage *img, const wxTimeSpan max_time_diff)
return true, if the image could belong to the given PossiblePano, it checks camera maker and model...
unsigned int addImage(const SrcPanoImage &img)
the the number for a specific image
wxTextCtrl * m_textctrl_dir
std::string tiffCompression
std::string verdandiOptions
Same as above, but use a non const panorama.
wxButton * m_button_close
NamingConvention
enumeration for different naming conventions, must be match combobox in ressource ...
std::string enblendOptions
const PanoramaOptions & getOptions() const
returns the options for this panorama
wxString GeneratePanorama(NamingConvention nc, bool createLinks, HuginBase::PanoramaOptions::BlendingMechanism defaultBlender)
generates the panorama file from this set of images
HDRMergeType hdrMergeMode
wxListCtrl * m_thumbsList
bool GetNewProjectFilename(NamingConvention nc, const wxString basePath, wxFileName &projectFile)
returns a given filename, which does not already exists
#define HUGIN_ENFUSE_ARGS
bool readEXIF()
try to fill out information about the image, by examining the exif data
const wxDateTime GetDateTime(const HuginBase::SrcPanoImage *img)
does some reformating date/time format
PossiblePano()
constructor, init values
std::string outputImageType
void OnClose(wxCloseEvent &e)
prevents closing window when running detection
bool WritePTOFile(const std::string &filename, const std::string &prefix="")
write data to given pto file
wxSpinCtrl * m_sc_minNumberImages
~FindPanoDialog()
destructor, saves size and position
std::string hdrmergeOptions
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
FindPanoDialog(BatchFrame *batchframe, wxString xrcPrefix)
Constructor, read from xrc ressource; restore last uses settings, size and position.
const wxString GetItemString(const wxString BasePath) const
returns a string which contains description of this pano
void OnRemoveImage(wxCommandEvent &e)
event handler to remove selected image from list
void setOptions(const PanoramaOptions &opt)
set new output settings This is not used directly for optimizing/stiching, but it can be feed into ru...
Interpolator
enum with all interpolation methods
All variables of a source image.
void switchParts(unsigned int ImageNr, unsigned int partNr)
switch a given image to a different part number.
const bool hasPossibleStacks() const
return true, if the metadata indicates that the projects is a bracketet project
wxButton * m_button_choose
#define HUGIN_ENBLEND_ARGS
void OnButtonSend(wxCommandEvent &e)
add selected projects to queue
wxString getDefaultProjectName(const HuginBase::Panorama &pano, const wxString filenameTemplate)
gets the default project name, as defined in the preferences
void OnButtonChoose(wxCommandEvent &e)
select directory with dialog
BlendingMechanism blendMode
wxCheckListBox * m_list_pano
void OnButtonStart(wxCommandEvent &e)
start/stops detections
std::vector< PossiblePano * > m_panos
double outputExposureValue