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())
420 return doj::alphanum_comp(std::string(s1.mb_str(wxConvLocal)),std::string(s2.mb_str(wxConvLocal)));
423 void FindPanoDialog::SearchInDir(wxString dirstring,
const bool includeSubdir,
const bool loadDistortion,
const bool loadVignetting,
const size_t minNumberImages,
const size_t maxTimeDiff)
425 std::vector<PossiblePano*> newPanos;
426 wxTimeSpan max_diff(0, 0, maxTimeDiff, 0);
428 wxArrayString fileList;
429 wxDir::GetAllFiles(dirstring,&fileList,wxEmptyString,wxDIR_FILES|wxDIR_HIDDEN);
432 for(
size_t j=0; j<fileList.size() && !
m_stopped; j++)
434 m_statustext->SetLabel(wxString::Format(_(
"Reading file %s"),fileList[j].c_str()));
435 wxFileName file(fileList[j]);
437 wxString ext=file.GetExt();
438 if(ext.CmpNoCase(
"jpg")==0 || ext.CmpNoCase(
"jpeg")==0 ||
439 ext.CmpNoCase(
"tif")==0 || ext.CmpNoCase(
"tiff")==0)
443 img->setFilename(filenamestr);
447 HuginBase::FileMetaData::const_iterator it = metadata.find(
"pixeltype");
448 if (it != metadata.end())
450 if (it->second ==
"BILEVEL")
452 wxGetApp().Yield(
true);
456 img->applyEXIFValues();
457 if(!img->getExifMake().empty() && !img->getExifModel().empty() &&
458 img->getExifFocalLength()!=0 && img->getCropFactor()!=0)
460 img->readProjectionFromDB(
false);
463 img->readDistortionFromDB();
467 img->readVignettingFromDB();
470 for(
unsigned int i=0; i<newPanos.size() && !
m_stopped && !found; i++)
473 if(newPanos[i]->BelongsTo(img,max_diff))
475 newPanos[i]->AddSrcPanoImage(img);
480 wxGetApp().Yield(
true);
487 newPanos.push_back(newPano);
497 wxGetApp().Yield(
true);
501 for(
size_t i=0; i<newPanos.size(); i++)
503 if(newPanos[i]->GetImageCount()>=minNumberImages)
505 m_panos.push_back(newPanos[i]);
519 wxDir dir(dirstring);
520 bool cont=dir.GetFirst(&filename,wxEmptyString,wxDIR_DIRS);
523 SearchInDir(dir.GetName()+wxFileName::GetPathSeparator()+filename,includeSubdir, loadDistortion, loadVignetting, minNumberImages, maxTimeDiff);
524 cont=dir.GetNext(&filename);
537 m_statustext->SetLabel(wxString::Format(_(
"Found %d possible panoramas"), static_cast<int>(
m_panos.size())));
541 m_statustext->SetLabel(_(
"No possible panoramas found"));
551 for(ImageSet::reverse_iterator it=
m_images.rbegin(); it!=
m_images.rend(); ++it)
560 if(
m_make.compare(img->getExifMake())!=0)
564 if(
m_camera.compare(img->getExifModel())!=0)
568 if(
m_lens.compare(img->getExifLens())!=0)
580 if(
m_size!=img->getSize())
593 struct tm exifdatetime;
596 return wxDateTime(exifdatetime);
601 return file.GetModificationTime();
610 m_make=img->getExifMake();
612 m_lens=img->getExifLens();
636 ImageSet::const_iterator it=
m_images.begin();
638 f1.MakeRelativeTo(BasePath);
639 ImageSet::const_reverse_iterator rit=
m_images.rbegin();
643 return f1.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR)+f1.GetName()+
"-"+f2.GetName();
647 return f1.GetFullPath()+
" - "+f2.GetFullName();
653 return wxString::Format(_(
"%d images: %s"), static_cast<int>(
m_images.size()),
GetFilestring(BasePath).c_str());
660 projectFile.SetPath(basePath);
661 projectFile.SetName(
"pano");
662 projectFile.SetExt(
"pto");
663 if(!projectFile.IsDirWritable())
674 projectFile.SetName(mask);
675 if(!projectFile.FileExists())
683 wxArrayString folders=projectFile.GetDirs();
684 if(folders.GetCount()==0)
689 projectFile.SetName(mask);
690 if(!projectFile.FileExists())
703 mask=newProject.GetName();
704 projectFile.SetName(mask);
705 if(!projectFile.FileExists())
716 projectFile.SetName(wxString::Format(mask,i));
717 while(projectFile.FileExists())
720 projectFile.SetName(wxString::Format(mask,i));
734 return wxEmptyString;
736 ImageSet::const_iterator it=
m_images.begin();
738 firstFile.MakeAbsolute();
739 wxFileName projectFile;
742 return wxEmptyString;
745 double redBalanceAnchor = (*
m_images.begin())->getExifRedBalance();
746 double blueBalanceAnchor = (*
m_images.begin())->getExifBlueBalance();
747 if (fabs(redBalanceAnchor)<1e-2)
749 redBalanceAnchor = 1;
751 if (fabs(blueBalanceAnchor)<1e-2)
753 blueBalanceAnchor = 1;
758 (*it)->setWhiteBalanceRed((*it)->getExifRedBalance() / redBalanceAnchor);
759 (*it)->setWhiteBalanceBlue((*it)->getExifBlueBalance() / blueBalanceAnchor);
780 wxConfigBase* config = wxConfigBase::Get();
826 opts.
verdandiOptions = config->Read(
"/VerdandiDefaultArgs", wxEmptyString).mb_str(wxConvLocal);
833 std::string(projectFile.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR).mb_str(
HUGIN_CONV_FILENAME))))
835 return projectFile.GetFullPath();
839 return wxEmptyString;
845 return wxString(
m_camera.c_str(), wxConvLocal);
850 return wxString(
m_lens.c_str(), wxConvLocal);
874 list->DeleteAllItems();
880 #if defined EXIV2_VERSION && EXIV2_TEST_VERSION(0,27,99)
881 Exiv2::Image::UniquePtr image;
883 Exiv2::Image::AutoPtr image;
888 image = Exiv2::ImageFactory::open((*it)->getFilename().c_str());
893 std::cerr << __FILE__ <<
" " << __LINE__ <<
" Error opening file" << std::endl;
901 image->readMetadata();
903 catch (
const Exiv2::Error& e)
905 std::cerr << __FILE__ <<
" " << __LINE__ <<
" Exiv2: Error reading metadata (" << e.what() <<
")" << std::endl;
909 Exiv2::PreviewManager previews(*image);
910 Exiv2::PreviewPropertiesList lists = previews.getPreviewProperties();
914 int previewIndex = 0;
915 while (previewIndex < lists.size() - 1 && lists[previewIndex].width_ <
THUMBSIZE && lists[previewIndex].height_ <
THUMBSIZE)
921 Exiv2::PreviewImage previewImage = previews.getPreviewImage(lists[previewIndex]);
922 wxMemoryInputStream stream(previewImage.pData(), previewImage.size());
923 rawImage.LoadFile(stream, wxString(previewImage.mimeType().c_str(), wxConvLocal), -1);
926 if (previewImage.width() > previewImage.height())
929 int newHeight =
THUMBSIZE*previewImage.height() / previewImage.width();
937 int newWidth =
THUMBSIZE*previewImage.width() / previewImage.height();
943 if ((*it)->getRoll() == 90)
945 rawImage = rawImage.Rotate90();
950 if ((*it)->getRoll() == 270)
952 rawImage = rawImage.Rotate90(
false);
957 if ((*it)->getRoll() == 180)
959 rawImage = rawImage.Rotate180();
965 wxMemoryDC dc(bitmap);
966 dc.SetBackground(list->GetBackgroundColour());
968 dc.DrawBitmap(rawImage, x, y);
969 dc.SelectObject(wxNullBitmap);
975 index = thumbs->Add(bitmap, wxBitmap(mask, 1));
980 list->InsertItem(list->GetItemCount(), fn.GetFullName(), index);
993 ImageSet::iterator item =
m_images.begin();
994 std::advance(item, index);
1010 ImageSet::iterator img = allImages.begin();
1011 while (
m_images.size() < index && img != allImages.end())
1016 while (img != allImages.end())
1038 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