34 #include "wx/mstream.h"
39 #include <exiv2/exiv2.hpp>
70 wxXmlResource::Get()->LoadDialog(
this,batchframe,
"find_pano_dialog");
82 m_dirPicker=XRCCTRL(*
this,
"find_pano_dir",wxDirPickerCtrl);
83 m_cb_subdir=XRCCTRL(*
this,
"find_pano_subdir",wxCheckBox);
84 m_statustext=XRCCTRL(*
this,
"find_pano_label",wxStaticText);
85 m_list_pano=XRCCTRL(*
this,
"find_pano_list",wxCheckListBox);
87 m_ch_naming=XRCCTRL(*
this,
"find_pano_naming",wxChoice);
93 m_ch_blender = XRCCTRL(*
this,
"find_pano_default_blender", wxChoice);
97 wxConfigBase* config = wxConfigBase::Get();
100 long splitterPos = config->Read(
"/FindPanoDialog/splitterPos", -1l);
101 if (splitterPos != -1)
103 XRCCTRL(*
this,
"find_pano_splitter", wxSplitterWindow)->SetSashPosition(splitterPos);
105 wxString path=config->Read(
"/FindPanoDialog/actualPath",wxEmptyString);
111 config->Read(
"/FindPanoDialog/includeSubDirs",&val,
false);
113 long i=config->Read(
"/FindPanoDialog/Naming",0l);
115 config->Read(
"/FindPanoDialog/linkStacks",&val,
true);
117 config->Read(
"/FindPanoDialog/loadDistortion",&val,
false);
119 config->Read(
"/FindPanoDialog/loadVignetting",&val,
false);
121 i=config->Read(
"/FindPanoDialog/MinNumberImages", 2l);
123 i=config->Read(
"/FindPanoDialog/MaxTimeDiff", 30l);
129 m_thumbsList = XRCCTRL(*
this,
"find_pano_selected_thumbslist", wxListCtrl);
145 wxConfigBase* config=wxConfigBase::Get();
147 config->Write(
"/FindPanoDialog/splitterPos", XRCCTRL(*
this,
"find_pano_splitter", wxSplitterWindow)->GetSashPosition());
148 config->Write(
"/FindPanoDialog/actualPath",
m_dirPicker->GetPath());
149 config->Write(
"/FindPanoDialog/includeSubDirs",
m_cb_subdir->GetValue());
150 config->Write(
"/FindPanoDialog/Naming",
m_ch_naming->GetSelection());
188 if (
hugin_utils::HuginMessageBox(_(
"The list contains possibly unprocessed panoramas.\nIf you close the dialog, you will lose them.\nContinue anyway?"),
189 _(
"PTBatcherGUI"), wxYES_NO | wxICON_WARNING,
this) == wxNO)
213 if (
hugin_utils::HuginMessageBox(_(
"The list contains still not yet processed panoramas.\nIf you continue, they will be disregarded.\nDo you still want to continue?"),
214 _(
"PTBatcherGUI"), wxYES_NO | wxICON_WARNING,
this) == wxNO)
226 wxCommandEvent dummy;
235 _(
"PTBatcherGUI"), wxOK | wxICON_EXCLAMATION,
this);
247 for(
unsigned int i=0; i<
m_list_pano->GetCount(); i++)
256 hugin_utils::HuginMessageBox(_(
"You have not selected a panorama.\nPlease select at least one panorama and try again."), _(
"PTBatcherGUI"), wxOK | wxICON_EXCLAMATION,
this);
261 for(
unsigned int i=0; i<
m_list_pano->GetCount(); i++)
267 if(!filename.IsEmpty())
279 hugin_utils::HuginMessageBox(_(
"Not all project files could be written successfully.\nMaybe you have no write permission for these directories or your disc is full."), _(
"PTBatcherGUI"), wxOK,
this);
297 if (selected != wxNOT_FOUND)
299 XRCCTRL(*
this,
"find_pano_selected_cam", wxStaticText)->SetLabel(
m_panos[selected]->GetCameraName());
300 XRCCTRL(*
this,
"find_pano_selected_lens", wxStaticText)->SetLabel(
m_panos[selected]->GetLensName());
301 XRCCTRL(*
this,
"find_pano_selected_focallength", wxStaticText)->SetLabel(
m_panos[selected]->
GetFocalLength());
302 XRCCTRL(*
this,
"find_pano_selected_date_time", wxStaticText)->SetLabel(
m_panos[selected]->GetStartString() +
" ("+
m_panos[selected]->GetDuration() +
")");
307 XRCCTRL(*
this,
"find_pano_selected_cam", wxStaticText)->SetLabel(wxEmptyString);
308 XRCCTRL(*
this,
"find_pano_selected_lens", wxStaticText)->SetLabel(wxEmptyString);
309 XRCCTRL(*
this,
"find_pano_selected_focallength", wxStaticText)->SetLabel(wxEmptyString);
310 XRCCTRL(*
this,
"find_pano_selected_date_time", wxStaticText)->SetLabel(wxEmptyString);
321 const int selectedPano =
m_list_pano->GetSelection();
322 if (
m_panos[selectedPano]->GetImageCount() > 2)
326 long imageIndex = -1;
327 imageIndex =
m_thumbsList->GetNextItem(imageIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
328 if(imageIndex > 1 && imageIndex <= static_cast<long>(
m_panos[selectedPano]->GetImageCount()) - 2)
330 contextMenu.Append(
ID_SPLIT_PANOS, _(
"Split here into two panoramas"));
333 if (contextMenu.GetMenuItemCount() > 0)
335 PopupMenu(&contextMenu);
341 const int selectedPano =
m_list_pano->GetSelection();
342 if (selectedPano != wxNOT_FOUND)
344 if (
m_panos[selectedPano]->GetImageCount() > 2)
346 long imageIndex = -1;
347 imageIndex =
m_thumbsList->GetNextItem(imageIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
348 if (imageIndex != wxNOT_FOUND)
351 m_panos[selectedPano]->RemoveImage(imageIndex);
357 wxCommandEvent dummy;
366 const int selectedPano =
m_list_pano->GetSelection();
367 if (selectedPano != wxNOT_FOUND)
369 long imageIndex = -1;
370 imageIndex =
m_thumbsList->GetNextItem(imageIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
371 if (imageIndex != wxNOT_FOUND)
373 if (imageIndex > 1 && imageIndex <= static_cast<long>(
m_panos[selectedPano]->GetImageCount()) - 2)
386 wxCommandEvent dummy;
407 if (item != wxNOT_FOUND && (flags&wxLIST_HITTEST_ONITEM) && item <
m_tooltips.GetCount())
419 return doj::alphanum_comp(std::string(s1.mb_str(wxConvLocal)),std::string(s2.mb_str(wxConvLocal)));
422 void FindPanoDialog::SearchInDir(wxString dirstring,
const bool includeSubdir,
const bool loadDistortion,
const bool loadVignetting,
const size_t minNumberImages,
const size_t maxTimeDiff)
424 std::vector<PossiblePano*> newPanos;
425 wxTimeSpan max_diff(0, 0, maxTimeDiff, 0);
427 wxArrayString fileList;
428 wxDir::GetAllFiles(dirstring,&fileList,wxEmptyString,wxDIR_FILES|wxDIR_HIDDEN);
431 for(
size_t j=0; j<fileList.size() && !
m_stopped; j++)
433 m_statustext->SetLabel(wxString::Format(_(
"Reading file %s"),fileList[j].c_str()));
434 wxFileName file(fileList[j]);
436 wxString ext=file.GetExt();
437 if(ext.CmpNoCase(
"jpg")==0 || ext.CmpNoCase(
"jpeg")==0 ||
438 ext.CmpNoCase(
"tif")==0 || ext.CmpNoCase(
"tiff")==0)
442 img->setFilename(filenamestr);
446 HuginBase::FileMetaData::const_iterator it = metadata.find(
"pixeltype");
447 if (it != metadata.end())
449 if (it->second ==
"BILEVEL")
451 wxGetApp().Yield(
true);
455 img->applyEXIFValues();
456 if(!img->getExifMake().empty() && !img->getExifModel().empty() &&
457 img->getExifFocalLength()!=0 && img->getCropFactor()!=0)
459 img->readProjectionFromDB(
false);
462 img->readDistortionFromDB();
466 img->readVignettingFromDB();
469 for(
unsigned int i=0; i<newPanos.size() && !
m_stopped && !found; i++)
472 if(newPanos[i]->BelongsTo(img,max_diff))
474 newPanos[i]->AddSrcPanoImage(img);
479 wxGetApp().Yield(
true);
486 newPanos.push_back(newPano);
496 wxGetApp().Yield(
true);
500 for(
size_t i=0; i<newPanos.size(); i++)
502 if(newPanos[i]->GetImageCount()>=minNumberImages)
504 m_panos.push_back(newPanos[i]);
518 wxDir dir(dirstring);
519 bool cont=dir.GetFirst(&filename,wxEmptyString,wxDIR_DIRS);
522 SearchInDir(dir.GetName()+wxFileName::GetPathSeparator()+filename,includeSubdir, loadDistortion, loadVignetting, minNumberImages, maxTimeDiff);
523 cont=dir.GetNext(&filename);
536 m_statustext->SetLabel(wxString::Format(_(
"Found %d possible panoramas"), static_cast<int>(
m_panos.size())));
540 m_statustext->SetLabel(_(
"No possible panoramas found"));
550 for(ImageSet::reverse_iterator it=
m_images.rbegin(); it!=
m_images.rend(); ++it)
559 if(
m_make.compare(img->getExifMake())!=0)
563 if(
m_camera.compare(img->getExifModel())!=0)
567 if(
m_lens.compare(img->getExifLens())!=0)
579 if(
m_size!=img->getSize())
592 struct tm exifdatetime;
595 return wxDateTime(exifdatetime);
600 return file.GetModificationTime();
609 m_make=img->getExifMake();
611 m_lens=img->getExifLens();
635 ImageSet::const_iterator it=
m_images.begin();
637 f1.MakeRelativeTo(BasePath);
638 ImageSet::const_reverse_iterator rit=
m_images.rbegin();
642 return f1.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR)+f1.GetName()+
"-"+f2.GetName();
646 return f1.GetFullPath()+
" - "+f2.GetFullName();
652 return wxString::Format(_(
"%d images: %s"), static_cast<int>(
m_images.size()),
GetFilestring(BasePath).c_str());
659 projectFile.SetPath(basePath);
660 projectFile.SetName(
"pano");
661 projectFile.SetExt(
"pto");
662 if(!projectFile.IsDirWritable())
673 projectFile.SetName(mask);
674 if(!projectFile.FileExists())
682 wxArrayString folders=projectFile.GetDirs();
683 if(folders.GetCount()==0)
688 projectFile.SetName(mask);
689 if(!projectFile.FileExists())
702 mask=newProject.GetName();
703 projectFile.SetName(mask);
704 if(!projectFile.FileExists())
715 projectFile.SetName(wxString::Format(mask,i));
716 while(projectFile.FileExists())
719 projectFile.SetName(wxString::Format(mask,i));
733 return wxEmptyString;
735 ImageSet::const_iterator it=
m_images.begin();
737 firstFile.MakeAbsolute();
738 wxFileName projectFile;
741 return wxEmptyString;
744 double redBalanceAnchor = (*
m_images.begin())->getExifRedBalance();
745 double blueBalanceAnchor = (*
m_images.begin())->getExifBlueBalance();
746 if (fabs(redBalanceAnchor)<1e-2)
748 redBalanceAnchor = 1;
750 if (fabs(blueBalanceAnchor)<1e-2)
752 blueBalanceAnchor = 1;
757 (*it)->setWhiteBalanceRed((*it)->getExifRedBalance() / redBalanceAnchor);
758 (*it)->setWhiteBalanceBlue((*it)->getExifBlueBalance() / blueBalanceAnchor);
779 wxConfigBase* config = wxConfigBase::Get();
825 opts.
verdandiOptions = config->Read(
"/VerdandiDefaultArgs", wxEmptyString).mb_str(wxConvLocal);
832 std::string(projectFile.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR).mb_str(
HUGIN_CONV_FILENAME))))
834 return projectFile.GetFullPath();
838 return wxEmptyString;
844 return wxString(
m_camera.c_str(), wxConvLocal);
849 return wxString(
m_lens.c_str(), wxConvLocal);
873 list->DeleteAllItems();
879 #if defined EXIV2_VERSION && EXIV2_TEST_VERSION(0,27,99)
880 Exiv2::Image::UniquePtr image;
882 Exiv2::Image::AutoPtr image;
887 image = Exiv2::ImageFactory::open((*it)->getFilename().c_str());
892 std::cerr << __FILE__ <<
" " << __LINE__ <<
" Error opening file" << std::endl;
900 image->readMetadata();
902 catch (
const Exiv2::Error& e)
904 std::cerr << __FILE__ <<
" " << __LINE__ <<
" Exiv2: Error reading metadata (" << e.what() <<
")" << std::endl;
908 Exiv2::PreviewManager previews(*image);
909 Exiv2::PreviewPropertiesList lists = previews.getPreviewProperties();
913 int previewIndex = 0;
914 while (previewIndex < lists.size() - 1 && lists[previewIndex].width_ <
THUMBSIZE && lists[previewIndex].height_ <
THUMBSIZE)
920 Exiv2::PreviewImage previewImage = previews.getPreviewImage(lists[previewIndex]);
921 wxMemoryInputStream stream(previewImage.pData(), previewImage.size());
922 rawImage.LoadFile(stream, wxString(previewImage.mimeType().c_str(), wxConvLocal), -1);
925 if (previewImage.width() > previewImage.height())
928 int newHeight =
THUMBSIZE*previewImage.height() / previewImage.width();
936 int newWidth =
THUMBSIZE*previewImage.width() / previewImage.height();
942 if ((*it)->getRoll() == 90)
944 rawImage = rawImage.Rotate90();
949 if ((*it)->getRoll() == 270)
951 rawImage = rawImage.Rotate90(
false);
956 if ((*it)->getRoll() == 180)
958 rawImage = rawImage.Rotate180();
964 wxMemoryDC dc(bitmap);
965 dc.SetBackground(list->GetBackgroundColour());
967 dc.DrawBitmap(rawImage, x, y);
968 dc.SelectObject(wxNullBitmap);
974 index = thumbs->Add(bitmap, wxBitmap(mask, 1));
979 list->InsertItem(list->GetItemCount(), fn.GetFullName(), index);
992 ImageSet::iterator item =
m_images.begin();
993 std::advance(item, index);
1009 ImageSet::iterator img = allImages.begin();
1010 while (
m_images.size() < index && img != allImages.end())
1015 while (img != allImages.end())
1037 if (dt.IsLaterThan(m_dt_end))
wxString GetFocalLength()
returns the focal length as string
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
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
unsigned int getPartNumber(unsigned int imageNr) const
Get a part number from an image number.
BlendingMechanism
blenders
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
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
WXIMPEX wxString GetFormattedTimeSpan(const wxTimeSpan &timeSpan)
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
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
wxDirPickerCtrl * m_dirPicker
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
#define HUGIN_ENBLEND_ARGS
void OnButtonSend(wxCommandEvent &e)
add selected projects to queue
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
wxString getDefaultProjectName(const HuginBase::Panorama &pano, const wxString filenameTemplate)
gets the default project name, as defined in the preferences
BlendingMechanism blendMode
wxCheckListBox * m_list_pano
void OnButtonStart(wxCommandEvent &e)
start/stops detections
std::vector< PossiblePano * > m_panos
double outputExposureValue