pto_var.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00002 
00011 /*  This program is free software; you can redistribute it and/or
00012  *  modify it under the terms of the GNU General Public
00013  *  License as published by the Free Software Foundation; either
00014  *  version 2 of the License, or (at your option) any later version.
00015  *
00016  *  This software is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  *  General Public License for more details.
00020  *
00021  *  You should have received a copy of the GNU General Public
00022  *  License along with this software. If not, see
00023  *  <http://www.gnu.org/licenses/>.
00024  *
00025  */
00026 
00027 #include <fstream>
00028 #include <sstream>
00029 #include <getopt.h>
00030 #ifndef _WIN32
00031 #include <unistd.h>
00032 #endif
00033 #include <panodata/Panorama.h>
00034 #include <panodata/ImageVariableTranslate.h>
00035 #include <panodata/ImageVariableGroup.h>
00036 #include <panodata/StandardImageVariableGroups.h>
00037 #include "hugin_utils/utils.h"
00038 #include "ParseExp.h"
00039 
00040 struct ParseVar
00041 {
00042     std::string varname;
00043     int imgNr;
00044     std::string expression;
00045     bool removeOpt;
00046     ParseVar(): varname(""), imgNr(-1), expression(""), removeOpt(false) {};
00047 };
00048 
00049 typedef std::vector<ParseVar> ParseVarVec;
00050 
00051 bool ParseVarNumber(const std::string&s, ParseVar& var)
00052 {
00053     std::size_t pos = s.find_first_of("0123456789");
00054     std::string varName;
00055     if (pos == std::string::npos)
00056     {
00057         varName = s;
00058         var.imgNr = -1;
00059     }
00060     else
00061     {
00062         if (pos == 0)
00063         {
00064             return false;
00065         };
00066         varName = s.substr(0, pos);
00067         if (!hugin_utils::stringToInt(s.substr(pos, s.length() - pos), var.imgNr))
00068         {
00069             return false;
00070         };
00071     }
00072 #define image_variable( name, type, default_value ) \
00073     if (HuginBase::PTOVariableConverterFor##name::checkApplicability(varName))\
00074     {\
00075         var.varname=varName;\
00076         return true;\
00077     };
00078 #include "panodata/image_variables.h"
00079 #undef image_variable
00080     return false;
00081 };
00082 
00083 // parse a single variable and put result in struct ParseVar
00084 void ParseSingleOptVar(ParseVarVec& varVec, const std::string& s)
00085 {
00086     // parse following regex ([!]?)([a-zA-Z]{1,3})(\\d*?) 
00087     std::string tempString(s);
00088     ParseVar var;
00089     var.removeOpt = (tempString[0] == '!');
00090     if (var.removeOpt)
00091     {
00092         tempString.erase(0, 1);
00093     };
00094     if (ParseVarNumber(tempString, var))
00095     {
00096         varVec.push_back(var);
00097     };
00098 };
00099 
00100 void ParseSingleLinkVar(ParseVarVec& varVec, const std::string& s)
00101 {
00102     // parse following regex ([a-zA-Z]{1,3})(\\d+?)
00103     ParseVar var;
00104     if (ParseVarNumber(s, var))
00105     {
00106         varVec.push_back(var);
00107     };
00108 };
00109 
00110 void ParseSingleVar(ParseVarVec& varVec, const std::string& s)
00111 {
00112     // parse following regex ([a-zA-Z]{1,3})(\\d*?)=(.*)
00113     const std::size_t pos = s.find_first_of("=", 0);
00114     if (pos != std::string::npos && pos > 0 && pos < s.length() - 1)
00115     {
00116         ParseVar var;
00117         const std::string tempString(s.substr(0, pos));
00118         if (ParseVarNumber(tempString, var))
00119         {
00120             var.expression = s.substr(pos + 1, s.length() - pos - 1);
00121             varVec.push_back(var);
00122         };
00123     };
00124 };
00125 
00126 //parse complete variables string
00127 void ParseVariableString(ParseVarVec& parseVec, const std::string& input, void (*func)(ParseVarVec&, const std::string&))
00128 {
00129     std::vector<std::string> splitResult = hugin_utils::SplitString(input, ", ");
00130     for(size_t i=0; i<splitResult.size(); i++)
00131     {
00132         (*func)(parseVec, splitResult[i]);
00133     };
00134 };
00135 
00136 // adds given varname to optVec
00137 // does some additional checking:
00138 //   1. don't add y,p,r for anchor image
00139 //   2. handle vignetting and EMoR parameters as group
00140 void AddToOptVec(HuginBase::OptimizeVector& optVec, std::string varname, size_t imgNr,
00141                  std::set<size_t> refImgs, bool linkRefImgsYaw, bool linkRefImgsPitch, bool linkRefImgsRoll, std::vector<std::set<std::string> > groupedVars)
00142 {
00143     if(varname=="y")
00144     {
00145         if(!set_contains(refImgs, imgNr) || linkRefImgsYaw)
00146         {
00147             optVec[imgNr].insert(varname);
00148         };
00149     }
00150     else
00151     {
00152         if(varname=="p")
00153         {
00154             if(!set_contains(refImgs, imgNr) || linkRefImgsPitch)
00155             {
00156                 optVec[imgNr].insert(varname);
00157             };
00158         }
00159         else
00160         {
00161             if(varname=="r")
00162             {
00163                 if(!set_contains(refImgs, imgNr) || linkRefImgsRoll)
00164                 {
00165                     optVec[imgNr].insert(varname);
00166                 };
00167             }
00168             else
00169             {
00170                 if(varname=="TrX" || varname=="TrY" || varname=="TrZ" || varname=="Tpy" || varname=="Tpp")
00171                 {
00172                     if(!set_contains(refImgs, imgNr))
00173                     {
00174                         optVec[imgNr].insert(varname);
00175                     };
00176                 }
00177                 else
00178                 {
00179                     for(size_t i=0; i<groupedVars.size(); i++)
00180                     {
00181                         if(set_contains(groupedVars[i], varname))
00182                         {
00183                             for(std::set<std::string>::const_iterator it=groupedVars[i].begin(); it!=groupedVars[i].end(); ++it)
00184                             {
00185                                 optVec[imgNr].insert(*it);
00186                             };
00187                             return;
00188                         };
00189                     };
00190                     optVec[imgNr].insert(varname);
00191                 };
00192             };
00193         };
00194     };
00195 };
00196 
00197 // remove given variable from optvec, handle also correct grouped variables
00198 void RemoveFromOptVec(HuginBase::OptimizeVector& optVec, std::string varname, size_t imgNr, std::vector<std::set<std::string> > groupedVars)
00199 {
00200     for(size_t i=0; i<groupedVars.size(); i++)
00201     {
00202         if(set_contains(groupedVars[i], varname))
00203         {
00204             for(std::set<std::string>::const_iterator it=groupedVars[i].begin(); it!=groupedVars[i].end(); ++it)
00205             {
00206                 optVec[imgNr].erase(*it);
00207             };
00208             return;
00209         };
00210     };
00211     optVec[imgNr].erase(varname);
00212 };
00213 
00214 // link or unlink the parsed image variables
00215 void UnLinkVars(HuginBase::Panorama& pano, ParseVarVec parseVec, bool link)
00216 {
00217     for(size_t i=0; i<parseVec.size(); i++)
00218     {
00219         //skip invalid image numbers
00220         if(parseVec[i].imgNr<0 || parseVec[i].imgNr>=(int)pano.getNrOfImages())
00221         {
00222             continue;
00223         };
00224 
00225         //convert to ImageVariableGroup::IVE_name format
00226         std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> variables;
00227 #define image_variable( name, type, default_value ) \
00228     if (HuginBase::PTOVariableConverterFor##name::checkApplicability(parseVec[i].varname))\
00229     {\
00230         variables.insert(HuginBase::ImageVariableGroup::IVE_##name);\
00231     };
00232 #include "panodata/image_variables.h"
00233 #undef image_variable
00234 
00235         if(!variables.empty())
00236         {
00237             //lens variable
00238             if(set_contains(HuginBase::StandardImageVariableGroups::getLensVariables(), *variables.begin()))
00239             {
00240                 HuginBase::ImageVariableGroup group(HuginBase::StandardImageVariableGroups::getLensVariables(), pano);
00241                 if (link)
00242                 {
00243                     group.linkVariableImage(*variables.begin(), parseVec[i].imgNr);
00244                 }
00245                 else
00246                 {
00247                     group.unlinkVariableImage(*variables.begin(), parseVec[i].imgNr);
00248                     group.updatePartNumbers();
00249                 }
00250             }
00251             else
00252             {
00253                 //stack variables
00254                 // handle yaw, pitch, roll, TrX, TrY and TrZ always together
00255                 if(set_contains(HuginBase::StandardImageVariableGroups::getStackVariables(), *variables.begin()))
00256                 {
00257                     HuginBase::ImageVariableGroup group(HuginBase::StandardImageVariableGroups::getStackVariables(), pano);
00258                     if (link)
00259                     {
00260                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_Yaw, parseVec[i].imgNr);
00261                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_Pitch, parseVec[i].imgNr);
00262                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_Roll, parseVec[i].imgNr);
00263                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_X, parseVec[i].imgNr);
00264                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_Y, parseVec[i].imgNr);
00265                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_Z, parseVec[i].imgNr);
00266                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_TranslationPlaneYaw, parseVec[i].imgNr);
00267                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_TranslationPlanePitch, parseVec[i].imgNr);
00268                     }
00269                     else
00270                     {
00271                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_Yaw, parseVec[i].imgNr);
00272                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_Pitch, parseVec[i].imgNr);
00273                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_Roll, parseVec[i].imgNr);
00274                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_X, parseVec[i].imgNr);
00275                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_Y, parseVec[i].imgNr);
00276                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_Z, parseVec[i].imgNr);
00277                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_TranslationPlaneYaw, parseVec[i].imgNr);
00278                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_TranslationPlanePitch, parseVec[i].imgNr);
00279                         group.updatePartNumbers();
00280                     }
00281                 }
00282                 else
00283                 {
00284                     std::cerr << "Warning: " << parseVec[i].varname << " is not a valid linkable variable." << std::endl;
00285                 };
00286             };
00287         };
00288     };
00289 };
00290 
00291 bool UpdateSingleVar(HuginBase::Panorama& pano, ParseVar parseVar, size_t imgNr)
00292 {
00293     double val=pano.getImage(imgNr).getVar(parseVar.varname);
00294     Parser::ConstantMap constMap;
00295     constMap["i"]=1.0*imgNr;
00296     constMap["val"]=val;
00297     std::cout << "Updating variable " << parseVar.varname << imgNr << ": " << val;
00298     if(Parser::ParseExpression(parseVar.expression, val, constMap))
00299     {
00300         std::cout << " -> " << val << std::endl;
00301         HuginBase::Variable var(parseVar.varname, val);
00302         pano.updateVariable(imgNr, var);
00303         return true;
00304     }
00305     else
00306     {
00307         std::cout << std::endl;
00308         std::cerr << "Could not parse given expression \"" << parseVar.expression << "\" for image " << imgNr << "." << std::endl;
00309         return false;
00310     };
00311 };
00312 
00313 static void usage(const char* name)
00314 {
00315     std::cout << name << ": change image variables inside pto files" << std::endl
00316          << name << " version " << hugin_utils::GetHuginVersion() << std::endl
00317          << std::endl
00318          << "Usage:  " << name << " [options] --opt|--link|--unlink|--set varlist input.pto" << std::endl
00319          << std::endl
00320          << "     -o, --output=file.pto  Output Hugin PTO file. Default: <filename>_var.pto" << std::endl
00321          << "     -h, --help             Shows this help" << std::endl
00322          << std::endl
00323          << "     --opt varlist          Change optimizer variables" << std::endl
00324          << "     --modify-opt           Modify the existing optimizer variables" << std::endl
00325          << "                            (without pto_var will start with an" << std::endl
00326          << "                             empty variables set)" << std::endl
00327          << "                            Examples:" << std::endl
00328          << "           --opt=y,p,r        Optimize yaw, pitch and roll of all images" << std::endl
00329          << "                              (special treatment for anchor image applies)" << std::endl
00330          << "           --opt=v0,b2        Optimize hfov of image 0 and barrel distortion" << std::endl
00331          << "                              of image 2" << std::endl
00332          << "           --opt=v,!v0        Optimize field of view for all images except" << std::endl
00333          << "                              for the first image" << std::endl
00334          << "           --opt=!a,!b,!c     Don't optimise distortion (works only with" << std::endl
00335          << "                              switch --modify-opt together)" << std::endl
00336          << std::endl
00337          << "     --link varlist         Link given variables" << std::endl
00338          << "                            Example:" << std::endl
00339          << "           --link=v3          Link hfov of image 3" << std::endl
00340          << "           --link=a1,b1,c1    Link distortions parameter for image 1" << std::endl
00341          << std::endl
00342          << "     --unlink varlist       Unlink given variables" << std::endl
00343          << "                            Examples:" << std::endl
00344          << "           --unlink=v5        Unlink hfov for image 5" << std::endl
00345          << "           --unlink=a2,b2,c2  Unlink distortions parameters for image 2" << std::endl
00346          << std::endl
00347          << "     --set varlist          Sets variables to new values" << std::endl
00348          << "                            Examples:" << std::endl
00349          << "           --set=y0=0,r0=0,p0=0  Resets position of image 0" << std::endl
00350          << "           --set=Vx4=-10,Vy4=10  Sets vignetting offset for image 4" << std::endl
00351          << "           --set=v=20            Sets the field of view to 20 for all images" << std::endl
00352          << "           --set=y=val+20        Increase yaw by 20 deg for all images" << std::endl
00353          << "           --set=v=val*1.1       Increase fov by 10 % for all images" << std::endl
00354          << "           --set=y=i*20          Set yaw to 0, 20, 40, ..." << std::endl
00355          << "     --set-from-file filename  Sets variables to new values" << std::endl
00356          << "                               It reads the varlist from a file" << std::endl
00357          << std::endl;
00358 }
00359 
00360 int main(int argc, char* argv[])
00361 {
00362     // parse arguments
00363     const char* optstring = "o:h";
00364 
00365     enum
00366     {
00367         SWITCH_OPT=1000,
00368         SWITCH_LINK,
00369         SWITCH_UNLINK,
00370         SWITCH_SET,
00371         SWITCH_SET_FILE,
00372         OPT_MODIFY_OPTVEC
00373     };
00374     static struct option longOptions[] =
00375     {
00376         {"output", required_argument, NULL, 'o' },
00377         {"opt", required_argument, NULL, SWITCH_OPT },
00378         {"link", required_argument, NULL, SWITCH_LINK },
00379         {"unlink", required_argument, NULL, SWITCH_UNLINK },
00380         {"set", required_argument, NULL, SWITCH_SET },
00381         {"set-from-file", required_argument, NULL, SWITCH_SET_FILE },
00382         {"modify-opt", no_argument, NULL, OPT_MODIFY_OPTVEC },
00383         {"help", no_argument, NULL, 'h' },
00384         0
00385     };
00386 
00387     ParseVarVec optVars;
00388     ParseVarVec linkVars;
00389     ParseVarVec unlinkVars;
00390     ParseVarVec setVars;
00391     bool modifyOptVec=false;
00392     int c;
00393     int optionIndex = 0;
00394     std::string output;
00395     while ((c = getopt_long (argc, argv, optstring, longOptions,&optionIndex)) != -1)
00396     {
00397         switch (c)
00398         {
00399             case 'o':
00400                 output = optarg;
00401                 break;
00402             case 'h':
00403                 usage(hugin_utils::stripPath(argv[0]).c_str());
00404                 return 0;
00405             case SWITCH_OPT:
00406                 ParseVariableString(optVars, std::string(optarg), ParseSingleOptVar);
00407                 break;
00408             case SWITCH_LINK:
00409                 ParseVariableString(linkVars, std::string(optarg), ParseSingleLinkVar);
00410                 break;
00411             case SWITCH_UNLINK:
00412                 ParseVariableString(unlinkVars, std::string(optarg), ParseSingleLinkVar);
00413                 break;
00414             case SWITCH_SET:
00415                 ParseVariableString(setVars, std::string(optarg), ParseSingleVar);
00416                 break;
00417             case SWITCH_SET_FILE:
00418                 {
00419                     std::ifstream ifs(optarg);
00420                     if(ifs.is_open())
00421                     {
00422                         std::ostringstream contents;
00423                         contents << ifs.rdbuf();
00424                         ifs.close();
00425                         std::string s(contents.str());
00426                         hugin_utils::ReplaceAll(s, "\n", ',');
00427                         ParseVariableString(setVars, s, ParseSingleVar);
00428                     }
00429                     else
00430                     {
00431                         std::cerr << "Could not open file " << optarg << std::endl;
00432                     };
00433                 };
00434                 break;
00435             case OPT_MODIFY_OPTVEC:
00436                 modifyOptVec=true;
00437                 break;
00438             case ':':
00439                 std::cerr <<"Option " << longOptions[optionIndex].name << " requires a parameter." << std::endl;
00440                 return 1;
00441                 break;
00442             case '?':
00443                 break;
00444             default:
00445                 abort ();
00446         }
00447     }
00448 
00449     if (argc - optind == 0)
00450     {
00451         std::cerr << "Error: " << argv[0] << " needs at least one project file." << std::endl;
00452         return 1;
00453     };
00454     if (argc - optind != 1)
00455     {
00456         std::cout << "Error: " << argv[0] << " can only work on one project file at one time" << std::endl;
00457         return 1;
00458     };
00459 
00460     if(optVars.size() + linkVars.size() + unlinkVars.size() + setVars.size()==0)
00461     {
00462         std::cerr << "Error: no variables to modify given" << std::endl;
00463         return 1;
00464     };
00465 
00466     std::string input=argv[optind];
00467     // read panorama
00468     HuginBase::Panorama pano;
00469     std::ifstream prjfile(input.c_str());
00470     if (!prjfile.good())
00471     {
00472         std::cerr << "could not open script : " << input << std::endl;
00473         return 1;
00474     }
00475     pano.setFilePrefix(hugin_utils::getPathPrefix(input));
00476     AppBase::DocumentData::ReadWriteError err = pano.readData(prjfile);
00477     if (err != AppBase::DocumentData::SUCCESSFUL)
00478     {
00479         std::cerr << "error while parsing panos tool script: " << input << std::endl;
00480         std::cerr << "AppBase::DocumentData::ReadWriteError code: " << err << std::endl;
00481         return 1;
00482     }
00483 
00484     if(pano.getNrOfImages()==0)
00485     {
00486         std::cerr << "error: project file does not contains any image" << std::endl;
00487         std::cerr << "aborting processing" << std::endl;
00488         return 1;
00489     };
00490 
00491     //link/unlink variables
00492     if(linkVars.size()>0)
00493     {
00494         UnLinkVars(pano, linkVars, true);
00495     };
00496 
00497     if(unlinkVars.size()>0)
00498     {
00499         UnLinkVars(pano, unlinkVars, false);
00500     };
00501 
00502     // set variables to new value
00503     if(setVars.size()>0)
00504     {
00505         for(size_t i=0; i<setVars.size(); i++)
00506         {
00507             //skip invalid image numbers
00508             if(setVars[i].imgNr>=(int)pano.getNrOfImages())
00509             {
00510                 continue;
00511             };
00512             if(setVars[i].imgNr<0)
00513             {
00514                 HuginBase::UIntSet updatedImgs;
00515                 for(size_t j=0; j<pano.getNrOfImages(); j++)
00516                 {
00517                     //if we already update the variable in this image via links, skip it
00518                     if(set_contains(updatedImgs, j))
00519                     {
00520                         continue;
00521                     };
00522                     // skip following images, if expression could not parsed
00523                     if(!UpdateSingleVar(pano, setVars[i], j))
00524                     {
00525                         break;
00526                     };
00527                     updatedImgs.insert(j);
00528                     if(j==pano.getNrOfImages()-1)
00529                     {
00530                         break;
00531                     };
00532                     // now remember linked variables
00533                     const HuginBase::SrcPanoImage& img1=pano.getImage(j);
00534 #define image_variable( name, type, default_value ) \
00535     if (HuginBase::PTOVariableConverterFor##name::checkApplicability(setVars[i].varname))\
00536     {\
00537         if(img1.name##isLinked())\
00538         {\
00539             for(size_t k=j+1; k<pano.getNrOfImages(); k++)\
00540             {\
00541                 if(img1.name##isLinkedWith(pano.getImage(k)))\
00542                 {\
00543                     updatedImgs.insert(k);\
00544                 }\
00545             };\
00546         };\
00547     };
00548 #include "panodata/image_variables.h"
00549 #undef image_variable
00550                 };
00551             }
00552             else
00553             {
00554                 UpdateSingleVar(pano, setVars[i], setVars[i].imgNr);
00555             };
00556         };
00557         Parser::CleanUpParser();
00558     };
00559 
00560     // update optimzer vector
00561     if(optVars.size()>0)
00562     {
00563         std::set<size_t> refImgs=pano.getRefImages();
00564         bool linkRefImgsYaw=false;
00565         bool linkRefImgsPitch=false;
00566         bool linkRefImgsRoll=false;
00567         pano.checkRefOptStatus(linkRefImgsYaw, linkRefImgsPitch, linkRefImgsRoll);
00568 
00569         //simplify handling of variable groups
00570         std::vector<std::set<std::string> > groupedVars;
00571         std::set<std::string> varSet;
00572         varSet.insert("Vb");
00573         varSet.insert("Vc");
00574         varSet.insert("Vd");
00575         groupedVars.push_back(varSet);
00576         varSet.clear();
00577         varSet.insert("Vx");
00578         varSet.insert("Vy");
00579         groupedVars.push_back(varSet);
00580         varSet.clear();
00581         varSet.insert("Ra");
00582         varSet.insert("Rb");
00583         varSet.insert("Rc");
00584         varSet.insert("Rd");
00585         varSet.insert("Re");
00586         groupedVars.push_back(varSet);
00587 
00588         HuginBase::OptimizeVector optVec;
00589         if(modifyOptVec)
00590         {
00591             optVec=pano.getOptimizeVector();
00592         };
00593         if(optVec.size()!=pano.getNrOfImages())
00594         {
00595             optVec.resize(pano.getNrOfImages());
00596         };
00597         for(size_t i=0; i<optVars.size(); i++)
00598         {
00599             //skip invalid image numbers
00600             if(optVars[i].imgNr>=(int)pano.getNrOfImages())
00601             {
00602                 continue;
00603             };
00604             if(optVars[i].imgNr==-1)
00605             {
00606                 for(size_t imgNr=0; imgNr<pano.getNrOfImages(); imgNr++)
00607                 {
00608                     if(optVars[i].removeOpt)
00609                     {
00610                         RemoveFromOptVec(optVec, optVars[i].varname, imgNr, groupedVars);
00611                     }
00612                     else
00613                     {
00614                         AddToOptVec(optVec, optVars[i].varname, imgNr, refImgs, linkRefImgsYaw, linkRefImgsPitch, linkRefImgsRoll, groupedVars);
00615                     };
00616                 };
00617             }
00618             else
00619             {
00620                 if(optVars[i].removeOpt)
00621                 {
00622                     RemoveFromOptVec(optVec, optVars[i].varname, optVars[i].imgNr, groupedVars);
00623                 }
00624                 else
00625                 {
00626                     AddToOptVec(optVec, optVars[i].varname, optVars[i].imgNr, refImgs, true, true, true, groupedVars);
00627                 };
00628             };
00629         };
00630         pano.setOptimizerSwitch(0);
00631         pano.setPhotometricOptimizerSwitch(0);
00632         pano.setOptimizeVector(optVec);
00633     };
00634 
00635     //write output
00636     HuginBase::UIntSet imgs;
00637     fill_set(imgs,0, pano.getNrOfImages()-1);
00638     // Set output .pto filename if not given
00639     if (output=="")
00640     {
00641         output=input.substr(0,input.length()-4).append("_var.pto");
00642     }
00643     std::ofstream of(output.c_str());
00644     pano.printPanoramaScript(of, pano.getOptimizeVector(), pano.getOptions(), imgs, false, hugin_utils::getPathPrefix(input));
00645     std::cout << std::endl << "Written output to " << output << std::endl;
00646     return 0;
00647 }

Generated on 23 Jul 2016 for Hugintrunk by  doxygen 1.4.7