25#include "hugin_config.h"
31#if defined (__GNUC__) && !defined (__FreeBSD__) && !defined (__clang__)
32#include <ext/stdio_filebuf.h>
52#if defined __WXMSW__ || defined UNIX_SELF_CONTAINED_BUNDLE
53#include <wx/stdpaths.h>
61#include <wx/cmdline.h>
63#if defined MAC_SELF_CONTAINED_BUNDLE
65 #include <CoreFoundation/CFBundle.h>
76 std::cout <<
message << std::endl;
96 std::ifstream
stream(file.c_str());
98 DEBUG_ERROR(
"Could not open control point detector output: " << file);
106 tmpp.setMemento(newPano);
109 if(
tmpp.getNrOfImages()!=imgs.size())
115 std::map<unsigned int, unsigned int>
imgMapping;
119 for (
unsigned int ni = 0;
ni <
tmpp.getNrOfImages();
ni++) {
121 for(HuginBase::UIntSet::const_iterator
it=imgs.begin();
it!=imgs.end();++
it) {
130 DEBUG_ERROR(
"Could not find image " <<
ni <<
", name: " <<
tmpp.getImage(
ni).getFilename() <<
" in autopano output");
136 for(HuginBase::UIntSet::const_iterator
it=imgs.begin();
it!=imgs.end();++
it)
145 for (HuginBase::CPVector::iterator
it = ctrlPoints.begin();
it != ctrlPoints.end(); ++
it) {
153#if defined MAC_SELF_CONTAINED_BUNDLE
159 if(file.GetPath().IsEmpty())
168#if defined MAC_SELF_CONTAINED_BUNDLE
173#if defined __WXMSW__ || defined UNIX_SELF_CONTAINED_BUNDLE
175 if(prog.IsAbsolute())
194#if defined MAC_SELF_CONTAINED_BUNDLE
200 if(prog.IsAbsolute())
207#if defined __WXMSW__ || defined UNIX_SELF_CONTAINED_BUNDLE
223 _(
"Could not find \"%s\" in path.\nMaybe you have not installed it properly or given a wrong path in the settings."),
progName.c_str()),
233 if (
tempDir.Last() != wxFileName::GetPathSeparator())
235 tempDir.Append(wxFileName::GetPathSeparator());
260 if(
setting.IsTwoStepDetector())
264 if(!
setting.GetProgStack().IsEmpty())
325 if(
setting.IsTwoStepDetector())
343 if(!
setting.IsCleanupPossible())
364 DEBUG_DEBUG(
"could not cleanup temporary keypoint files");
392 if(
setting.IsTwoStepDetector())
419 tmp.Printf(
"%f",
firstImg.getHFOV());
422 tmp.Printf(
"%d", (
int)
firstImg.getProjection());
435 CPMessage(
_(
"Please use %namefile, %i or %s to specify the input files for the control point detector"),
436 _(
"Error in control point detector command"),
parent);
448 for (HuginBase::UIntSet::const_iterator
it = imgs.begin();
it != imgs.end(); ++
it)
459 for (HuginBase::UIntSet::const_iterator
it = imgs.begin();
it != imgs.end(); ++
it)
494 CPMessage(
_(
"Command line for control point detector too long.\nThis is a Windows limitation\nPlease select less images, or place the images in a folder with\na shorter pathname"),
495 _(
"Too many images selected"),
parent );
505 DEBUG_ERROR(
"Too many arguments for call to wxExecute()");
506 DEBUG_ERROR(
"Try using the %%s parameter in preferences");
507 CPMessage(wxString::Format(
_(
"Too many arguments (images). Try using the %%s parameter in preferences.\n\n Could not execute command: %s"),
autopanoExe.c_str()),
_(
"wxExecute Error"),
parent);
518 CPMessage( wxString::Format(
_(
"Could not execute command: %s"),
cmd.c_str()),
_(
"wxExecute Error"),
parent);
527 CPMessage(wxString::Format(
_(
"Could not open %s for reading\nThis is an indicator that the control point detector call failed,\nor incorrect command line parameters have been used.\n\nExecuted command: %s"),
ptofile.c_str(),
cmd.c_str()),
528 _(
"Control point detector failure"),
parent );
537 cps.erase(cps.begin(), cps.begin() +
oldCpsSize);
542 size_t i = cps.size() - 1;
543 for (
auto it = cps.rbegin();
it != cps.rend(); ++
it, --
i)
548 cps.erase(cps.begin() +
i);
587 CPMessage(
_(
"Please use %i to specify the input files and %k to specify the keypoint file for the generate keys step"),
588 _(
"Error in control point detector command"),
parent);
593 CPMessage(
_(
"Please use %k to specify the keypoint files and %o to specify the output project file for the matching step"),
594 _(
"Error in control point detector command"),
parent);
600 for (HuginBase::UIntSet::const_iterator img = imgs.begin(); img != imgs.end(); ++img)
610 cmd.Replace(
"%p", tmp);
613 tmp.Printf(
"%f",
srcImg.getHFOV());
614 cmd.Replace(
"%v", tmp);
616 tmp.Printf(
"%d", (
int)
srcImg.getProjection());
617 cmd.Replace(
"%f", tmp);
629 CPMessage( wxString::Format(
_(
"Could not execute command: %s"),
cmd.c_str()),
_(
"wxExecute Error"),
parent);
650 tmp.Printf(
"%f",
firstImg.getHFOV());
653 tmp.Printf(
"%d", (
int)
firstImg.getProjection());
657 for (HuginBase::UIntSet::const_iterator
it = imgs.begin();
it != imgs.end(); ++
it)
665 CPMessage(
_(
"Command line for control point detector too long.\nThis is a Windows limitation\nPlease select less images, or place the images in a folder with\na shorter pathname"),
666 _(
"Too many images selected"),
parent );
676 DEBUG_ERROR(
"Too many arguments for call to wxExecute()");
677 CPMessage(wxString::Format(
_(
"Too many arguments (images). Try using a cp generator setting which supports the %%s parameter in preferences.\n\n Could not execute command: %s"),
matcherExe.c_str()),
_(
"wxExecute Error"),
parent);
689 CPMessage( wxString::Format(
_(
"Could not execute command: %s"),
cmd.c_str()),
_(
"wxExecute Error"),
parent);
702 CPMessage(wxString::Format(
_(
"Could not open %s for reading\nThis is an indicator that the control point detector call failed,\nor incorrect command line parameters have been used.\n\nExecuted command: %s"),
ptofile.c_str(),
cmd.c_str()),
703 _(
"Control point detector failure"),
parent );
727 for (HuginBase::UIntSet::const_iterator
it = imgs.begin();
it != imgs.end(); ++
it)
740 tmp.Printf(
"%f",
firstImg.getHFOV());
743 tmp.Printf(
"%d", (
int)
firstImg.getProjection());
753 if (
cmd.size() > 32766) {
754 CPMessage(
_(
"Command line for control point detector too long.\nThis is a Windows limitation\nPlease select less images, or place the images in a folder with\na shorter pathname"),
755 _(
"Too many images selected"),
parent);
763 DEBUG_ERROR(
"Too many arguments for call to wxExecute()");
764 DEBUG_ERROR(
"Try using the %s parameter in preferences");
765 CPMessage(wxString::Format(
_(
"Too many arguments (images). Try using the %%s parameter in preferences.\n\n Could not execute command: %s"),
autopanoExe.c_str()),
_(
"wxExecute Error"),
parent);
776 CPMessage( wxString::Format(
_(
"Could not execute command: %s"),
cmd.c_str()),
_(
"wxExecute Error"),
parent);
787 CPMessage(wxString::Format(
_(
"Could not open %s for reading\nThis is an indicator that the control point detector call failed,\nor incorrect command line parameters have been used.\n\nExecuted command: %s"),
ptofile.c_str(),
cmd.c_str()),
788 _(
"Control point detector failure"),
parent );
814 for(
unsigned int i=0;
i<
new_cp.size();
i++)
817 bool duplicate=
false;
818 for(
unsigned int j=0;
j<
cpv.size();
j++)
830 pano->addCtrlPoint(
cp);
844 for (HuginBase::UIntSet::const_iterator
it = imgs.begin();
it != imgs.end(); ++
it)
849 unsigned int index=0;
876 unsigned int index=0;
893 if(!
setting.GetProgStack().IsEmpty())
930 unsigned int counter=0;
931 for (HuginBase::UIntSet::const_iterator
it = imgs.begin();
it != imgs.end();)
933 if(counter==imgs.size()-1)
944 if(
setting.IsTwoStepDetector())
961 for (HuginBase::CPVector::const_iterator
it = cps.begin();
it != cps.end(); ++
it)
970 for(
size_t i=0;
i<
n;
i++)
978 if(
setting.IsTwoStepDetector())
990 n =
graph2.IsConnected() ? 1 : 2;
1013 for (
unsigned i=0;
i <
optPano.getNrOfImages();
i++)
1015 std::set<std::string>
imgopt;
1030 optvars.push_back(
imgopt);
1032 optPano.setOptimizeVector(optvars);
1054 if(
setting.IsTwoStepDetector())
1061 if(
setting.IsTwoStepDetector())
1081 for (HuginBase::UIntSet::const_iterator
it = imgs.begin();
it != imgs.end(); ++
it)
1086 unsigned int index=0;
1113 unsigned int index=0;
1122 if(!
setting.GetProgStack().IsEmpty())
1157 for (HuginBase::CPVector::const_iterator
it = cps.begin();
it != cps.end(); ++
it)
1200 for (HuginBase::UIntSet::const_iterator
it = imgs.begin();
it != imgs.end(); ++
it)
1205 HuginBase::UIntSet::const_iterator
it2 =
it;
1214 images.insert(*
it2);
1220 for (HuginBase::UIntSet::const_iterator
img_it = images.begin();
img_it != images.end(); ++
img_it)
1221 for (HuginBase::UIntSet::const_iterator
img_it2 = images.begin();
img_it2 != images.end(); ++
img_it2)
1225 if(
setting.IsTwoStepDetector())
void CPMessage(const wxString message, const wxString caption, wxWindow *parent)
int CPExecute(wxString prog, wxString args, wxString caption, wxWindow *parent)
void AddControlPointsWithCheck(HuginBase::CPVector &cpv, HuginBase::CPVector &new_cp, HuginBase::Panorama *pano=NULL)
bool sort_img_ev(img_ev i1, img_ev i2)
wxString GetProgPath(wxString progName)
bool CanStartProg(wxString progName, wxWindow *parent)
wxString GetCheckedTempDir()
@ CPDetector_AutoPanoSiftMultiRow
@ CPDetector_AutoPanoSiftStack
@ CPDetector_AutoPanoSiftMultiRowStack
@ CPDetector_AutoPanoSift
@ CPDetector_AutoPanoSiftPreAlign
definitions of classes to calculate overlap between different images
int MyExecuteCommandOnDialog(wxString command, wxString args, wxWindow *parent, wxString title, bool isQuoted)
execute a single command in own dialog, redirect output to frame and allow canceling
const int HUGIN_EXIT_CODE_CANCELLED
!! from PTOptimise.h 1951
Somewhere to specify what variables belong to what.
HuginBase::CPVector readUpdatedControlPoints(const std::string &file, HuginBase::Panorama &pano, const HuginBase::UIntSet &imgs, bool reordered)
virtual void Cleanup(CPDetectorSetting &setting, HuginBase::Panorama &pano, const HuginBase::UIntSet &imgs, std::vector< wxString > &keyFiles, wxWindow *parent=NULL)
virtual HuginBase::CPVector automatch(CPDetectorSetting &setting, HuginBase::Panorama &pano, const HuginBase::UIntSet &imgs, int nFeatures, int &ret_value, wxWindow *parent=NULL)
Do cp matching, calles the right routines, based on the matcher selected.
A matcher that uses Alexandres sift matcher.
virtual HuginBase::CPVector automatch(CPDetectorSetting &setting, HuginBase::Panorama &pano, const HuginBase::UIntSet &imgs, int nFeatures, int &ret_value, wxWindow *parent=NULL)
Do cp matching, calles the right routines, based on the matcher selected.
A matcher for multi-rows, which considers stacks.
virtual HuginBase::CPVector automatch(CPDetectorSetting &setting, HuginBase::Panorama &pano, const HuginBase::UIntSet &imgs, int nFeatures, int &ret_value, wxWindow *parent=NULL)
Do cp matching, calles the right routines, based on the matcher selected.
A matcher for multi-row panoramas based on an idea by Bruno Postle.
virtual HuginBase::CPVector automatch(CPDetectorSetting &setting, HuginBase::Panorama &pano, const HuginBase::UIntSet &imgs, int nFeatures, int &ret_value, wxWindow *parent=NULL)
Do cp matching, calles the right routines, based on the matcher selected.
A matcher that uses the align information in the panorama to generate cp between overlapping images.
virtual HuginBase::CPVector automatch(CPDetectorSetting &setting, HuginBase::Panorama &pano, const HuginBase::UIntSet &imgs, int nFeatures, int &ret_value, wxWindow *parent=NULL)
Do cp matching, calles the right routines, based on the matcher selected.
A matcher that uses Sebastians Nowozin's excellent sift matcher and considers stacks.
virtual HuginBase::CPVector automatch(CPDetectorSetting &setting, HuginBase::Panorama &pano, const HuginBase::UIntSet &imgs, int nFeatures, int &ret_value, wxWindow *parent=NULL)
Do cp matching, calles the right routines, based on the matcher selected.
A matcher that uses Sebastians Nowozin's excellent sift matcher.
virtual HuginBase::CPVector automatch(CPDetectorSetting &setting, HuginBase::Panorama &pano, const HuginBase::UIntSet &imgs, int nFeatures, int &ret_value, wxWindow *parent=NULL)
Do cp matching, calles the right routines, based on the matcher selected.
class, which stores all settings of one cp detector
void SetProg(wxString new_prog)
sets program for one step detector or feature descriptor
void SetType(CPDetectorType new_type)
sets type of this setting
static void autoOptimise(PanoramaData &pano, bool optRoll=true)
class for calculating overlap of images
static double calcOptimalScale(PanoramaData &panorama)
represents a control point
Memento class for a Panorama object.
bool loadPTScript(std::istream &i, int &ptoVersion, const std::string &prefix="")
load a Hugin file
void setProjection(ProjectionFormat f)
set the Projection format and adjust the hfov/vfov if nessecary
unsigned int optimizeReferenceImage
void setHeight(unsigned int h)
set panorama height
void setWidth(unsigned int w, bool keepView=true)
set panorama width keep the HFOV, if keepView=true
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
SrcPanoImage getSrcImage(unsigned imgNr) const
get a description of a source image
unsigned int addCtrlPoint(const ControlPoint &point)
add a new control point.
void printPanoramaScript(std::ostream &o, const OptimizeVector &optvars, const PanoramaOptions &options, const UIntSet &imgs, bool forPTOptimizer, const std::string &stripPrefix="") const
create an optimizer script
std::size_t getNrOfCtrlPoints() const
number of control points
const CPVector & getCtrlPoints() const
get all control point of this Panorama
Panorama getSubset(const UIntSet &imgs) const
get a subset of the panorama
const OptimizeVector & getOptimizeVector() const
return the optimize settings stored inside panorama
std::size_t getNrOfImages() const
number of images.
All variables of a source image.
double getExposure() const
class to work with images graphs created from a HuginBase::Panorama class it creates a graph based on...
std::vector< HuginBase::UIntSet > Components
stores the components of the graph
functions for interaction with the hugin configuration file
#define DEBUG_ASSERT(cond)
std::vector< ControlPoint > CPVector
std::vector< std::set< std::string > > OptimizeVector
std::set< unsigned int > UIntSet
str quoteFilename(const str &arg)
Quote a filename, so that it is surrounded by "".
str wxQuoteFilename(const str &arg)
Quote a filename, so that it is surrounded by "".
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
std::string stripPath(const std::string &filename)
remove the path of a filename (mainly useful for gui display of filenames)
include file for the hugin project
include file for the hugin project
bool set_contains(const _Container &c, const typename _Container::key_type &key)
void fill_set(_Container &c, typename _Container::key_type begin, typename _Container::key_type end)
std::vector< img_ev > images
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.