25 #include "hugin_config.h"
31 #if defined (__GNUC__) && !defined (__FreeBSD__) && !defined (__clang__)
32 #include <ext/stdio_filebuf.h>
51 #if defined __WXMSW__ || defined UNIX_SELF_CONTAINED_BUNDLE
52 #include <wx/stdpaths.h>
60 #include <wx/cmdline.h>
62 #if defined MAC_SELF_CONTAINED_BUNDLE
64 #include <CoreFoundation/CFBundle.h>
67 void CPMessage(
const wxString message,
const wxString caption, wxWindow *parent)
71 wxMessageBox(message,caption,wxOK | wxICON_ERROR,parent);
75 std::cout << message << std::endl;
79 int CPExecute(wxString prog, wxString args, wxString caption, wxWindow *parent)
87 wxString cmdline=prog+wxT(
" ")+args;
88 return wxExecute(cmdline,wxEXEC_SYNC | wxEXEC_MAKE_GROUP_LEADER);
95 std::ifstream stream(file.c_str());
96 if (! stream.is_open()) {
97 DEBUG_ERROR(
"Could not open control point detector output: " << file);
114 std::map<unsigned int, unsigned int> imgMapping;
120 for(HuginBase::UIntSet::const_iterator it=imgs.begin();it!=imgs.end();++it) {
122 if (nname == oname) {
124 imgMapping[ni] = *it;
129 DEBUG_ERROR(
"Could not find image " << ni <<
", name: " << tmpp.
getImage(ni).getFilename() <<
" in autopano output");
135 for(HuginBase::UIntSet::const_iterator it=imgs.begin();it!=imgs.end();++it)
144 for (HuginBase::CPVector::iterator it = ctrlPoints.begin(); it != ctrlPoints.end(); ++it) {
145 (*it).image1Nr = imgMapping[(*it).image1Nr];
146 (*it).image2Nr = imgMapping[(*it).image2Nr];
152 #if defined MAC_SELF_CONTAINED_BUNDLE
153 wxString GetBundledProg(wxString progName)
156 wxFileName file(progName);
158 if(file.GetPath().IsEmpty())
160 return MacGetPathToBundledExecutableFile(MacCreateCFStringWithWxString(progName));
161 return wxEmptyString;
167 #if defined MAC_SELF_CONTAINED_BUNDLE
168 wxString bundled=GetBundledProg(progName);
169 if(!bundled.IsEmpty())
172 #if defined __WXMSW__ || defined UNIX_SELF_CONTAINED_BUNDLE
173 wxFileName prog(progName);
174 if(prog.IsAbsolute())
181 const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
182 pathlist.Add(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
183 pathlist.AddEnvList(wxT(
"PATH"));
184 return pathlist.FindAbsoluteValidPath(progName);
193 #if defined MAC_SELF_CONTAINED_BUNDLE
194 if(!GetBundledProg(progName).IsEmpty())
197 wxFileName prog(progName);
199 if(prog.IsAbsolute())
201 canStart=(prog.IsFileExecutable());
206 #if defined __WXMSW__ || defined UNIX_SELF_CONTAINED_BUNDLE
207 const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
208 pathlist.Add(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
210 pathlist.AddEnvList(wxT(
"PATH"));
211 wxString path = pathlist.FindAbsoluteValidPath(progName);
216 wxFileName prog2(path);
217 canStart=(prog2.IsFileExecutable());
222 _(
"Could not find \"%s\" in path.\nMaybe you have not installed it properly or given a wrong path in the settings."),progName.c_str()),
229 wxString tempDir = wxConfigBase::Get()->Read(wxT(
"tempDir"), wxT(
""));
230 if (!tempDir.IsEmpty())
232 if (tempDir.Last() != wxFileName::GetPathSeparator())
234 tempDir.Append(wxFileName::GetPathSeparator());
241 int nFeatures, wxWindow *parent)
244 return automatch(setting,pano,imgs,nFeatures,return_value,parent);
267 char * p = setlocale(LC_NUMERIC,NULL);
268 char * old_locale = strdup(p);
269 setlocale(LC_NUMERIC,
"C");
275 cps = matcher.
automatch(setting, pano, imgs, nFeatures, ret_value, parent);
282 cps = matcher.
automatch(setting, pano, imgs, nFeatures, ret_value, parent);
289 cps = matcher.
automatch(setting, pano, imgs, nFeatures, ret_value, parent);
296 cps = matcher.
automatch(setting, pano, imgs, nFeatures, ret_value, parent);
303 cps = matcher.
automatch(setting, pano, imgs, nFeatures, ret_value, parent);
310 cps = matcher.
automatch(setting, pano, imgs, nFeatures, ret_value, parent);
316 setlocale(LC_NUMERIC,old_locale);
322 std::vector<wxString> &keyFiles, wxWindow *parent)
326 if(!keyFiles.empty())
328 for(
unsigned int i=0;i<keyFiles.size();i++)
330 if(wxFileExists(keyFiles[i]))
332 if(!wxRemoveFile(keyFiles[i]))
334 DEBUG_DEBUG(
"could not remove temporary file: " << keyFiles[i].c_str());
349 if(cleanupArgs.IsEmpty())
354 wxString ptoinfile_name = wxFileName::CreateTempFileName(
GetCheckedTempDir() + (
"ap_inproj"));
356 std::ofstream ptoinstream(ptoinfile_name.mb_str(wxConvFile));
359 int ret_value=
CPExecute(cleanupExe, cleanupArgs, _(
"cleaning up temporary keypoint files"), parent);
363 DEBUG_DEBUG(
"could not cleanup temporary keypoint files");
365 if(!wxRemoveFile(ptoinfile_name))
367 DEBUG_DEBUG(
"could not remove temporary file: " << ptoinfile_name.c_str());
373 int nFeatures,
int & ret_value, wxWindow *parent)
387 const bool detectorNeedsOtherCp = (autopanoExe.Find(
"geocpset") != wxNOT_FOUND) ||
388 (autopanoExe.Find(
"linefind") != wxNOT_FOUND && pano.
getNrOfImages()==imgs.size()) ||
389 (autopanoExe.Find(
"cpfind") != wxNOT_FOUND && setting.
GetArgs().Find(
"--prealigned") != wxNOT_FOUND);
390 size_t oldCpsSize = -1;
394 cps=
automatch(setting, pano, imgs, nFeatures, keyFiles, ret_value, parent);
395 Cleanup(setting, pano, imgs, keyFiles, parent);
398 wxString autopanoArgs = setting.
GetArgs();
401 std::set<std::string> cpsHash;
406 cpsHash.insert(cp.getCPString());
411 wxString ptofile = wxFileName::CreateTempFileName(
GetCheckedTempDir() + wxT(
"ap_res"));
414 tmp.Printf(wxT(
"%d"), nFeatures);
415 autopanoArgs.Replace(wxT(
"%p"), tmp);
418 tmp.Printf(wxT(
"%f"), firstImg.getHFOV());
419 autopanoArgs.Replace(wxT(
"%v"), tmp);
421 tmp.Printf(wxT(
"%d"), (
int) firstImg.getProjection());
422 autopanoArgs.Replace(wxT(
"%f"), tmp);
424 long idx = autopanoArgs.Find(wxT(
"%namefile")) ;
425 DEBUG_DEBUG(
"find %namefile in '"<< autopanoArgs.mb_str(wxConvLocal) <<
"' returned: " << idx);
426 bool use_namefile = idx >=0;
427 idx = autopanoArgs.Find(wxT(
"%i"));
428 DEBUG_DEBUG(
"find %i in '"<< autopanoArgs.mb_str(wxConvLocal) <<
"' returned: " << idx);
429 bool use_params = idx >=0;
430 idx = autopanoArgs.Find(wxT(
"%s"));
431 bool use_inputscript = idx >=0;
433 if (! (use_namefile || use_params || use_inputscript)) {
434 CPMessage(_(
"Please use %namefile, %i or %s to specify the input files for the control point detector"),
435 _(
"Error in control point detector command"), parent);
440 wxString namefile_name;
443 namefile_name = wxFileName::CreateTempFileName(
GetCheckedTempDir() + wxT(
"ap_imgnames"), &namefile);
444 DEBUG_DEBUG(
"before replace %namefile: " << autopanoArgs.mb_str(wxConvLocal));
446 DEBUG_DEBUG(
"after replace %namefile: " << autopanoArgs.mb_str(wxConvLocal));
447 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end(); ++it)
450 namefile.Write(wxT(
"\r\n"));
453 if (namefile_name != wxString(wxT(
""))) {
457 std::string imgFiles;
458 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end(); ++it)
465 wxString ptoinfile_name;
466 if (use_inputscript) {
468 ptoinfile_name = wxFileName::CreateTempFileName(
GetCheckedTempDir() + (
"ap_inproj"));
471 std::ofstream ptoinstream(ptoinfile_name.mb_str(wxConvFile));
474 if (detectorNeedsOtherCp)
484 tempPano.setCtrlPoints(emptyCPV);
487 fill_set(tempImgSet, 0, tempPano.getNrOfImages() - 1);
488 tempPano.printPanoramaScript(ptoinstream, tempPano.getOptimizeVector(), tempPano.getOptions(), tempImgSet,
false);
492 if (autopanoArgs.size() > 32000) {
493 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"),
494 _(
"Too many images selected"), parent );
499 wxString cmd = autopanoExe + wxT(
" ") + autopanoArgs;
500 DEBUG_DEBUG(
"Executing: " << autopanoExe.mb_str(wxConvLocal) <<
" " << autopanoArgs.mb_str(wxConvLocal));
502 wxArrayString arguments = wxCmdLineParser::ConvertStringToArgs(autopanoArgs);
503 if (arguments.GetCount() > 127) {
504 DEBUG_ERROR(
"Too many arguments for call to wxExecute()");
505 DEBUG_ERROR(
"Try using the %%s parameter in preferences");
506 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);
512 ret_value =
CPExecute(autopanoExe, autopanoArgs, _(
"finding control points"), parent);
516 }
else if (ret_value == -1) {
517 CPMessage( wxString::Format(_(
"Could not execute command: %s"),cmd.c_str()), _(
"wxExecute Error"), parent);
519 }
else if (ret_value > 0) {
520 CPMessage(wxString::Format(_(
"Command: %s\nfailed with error code: %d"),cmd.c_str(),ret_value),
521 _(
"wxExecute Error"), parent);
525 if (! wxFileExists(ptofile.c_str())) {
526 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()),
527 _(
"Control point detector failure"), parent );
533 if (detectorNeedsOtherCp && oldCpsSize >= 0)
536 cps.erase(cps.begin(), cps.begin() + oldCpsSize);
541 size_t i = cps.size() - 1;
542 for (
auto it = cps.rbegin(); it != cps.rend(); ++it, --i)
547 cps.erase(cps.begin() + i);
552 if (namefile_name != wxString(wxT(
""))) {
554 wxRemoveFile(namefile_name);
557 if (ptoinfile_name != wxString(wxT(
""))) {
558 wxRemoveFile(ptoinfile_name);
561 if (!wxRemoveFile(ptofile)) {
562 DEBUG_DEBUG(
"could not remove temporary file: " << ptofile.c_str());
569 int nFeatures, std::vector<wxString> &keyFiles,
int & ret_value, wxWindow *parent)
580 wxString generateKeysArgs=setting.
GetArgs();
584 if(generateKeysArgs.Find(wxT(
"%i"))==wxNOT_FOUND || generateKeysArgs.Find(wxT(
"%k"))==wxNOT_FOUND)
586 CPMessage(_(
"Please use %i to specify the input files and %k to specify the keypoint file for the generate keys step"),
587 _(
"Error in control point detector command"), parent);
590 if(matcherArgs.Find(wxT(
"%k"))==wxNOT_FOUND || matcherArgs.Find(wxT(
"%o"))==wxNOT_FOUND)
592 CPMessage(_(
"Please use %k to specify the keypoint files and %o to specify the output project file for the matching step"),
593 _(
"Error in control point detector command"), parent);
599 for (HuginBase::UIntSet::const_iterator img = imgs.begin(); img != imgs.end(); ++img)
601 if(keyFiles[*img].IsEmpty())
604 wxString keyfile=wxFileName::CreateTempFileName(tempDir+wxT(
"apk_"));
605 keyFiles[*img]=keyfile;
606 wxString cmd=generateKeysArgs;
608 tmp.Printf(wxT(
"%d"), nFeatures);
609 cmd.Replace(wxT(
"%p"), tmp);
612 tmp.Printf(wxT(
"%f"), srcImg.getHFOV());
613 cmd.Replace(wxT(
"%v"), tmp);
615 tmp.Printf(wxT(
"%d"), (
int) srcImg.getProjection());
616 cmd.Replace(wxT(
"%f"), tmp);
621 ret_value =
CPExecute(generateKeysExe, cmd, _(
"generating key file"), parent);
622 cmd=generateKeysExe+wxT(
" ")+cmd;
628 CPMessage( wxString::Format(_(
"Could not execute command: %s"),cmd.c_str()), _(
"wxExecute Error"), parent);
634 CPMessage(wxString::Format(_(
"Command: %s\nfailed with error code: %d"),cmd.c_str(),ret_value),
635 _(
"wxExecute Error"), parent);
642 wxString ptofile = wxFileName::CreateTempFileName(
GetCheckedTempDir() + wxT(
"ap_res"));
645 tmp.Printf(wxT(
"%d"), nFeatures);
646 matcherArgs.Replace(wxT(
"%p"), tmp);
649 tmp.Printf(wxT(
"%f"), firstImg.getHFOV());
650 matcherArgs.Replace(wxT(
"%v"), tmp);
652 tmp.Printf(wxT(
"%d"), (
int) firstImg.getProjection());
653 matcherArgs.Replace(wxT(
"%f"), tmp);
656 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end(); ++it)
663 if (matcherArgs.size() > 32000) {
664 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"),
665 _(
"Too many images selected"), parent );
670 wxString cmd = matcherExe + wxT(
" ") + matcherArgs;
671 DEBUG_DEBUG(
"Executing: " << matcherExe.mb_str(wxConvLocal) <<
" " << matcherArgs.mb_str(wxConvLocal));
673 wxArrayString arguments = wxCmdLineParser::ConvertStringToArgs(matcherArgs);
674 if (arguments.GetCount() > 127) {
675 DEBUG_ERROR(
"Too many arguments for call to wxExecute()");
676 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);
681 ret_value =
CPExecute(matcherExe, matcherArgs, _(
"finding control points"), parent);
688 CPMessage( wxString::Format(_(
"Could not execute command: %s"),cmd.c_str()), _(
"wxExecute Error"), parent);
694 CPMessage(wxString::Format(_(
"Command: %s\nfailed with error code: %d"),cmd.c_str(),ret_value),
695 _(
"wxExecute Error"), parent);
699 if (! wxFileExists(ptofile.c_str()))
701 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()),
702 _(
"Control point detector failure"), parent );
709 if (!wxRemoveFile(ptofile)) {
710 DEBUG_DEBUG(
"could not remove temporary file: " << ptofile.c_str());
717 int nFeatures,
int & ret_value, wxWindow *parent)
720 wxString autopanoExe = setting.
GetProg();
723 wxString autopanoArgs = setting.
GetArgs();
725 std::string imgFiles;
726 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end(); ++it)
731 wxString ptofilepath = wxFileName::CreateTempFileName(
GetCheckedTempDir() + wxT(
"ap_res"));
732 wxFileName ptofn(ptofilepath);
733 wxString ptofile = ptofn.GetFullName();
736 tmp.Printf(wxT(
"%d"), nFeatures);
737 autopanoArgs.Replace(wxT(
"%p"), tmp);
739 tmp.Printf(wxT(
"%f"), firstImg.getHFOV());
740 autopanoArgs.Replace(wxT(
"%v"), tmp);
742 tmp.Printf(wxT(
"%d"), (
int) firstImg.getProjection());
743 autopanoArgs.Replace(wxT(
"%f"), tmp);
747 wxString tempdir = ptofn.GetPath();
748 autopanoArgs.Replace(wxT(
"%d"), ptofn.GetPath());
752 if (cmd.size() > 32766) {
753 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"),
754 _(
"Too many images selected"), parent);
760 wxArrayString arguments = wxCmdLineParser::ConvertStringToArgs(cmd);
761 if (arguments.GetCount() > 127) {
762 DEBUG_ERROR(
"Too many arguments for call to wxExecute()");
763 DEBUG_ERROR(
"Try using the %s parameter in preferences");
764 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);
770 ret_value =
CPExecute(autopanoExe, autopanoArgs, _(
"finding control points"), parent);
774 }
else if (ret_value == -1) {
775 CPMessage( wxString::Format(_(
"Could not execute command: %s"),cmd.c_str()), _(
"wxExecute Error"), parent);
777 }
else if (ret_value > 0) {
778 CPMessage(wxString::Format(_(
"Command: %s\nfailed with error code: %d"),cmd.c_str(),ret_value),
779 _(
"wxExecute Error"), parent);
783 ptofile = ptofn.GetFullPath();
784 ptofile.append(wxT(
"0.oto"));
785 if (! wxFileExists(ptofile.c_str()) ) {
786 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()),
787 _(
"Control point detector failure"), parent );
793 if (!wxRemoveFile(ptofile)) {
794 DEBUG_DEBUG(
"could not remove temporary file: " << ptofile.c_str());
813 for(
unsigned int i=0;i<new_cp.size();i++)
816 bool duplicate=
false;
817 for(
unsigned int j=0;j<cpv.size();j++)
829 pano->addCtrlPoint(cp);
835 int nFeatures,
int & ret_value, wxWindow *parent)
841 std::vector<stack_img> stack_images;
843 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end(); ++it)
848 unsigned int index=0;
849 for(index=0;index<stack_images.size();index++)
851 found=(stack_images[index].layer_nr==stack_nr);
858 stack_images.resize(stack_images.size()+1);
859 index=stack_images.size()-1;
861 stack_images[index].layer_nr=stack_nr;
864 unsigned int new_image_index=stack_images[index].images.size();
865 stack_images[index].images.resize(new_image_index+1);
866 stack_images[index].images[new_image_index].img_nr=*it;
869 delete variable_groups;
872 for(
unsigned int i=0;i<stack_images.size();i++)
874 std::sort(stack_images[i].images.begin(),stack_images[i].images.end(),
sort_img_ev);
875 unsigned int index=0;
876 if(stack_images[i].images[0].ev!=stack_images[i].images[stack_images[i].images.size()-1].ev)
878 index=stack_images[i].images.size() / 2;
880 images_layer.insert(stack_images[i].images[index].img_nr);
884 if(images_layer.size()>1)
887 cps=matcher.
automatch(setting, pano, images_layer, nFeatures, ret_value, parent);
899 for(
unsigned int i=0;i<stack_images.size();i++)
902 images_stack.clear();
903 for(
unsigned int j=0;j<stack_images[i].images.size();j++)
904 images_stack.insert(stack_images[i].images[j].img_nr);
905 if(images_stack.size()>1)
920 int nFeatures,
int & ret_value, wxWindow *parent)
929 unsigned int counter=0;
930 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end();)
932 if(counter==imgs.size()-1)
937 ImagePair.insert(*it);
939 ImagePair.insert(*it);
944 new_cps=matcher.
automatch(setting, pano, ImagePair, nFeatures, keyFiles, ret_value, parent);
946 new_cps=matcher.
automatch(setting, pano, ImagePair, nFeatures, ret_value, parent);
951 Cleanup(setting, pano, imgs, keyFiles, parent);
960 for (HuginBase::CPVector::const_iterator it = cps.begin(); it != cps.end(); ++it)
965 size_t n = comps.size();
969 for(
size_t i=0;i<n;i++)
971 ImagesGroups.insert(*(comps[i].begin()));
972 if(comps[i].size()>1)
973 ImagesGroups.insert(*(comps[i].rbegin()));
978 new_cps=matcher.
automatch(setting, optPano, ImagesGroups, nFeatures, keyFiles, ret_value, parent);
980 new_cps=matcher.
automatch(setting, optPano, ImagesGroups, nFeatures, ret_value, parent);
985 Cleanup(setting, pano, imgs, keyFiles, parent);
1002 optPano.setOptions(opts);
1007 optPano.setOptions(opts);
1012 for (
unsigned i=0; i < optPano.getNrOfImages(); i++)
1014 std::set<std::string> imgopt;
1023 if(!optPano.getImage(i).YawisLinkedWith(anchorImage))
1029 optvars.push_back(imgopt);
1031 optPano.setOptimizeVector(optvars);
1036 for (HuginBase::CPVector::const_iterator it = backupOldCPS.begin(); it != backupOldCPS.end(); ++it) {
1039 backupNewCPS.push_back(*it);
1042 optPano.setCtrlPoints(backupNewCPS);
1046 optPano.setCtrlPoints(backupOldCPS);
1061 new_cps=matcher.
automatch(newSetting, optPano, imgs, nFeatures, keyFiles, ret_value, parent);
1063 new_cps=matcher.
automatch(newSetting, optPano, imgs, nFeatures, ret_value, parent);
1064 if(!new_cps.empty())
1067 Cleanup(setting, pano, imgs, keyFiles, parent);
1072 int nFeatures,
int & ret_value, wxWindow *parent)
1078 std::vector<stack_img> stack_images;
1080 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end(); ++it)
1085 unsigned int index=0;
1086 for(index=0;index<stack_images.size();index++)
1088 found=(stack_images[index].layer_nr==stack_nr);
1095 stack_images.resize(stack_images.size()+1);
1096 index=stack_images.size()-1;
1098 stack_images[index].layer_nr=stack_nr;
1101 unsigned int new_image_index=stack_images[index].images.size();
1102 stack_images[index].images.resize(new_image_index+1);
1103 stack_images[index].images[new_image_index].img_nr=*it;
1106 delete variable_groups;
1109 for(
unsigned int i=0;i<stack_images.size();i++)
1111 std::sort(stack_images[i].images.begin(),stack_images[i].images.end(),
sort_img_ev);
1112 unsigned int index=0;
1113 if(stack_images[i].images[0].ev!=stack_images[i].images[stack_images[i].images.size()-1].ev)
1115 index=stack_images[i].images.size() / 2;
1117 images_layer.insert(stack_images[i].images[index].img_nr);
1128 for(
unsigned int i=0;i<stack_images.size();i++)
1131 images_stack.clear();
1132 for(
unsigned int j=0;j<stack_images[i].images.size();j++)
1133 images_stack.insert(stack_images[i].images[j].img_nr);
1134 if(images_stack.size()>1)
1138 if(!new_cps.empty())
1142 std::vector<wxString> emptyKeyfiles;
1143 Cleanup(setting, pano, imgs, emptyKeyfiles, parent);
1150 if(images_layer.size()>1)
1156 for (HuginBase::CPVector::const_iterator it = cps.begin(); it != cps.end(); ++it)
1161 if(!new_cps.empty())
1168 int nFeatures,
int & ret_value, wxWindow *parent)
1171 return automatch(setting, pano, imgs, nFeatures, keyFiles, ret_value, parent);
1175 int nFeatures, std::vector<wxString> &keyFiles,
int & ret_value, wxWindow *parent)
1182 std::vector<HuginBase::UIntSet> usedImages;
1188 for(
unsigned i=0;i<oldCps.size();i++)
1192 usedImages[oldCps[i].image1Nr].insert(oldCps[i].image2Nr);
1193 usedImages[oldCps[i].image2Nr].insert(oldCps[i].image1Nr);
1199 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end(); ++it)
1204 HuginBase::UIntSet::const_iterator it2 = it;
1205 for(++it2;it2!=imgs.end();++it2)
1213 images.insert(*it2);
1219 for (HuginBase::UIntSet::const_iterator img_it = images.begin(); img_it != images.end(); ++img_it)
1220 for (HuginBase::UIntSet::const_iterator img_it2 = images.begin(); img_it2 != images.end(); ++img_it2)
1221 usedImages[*img_it].insert(*img_it2);
1225 new_cps=matcher.
automatch(setting, pano, images, nFeatures, keyFiles, ret_value, parent);
1227 new_cps=matcher.
automatch(setting, pano, images, nFeatures, ret_value, parent);
1228 if(!new_cps.empty())
1232 Cleanup(setting, pano, imgs, keyFiles, parent);
1236 Cleanup(setting, pano, imgs, keyFiles, parent);
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 ...
wxString GetProgPath(wxString progName)
void setMemento(const PanoramaMemento &memento)
set the internal state
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.
void setHeight(unsigned int h)
set panorama height
unsigned int getPartNumber(unsigned int imageNr) const
Get a part number from an image number.
double getOverlap(unsigned int i, unsigned int j) const
returns the overlap for 2 images with number i and j
const CPDetectorType GetType()
return type of this setting
const int HUGIN_EXIT_CODE_CANCELLED
SrcPanoImage getSrcImage(unsigned imgNr) const
get a description of a source image
ImageVariableGroup & getStacks()
Get the ImageVariableGroup representing the group of stack variables.
A matcher that uses Alexandres sift matcher.
Somewhere to specify what variables belong to what.
void SetType(CPDetectorType new_type)
sets type of this setting
bool IsConnected()
check if all images are connected
HuginBase::CPVector readUpdatedControlPoints(const std::string &file, HuginBase::Panorama &pano, const HuginBase::UIntSet &imgs, bool reordered)
std::size_t getNrOfCtrlPoints() const
number of control points
A matcher for multi-rows, which considers stacks.
bool set_contains(const _Container &c, const typename _Container::key_type &key)
#define DEBUG_ASSERT(cond)
void SetArgs(wxString new_args)
sets arguments of one step detector or feature descriptor
void calculate(unsigned int steps)
does the calculation, for each image steps*steps points are extracted and tested with all other image...
include file for the hugin project
wxString GetCheckedTempDir()
Panorama getSubset(const UIntSet &imgs) const
get a subset of the panorama
int CPExecute(wxString prog, wxString args, wxString caption, wxWindow *parent)
const CPVector & getCtrlPoints() const
get all control point of this Panorama
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.
represents a control point
A matcher for multi-row panoramas based on an idea by Bruno Postle.
str quoteFilename(const str &arg)
Quote a filename, so that it is surrounded by "".
std::vector< HuginBase::UIntSet > Components
stores the components of the graph
void AddControlPointsWithCheck(HuginBase::CPVector &cpv, HuginBase::CPVector &new_cp, HuginBase::Panorama *pano=NULL)
std::set< unsigned int > UIntSet
virtual void Cleanup(CPDetectorSetting &setting, HuginBase::Panorama &pano, const HuginBase::UIntSet &imgs, std::vector< wxString > &keyFiles, wxWindow *parent=NULL)
const wxString GetProgMatcher()
return program for feature matcher
void CPMessage(const wxString message, const wxString caption, wxWindow *parent)
void SetArgsMatcher(wxString new_args)
sets arguments for feature matcher
unsigned int addCtrlPoint(const ControlPoint &point)
add a new control point.
const OptimizeVector & getOptimizeVector() const
return the optimize settings stored inside panorama
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.
bool loadPTScript(std::istream &i, int &ptoVersion, const std::string &prefix="")
load a Hugin file
class, which stores all settings of one cp detector
std::size_t getNrOfImages() const
number of images.
const wxString GetArgsMatcher()
return arguments for feature matcher
void SetProg(wxString new_prog)
sets program for one step detector or feature descriptor
static double calcOptimalScale(PanoramaData &panorama)
const wxString GetArgs()
return arguments of one step detector or feature descriptor
std::vector< img_ev > images
const wxString GetArgsCleanup()
return arguments for the cleanup step
const wxString GetProgStack()
return program name, which works on stacks
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.
const wxString GetArgsStack()
return arguments of program for detection of cp in stacks
const bool GetOption()
gets options, used in multi-row and prealigned cp detectors
!! from PTOptimise.h 1951
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.
double getExposure() const
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.
void SetProgMatcher(wxString new_prog)
sets program for feature matcher
const bool IsTwoStepDetector()
returns true, if setting is suitable for two step detector otherwise false
bool CanStartProg(wxString progName, wxWindow *parent)
include file for the hugin project
const PanoramaOptions & getOptions() const
returns the options for this panorama
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.
Components GetComponents()
find all connected components
bool sort_img_ev(img_ev i1, img_ev i2)
definitions of classes to calculate overlap between different images
Memento class for a Panorama object.
std::vector< ControlPoint > CPVector
functions for interaction with the hugin configuration file
std::vector< std::set< std::string > > OptimizeVector
class for calculating overlap of images
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
void SetOption(bool new_option)
set options, used in multi-row cp and prealigned detectors
void fill_set(_Container &c, typename _Container::key_type begin, typename _Container::key_type end)
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
A matcher that uses the align information in the panorama to generate cp between overlapping images...
str wxQuoteFilename(const str &arg)
Quote a filename, so that it is surrounded by "".
static const bool IsCleanupPossible(CPDetectorType _type)
return true, if setting allows a final cleanup run
A matcher that uses Sebastians Nowozin's excellent sift matcher.
All variables of a source image.
void setProjection(ProjectionFormat f)
set the Projection format and adjust the hfov/vfov if nessecary
std::string stripPath(const std::string &filename)
remove the path of a filename (mainly useful for gui display of filenames)
void setWidth(unsigned int w, bool keepView=true)
set panorama width keep the HFOV, if keepView=true
static void autoOptimise(PanoramaData &pano, bool optRoll=true)
unsigned int optimizeReferenceImage
const wxString GetProg()
return program for one step detector or feature descriptor
class to work with images graphs created from a HuginBase::Panorama class it creates a graph based on...