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>
68 void CPMessage(
const wxString message,
const wxString caption, wxWindow *parent)
76 std::cout << message << std::endl;
80 int CPExecute(wxString prog, wxString args, wxString caption, wxWindow *parent)
88 wxString cmdline=prog+
" "+args;
89 return wxExecute(cmdline,wxEXEC_SYNC | wxEXEC_MAKE_GROUP_LEADER);
96 std::ifstream stream(file.c_str());
97 if (! stream.is_open()) {
98 DEBUG_ERROR(
"Could not open control point detector output: " << file);
115 std::map<unsigned int, unsigned int> imgMapping;
121 for(HuginBase::UIntSet::const_iterator it=imgs.begin();it!=imgs.end();++it) {
123 if (nname == oname) {
125 imgMapping[ni] = *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) {
146 (*it).image1Nr = imgMapping[(*it).image1Nr];
147 (*it).image2Nr = imgMapping[(*it).image2Nr];
153 #if defined MAC_SELF_CONTAINED_BUNDLE
154 wxString GetBundledProg(wxString progName)
157 wxFileName file(progName);
159 if(file.GetPath().IsEmpty())
161 return MacGetPathToBundledExecutableFile(MacCreateCFStringWithWxString(progName));
162 return wxEmptyString;
168 #if defined MAC_SELF_CONTAINED_BUNDLE
169 wxString bundled=GetBundledProg(progName);
170 if(!bundled.IsEmpty())
173 #if defined __WXMSW__ || defined UNIX_SELF_CONTAINED_BUNDLE
174 wxFileName prog(progName);
175 if(prog.IsAbsolute())
182 const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
183 pathlist.Add(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
184 pathlist.AddEnvList(
"PATH");
185 return pathlist.FindAbsoluteValidPath(progName);
194 #if defined MAC_SELF_CONTAINED_BUNDLE
195 if(!GetBundledProg(progName).IsEmpty())
198 wxFileName prog(progName);
200 if(prog.IsAbsolute())
202 canStart=(prog.IsFileExecutable());
207 #if defined __WXMSW__ || defined UNIX_SELF_CONTAINED_BUNDLE
208 const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
209 pathlist.Add(exePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
211 pathlist.AddEnvList(
"PATH");
212 wxString path = pathlist.FindAbsoluteValidPath(progName);
217 wxFileName prog2(path);
218 canStart=(prog2.IsFileExecutable());
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()),
230 wxString tempDir = wxConfigBase::Get()->Read(
"tempDir", wxEmptyString);
231 if (!tempDir.IsEmpty())
233 if (tempDir.Last() != wxFileName::GetPathSeparator())
235 tempDir.Append(wxFileName::GetPathSeparator());
242 int nFeatures, wxWindow *parent)
245 return automatch(setting,pano,imgs,nFeatures,return_value,parent);
268 char * p = setlocale(LC_NUMERIC,NULL);
269 char * old_locale = strdup(p);
270 setlocale(LC_NUMERIC,
"C");
276 cps = matcher.
automatch(setting, pano, imgs, nFeatures, ret_value, parent);
283 cps = matcher.
automatch(setting, pano, imgs, nFeatures, ret_value, parent);
290 cps = matcher.
automatch(setting, pano, imgs, nFeatures, ret_value, parent);
297 cps = matcher.
automatch(setting, pano, imgs, nFeatures, ret_value, parent);
304 cps = matcher.
automatch(setting, pano, imgs, nFeatures, ret_value, parent);
311 cps = matcher.
automatch(setting, pano, imgs, nFeatures, ret_value, parent);
317 setlocale(LC_NUMERIC,old_locale);
323 std::vector<wxString> &keyFiles, wxWindow *parent)
327 if(!keyFiles.empty())
329 for(
unsigned int i=0;i<keyFiles.size();i++)
331 if(wxFileExists(keyFiles[i]))
333 if(!wxRemoveFile(keyFiles[i]))
335 DEBUG_DEBUG(
"could not remove temporary file: " << keyFiles[i].c_str());
350 if(cleanupArgs.IsEmpty())
355 wxString ptoinfile_name = wxFileName::CreateTempFileName(
GetCheckedTempDir() + (
"ap_inproj"));
357 std::ofstream ptoinstream(ptoinfile_name.mb_str(wxConvFile));
360 int ret_value=
CPExecute(cleanupExe, cleanupArgs, _(
"cleaning up temporary keypoint files"), parent);
364 DEBUG_DEBUG(
"could not cleanup temporary keypoint files");
366 if(!wxRemoveFile(ptoinfile_name))
368 DEBUG_DEBUG(
"could not remove temporary file: " << ptoinfile_name.c_str());
374 int nFeatures,
int & ret_value, wxWindow *parent)
388 const bool detectorNeedsOtherCp = (autopanoExe.Find(
"geocpset") != wxNOT_FOUND) ||
389 (autopanoExe.Find(
"linefind") != wxNOT_FOUND && pano.
getNrOfImages()==imgs.size()) ||
390 (autopanoExe.Find(
"cpfind") != wxNOT_FOUND && setting.
GetArgs().Find(
"--prealigned") != wxNOT_FOUND);
391 size_t oldCpsSize = -1;
395 cps=
automatch(setting, pano, imgs, nFeatures, keyFiles, ret_value, parent);
396 Cleanup(setting, pano, imgs, keyFiles, parent);
399 wxString autopanoArgs = setting.
GetArgs();
402 std::set<std::string> cpsHash;
407 cpsHash.insert(cp.getCPString());
412 wxString ptofile = wxFileName::CreateTempFileName(
GetCheckedTempDir() +
"ap_res");
415 tmp.Printf(
"%d", nFeatures);
416 autopanoArgs.Replace(
"%p", tmp);
419 tmp.Printf(
"%f", firstImg.getHFOV());
420 autopanoArgs.Replace(
"%v", tmp);
422 tmp.Printf(
"%d", (
int) firstImg.getProjection());
423 autopanoArgs.Replace(
"%f", tmp);
425 long idx = autopanoArgs.Find(
"%namefile") ;
426 DEBUG_DEBUG(
"find %namefile in '"<< autopanoArgs.mb_str(wxConvLocal) <<
"' returned: " << idx);
427 bool use_namefile = idx >=0;
428 idx = autopanoArgs.Find(
"%i");
429 DEBUG_DEBUG(
"find %i in '"<< autopanoArgs.mb_str(wxConvLocal) <<
"' returned: " << idx);
430 bool use_params = idx >=0;
431 idx = autopanoArgs.Find(
"%s");
432 bool use_inputscript = idx >=0;
434 if (! (use_namefile || use_params || use_inputscript)) {
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);
441 wxString namefile_name;
444 namefile_name = wxFileName::CreateTempFileName(
GetCheckedTempDir() +
"ap_imgnames", &namefile);
445 DEBUG_DEBUG(
"before replace %namefile: " << autopanoArgs.mb_str(wxConvLocal));
447 DEBUG_DEBUG(
"after replace %namefile: " << autopanoArgs.mb_str(wxConvLocal));
448 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end(); ++it)
451 namefile.Write(
"\r\n");
454 if (namefile_name != wxString(wxEmptyString)) {
458 std::string imgFiles;
459 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end(); ++it)
466 wxString ptoinfile_name;
467 if (use_inputscript) {
469 ptoinfile_name = wxFileName::CreateTempFileName(
GetCheckedTempDir() + (
"ap_inproj"));
472 std::ofstream ptoinstream(ptoinfile_name.mb_str(wxConvFile));
475 if (detectorNeedsOtherCp)
485 tempPano.setCtrlPoints(emptyCPV);
488 fill_set(tempImgSet, 0, tempPano.getNrOfImages() - 1);
489 tempPano.printPanoramaScript(ptoinstream, tempPano.getOptimizeVector(), tempPano.getOptions(), tempImgSet,
false);
493 if (autopanoArgs.size() > 32000) {
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 );
500 wxString cmd = autopanoExe +
" " + autopanoArgs;
501 DEBUG_DEBUG(
"Executing: " << autopanoExe.mb_str(wxConvLocal) <<
" " << autopanoArgs.mb_str(wxConvLocal));
503 wxArrayString arguments = wxCmdLineParser::ConvertStringToArgs(autopanoArgs);
504 if (arguments.GetCount() > 127) {
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);
513 ret_value =
CPExecute(autopanoExe, autopanoArgs, _(
"finding control points"), parent);
517 }
else if (ret_value == -1) {
518 CPMessage( wxString::Format(_(
"Could not execute command: %s"),cmd.c_str()), _(
"wxExecute Error"), parent);
520 }
else if (ret_value > 0) {
521 CPMessage(wxString::Format(_(
"Command: %s\nfailed with error code: %d"),cmd.c_str(),ret_value),
522 _(
"wxExecute Error"), parent);
526 if (! wxFileExists(ptofile.c_str())) {
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 );
534 if (detectorNeedsOtherCp && oldCpsSize >= 0)
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);
553 if (namefile_name != wxString(wxEmptyString)) {
555 wxRemoveFile(namefile_name);
558 if (ptoinfile_name != wxString(wxEmptyString)) {
559 wxRemoveFile(ptoinfile_name);
562 if (!wxRemoveFile(ptofile)) {
563 DEBUG_DEBUG(
"could not remove temporary file: " << ptofile.c_str());
570 int nFeatures, std::vector<wxString> &keyFiles,
int & ret_value, wxWindow *parent)
581 wxString generateKeysArgs=setting.
GetArgs();
585 if(generateKeysArgs.Find(
"%i")==wxNOT_FOUND || generateKeysArgs.Find(
"%k")==wxNOT_FOUND)
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);
591 if(matcherArgs.Find(
"%k")==wxNOT_FOUND || matcherArgs.Find(
"%o")==wxNOT_FOUND)
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)
602 if(keyFiles[*img].IsEmpty())
605 wxString keyfile=wxFileName::CreateTempFileName(tempDir+
"apk_");
606 keyFiles[*img]=keyfile;
607 wxString cmd=generateKeysArgs;
609 tmp.Printf(
"%d", nFeatures);
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);
622 ret_value =
CPExecute(generateKeysExe, cmd, _(
"generating key file"), parent);
623 cmd=generateKeysExe+
" "+cmd;
629 CPMessage( wxString::Format(_(
"Could not execute command: %s"),cmd.c_str()), _(
"wxExecute Error"), parent);
635 CPMessage(wxString::Format(_(
"Command: %s\nfailed with error code: %d"),cmd.c_str(),ret_value),
636 _(
"wxExecute Error"), parent);
643 wxString ptofile = wxFileName::CreateTempFileName(
GetCheckedTempDir() +
"ap_res");
646 tmp.Printf(
"%d", nFeatures);
647 matcherArgs.Replace(
"%p", tmp);
650 tmp.Printf(
"%f", firstImg.getHFOV());
651 matcherArgs.Replace(
"%v", tmp);
653 tmp.Printf(
"%d", (
int) firstImg.getProjection());
654 matcherArgs.Replace(
"%f", tmp);
657 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end(); ++it)
664 if (matcherArgs.size() > 32000) {
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 );
671 wxString cmd = matcherExe +
" " + matcherArgs;
672 DEBUG_DEBUG(
"Executing: " << matcherExe.mb_str(wxConvLocal) <<
" " << matcherArgs.mb_str(wxConvLocal));
674 wxArrayString arguments = wxCmdLineParser::ConvertStringToArgs(matcherArgs);
675 if (arguments.GetCount() > 127) {
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);
682 ret_value =
CPExecute(matcherExe, matcherArgs, _(
"finding control points"), parent);
689 CPMessage( wxString::Format(_(
"Could not execute command: %s"),cmd.c_str()), _(
"wxExecute Error"), parent);
695 CPMessage(wxString::Format(_(
"Command: %s\nfailed with error code: %d"),cmd.c_str(),ret_value),
696 _(
"wxExecute Error"), parent);
700 if (! wxFileExists(ptofile.c_str()))
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 );
710 if (!wxRemoveFile(ptofile)) {
711 DEBUG_DEBUG(
"could not remove temporary file: " << ptofile.c_str());
718 int nFeatures,
int & ret_value, wxWindow *parent)
721 wxString autopanoExe = setting.
GetProg();
724 wxString autopanoArgs = setting.
GetArgs();
726 std::string imgFiles;
727 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end(); ++it)
732 wxString ptofilepath = wxFileName::CreateTempFileName(
GetCheckedTempDir() +
"ap_res");
733 wxFileName ptofn(ptofilepath);
734 wxString ptofile = ptofn.GetFullName();
737 tmp.Printf(
"%d", nFeatures);
738 autopanoArgs.Replace(
"%p", tmp);
740 tmp.Printf(
"%f", firstImg.getHFOV());
741 autopanoArgs.Replace(
"%v", tmp);
743 tmp.Printf(
"%d", (
int) firstImg.getProjection());
744 autopanoArgs.Replace(
"%f", tmp);
748 wxString tempdir = ptofn.GetPath();
749 autopanoArgs.Replace(
"%d", ptofn.GetPath());
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);
761 wxArrayString arguments = wxCmdLineParser::ConvertStringToArgs(cmd);
762 if (arguments.GetCount() > 127) {
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);
771 ret_value =
CPExecute(autopanoExe, autopanoArgs, _(
"finding control points"), parent);
775 }
else if (ret_value == -1) {
776 CPMessage( wxString::Format(_(
"Could not execute command: %s"),cmd.c_str()), _(
"wxExecute Error"), parent);
778 }
else if (ret_value > 0) {
779 CPMessage(wxString::Format(_(
"Command: %s\nfailed with error code: %d"),cmd.c_str(),ret_value),
780 _(
"wxExecute Error"), parent);
784 ptofile = ptofn.GetFullPath();
785 ptofile.append(
"0.oto");
786 if (! wxFileExists(ptofile.c_str()) ) {
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 );
794 if (!wxRemoveFile(ptofile)) {
795 DEBUG_DEBUG(
"could not remove temporary file: " << ptofile.c_str());
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);
836 int nFeatures,
int & ret_value, wxWindow *parent)
842 std::vector<stack_img> stack_images;
844 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end(); ++it)
849 unsigned int index=0;
850 for(index=0;index<stack_images.size();index++)
852 found=(stack_images[index].layer_nr==stack_nr);
859 stack_images.resize(stack_images.size()+1);
860 index=stack_images.size()-1;
862 stack_images[index].layer_nr=stack_nr;
865 unsigned int new_image_index=stack_images[index].images.size();
866 stack_images[index].images.resize(new_image_index+1);
867 stack_images[index].images[new_image_index].img_nr=*it;
870 delete variable_groups;
873 for(
unsigned int i=0;i<stack_images.size();i++)
875 std::sort(stack_images[i].images.begin(),stack_images[i].images.end(),
sort_img_ev);
876 unsigned int index=0;
877 if(stack_images[i].images[0].ev!=stack_images[i].images[stack_images[i].images.size()-1].ev)
879 index=stack_images[i].images.size() / 2;
881 images_layer.insert(stack_images[i].images[index].img_nr);
885 if(images_layer.size()>1)
888 cps=matcher.
automatch(setting, pano, images_layer, nFeatures, ret_value, parent);
900 for(
unsigned int i=0;i<stack_images.size();i++)
903 images_stack.clear();
904 for(
unsigned int j=0;j<stack_images[i].images.size();j++)
905 images_stack.insert(stack_images[i].images[j].img_nr);
906 if(images_stack.size()>1)
921 int nFeatures,
int & ret_value, wxWindow *parent)
930 unsigned int counter=0;
931 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end();)
933 if(counter==imgs.size()-1)
938 ImagePair.insert(*it);
940 ImagePair.insert(*it);
945 new_cps=matcher.
automatch(setting, pano, ImagePair, nFeatures, keyFiles, ret_value, parent);
947 new_cps=matcher.
automatch(setting, pano, ImagePair, nFeatures, ret_value, parent);
952 Cleanup(setting, pano, imgs, keyFiles, parent);
961 for (HuginBase::CPVector::const_iterator it = cps.begin(); it != cps.end(); ++it)
966 size_t n = comps.size();
970 for(
size_t i=0;i<n;i++)
972 ImagesGroups.insert(*(comps[i].begin()));
973 if(comps[i].size()>1)
974 ImagesGroups.insert(*(comps[i].rbegin()));
979 new_cps=matcher.
automatch(setting, optPano, ImagesGroups, nFeatures, keyFiles, ret_value, parent);
981 new_cps=matcher.
automatch(setting, optPano, ImagesGroups, nFeatures, ret_value, parent);
986 Cleanup(setting, pano, imgs, keyFiles, parent);
1003 optPano.setOptions(opts);
1008 optPano.setOptions(opts);
1013 for (
unsigned i=0; i < optPano.getNrOfImages(); i++)
1015 std::set<std::string> imgopt;
1024 if(!optPano.getImage(i).YawisLinkedWith(anchorImage))
1030 optvars.push_back(imgopt);
1032 optPano.setOptimizeVector(optvars);
1037 for (HuginBase::CPVector::const_iterator it = backupOldCPS.begin(); it != backupOldCPS.end(); ++it) {
1040 backupNewCPS.push_back(*it);
1043 optPano.setCtrlPoints(backupNewCPS);
1047 optPano.setCtrlPoints(backupOldCPS);
1062 new_cps=matcher.
automatch(newSetting, optPano, imgs, nFeatures, keyFiles, ret_value, parent);
1064 new_cps=matcher.
automatch(newSetting, optPano, imgs, nFeatures, ret_value, parent);
1065 if(!new_cps.empty())
1068 Cleanup(setting, pano, imgs, keyFiles, parent);
1073 int nFeatures,
int & ret_value, wxWindow *parent)
1079 std::vector<stack_img> stack_images;
1081 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end(); ++it)
1086 unsigned int index=0;
1087 for(index=0;index<stack_images.size();index++)
1089 found=(stack_images[index].layer_nr==stack_nr);
1096 stack_images.resize(stack_images.size()+1);
1097 index=stack_images.size()-1;
1099 stack_images[index].layer_nr=stack_nr;
1102 unsigned int new_image_index=stack_images[index].images.size();
1103 stack_images[index].images.resize(new_image_index+1);
1104 stack_images[index].images[new_image_index].img_nr=*it;
1107 delete variable_groups;
1110 for(
unsigned int i=0;i<stack_images.size();i++)
1112 std::sort(stack_images[i].images.begin(),stack_images[i].images.end(),
sort_img_ev);
1113 unsigned int index=0;
1114 if(stack_images[i].images[0].ev!=stack_images[i].images[stack_images[i].images.size()-1].ev)
1116 index=stack_images[i].images.size() / 2;
1118 images_layer.insert(stack_images[i].images[index].img_nr);
1129 for(
unsigned int i=0;i<stack_images.size();i++)
1132 images_stack.clear();
1133 for(
unsigned int j=0;j<stack_images[i].images.size();j++)
1134 images_stack.insert(stack_images[i].images[j].img_nr);
1135 if(images_stack.size()>1)
1139 if(!new_cps.empty())
1143 std::vector<wxString> emptyKeyfiles;
1144 Cleanup(setting, pano, imgs, emptyKeyfiles, parent);
1151 if(images_layer.size()>1)
1157 for (HuginBase::CPVector::const_iterator it = cps.begin(); it != cps.end(); ++it)
1162 if(!new_cps.empty())
1169 int nFeatures,
int & ret_value, wxWindow *parent)
1172 return automatch(setting, pano, imgs, nFeatures, keyFiles, ret_value, parent);
1176 int nFeatures, std::vector<wxString> &keyFiles,
int & ret_value, wxWindow *parent)
1183 std::vector<HuginBase::UIntSet> usedImages;
1189 for(
unsigned i=0;i<oldCps.size();i++)
1193 usedImages[oldCps[i].image1Nr].insert(oldCps[i].image2Nr);
1194 usedImages[oldCps[i].image2Nr].insert(oldCps[i].image1Nr);
1200 for (HuginBase::UIntSet::const_iterator it = imgs.begin(); it != imgs.end(); ++it)
1205 HuginBase::UIntSet::const_iterator it2 = it;
1206 for(++it2;it2!=imgs.end();++it2)
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)
1222 usedImages[*img_it].insert(*img_it2);
1226 new_cps=matcher.
automatch(setting, pano, images, nFeatures, keyFiles, ret_value, parent);
1228 new_cps=matcher.
automatch(setting, pano, images, nFeatures, ret_value, parent);
1229 if(!new_cps.empty())
1233 Cleanup(setting, pano, imgs, keyFiles, parent);
1237 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
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)
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...