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 #include <panodata/Panorama.h>
00031 #include <panodata/ImageVariableTranslate.h>
00032 #include <panodata/ImageVariableGroup.h>
00033 #include <panodata/StandardImageVariableGroups.h>
00034 #include "hugin_utils/utils.h"
00035 #include "ParseExp.h"
00036 
00037 struct ParseVar
00038 {
00039     std::string varname;
00040     int imgNr;
00041     std::string expression;
00042     bool removeOpt;
00043     ParseVar(): varname(""), imgNr(-1), expression(""), removeOpt(false) {};
00044 };
00045 
00046 typedef std::vector<ParseVar> ParseVarVec;
00047 
00048 bool ParseVarNumber(const std::string&s, ParseVar& var)
00049 {
00050     std::size_t pos = s.find_first_of("0123456789");
00051     std::string varName;
00052     if (pos == std::string::npos)
00053     {
00054         varName = s;
00055         var.imgNr = -1;
00056     }
00057     else
00058     {
00059         if (pos == 0)
00060         {
00061             return false;
00062         };
00063         varName = s.substr(0, pos);
00064         if (!hugin_utils::stringToInt(s.substr(pos, s.length() - pos), var.imgNr))
00065         {
00066             return false;
00067         };
00068     }
00069 #define image_variable( name, type, default_value ) \
00070     if (HuginBase::PTOVariableConverterFor##name::checkApplicability(varName))\
00071     {\
00072         var.varname=varName;\
00073         return true;\
00074     };
00075 #include "panodata/image_variables.h"
00076 #undef image_variable
00077     return false;
00078 };
00079 
00080 // parse a single variable and put result in struct ParseVar
00081 void ParseSingleOptVar(ParseVarVec& varVec, const std::string& s)
00082 {
00083     // parse following regex ([!]?)([a-zA-Z]{1,3})(\\d*?) 
00084     std::string tempString(s);
00085     ParseVar var;
00086     var.removeOpt = (tempString[0] == '!');
00087     if (var.removeOpt)
00088     {
00089         tempString.erase(0, 1);
00090     };
00091     if (ParseVarNumber(tempString, var))
00092     {
00093         varVec.push_back(var);
00094     };
00095 };
00096 
00097 void ParseSingleLinkVar(ParseVarVec& varVec, const std::string& s)
00098 {
00099     // parse following regex ([a-zA-Z]{1,3})(\\d+?)
00100     ParseVar var;
00101     if (ParseVarNumber(s, var))
00102     {
00103         varVec.push_back(var);
00104     };
00105 };
00106 
00107 void ParseSingleVar(ParseVarVec& varVec, const std::string& s)
00108 {
00109     // parse following regex ([a-zA-Z]{1,3})(\\d*?)=(.*)
00110     const std::size_t pos = s.find_first_of("=", 0);
00111     if (pos != std::string::npos && pos > 0 && pos < s.length() - 1)
00112     {
00113         ParseVar var;
00114         const std::string tempString(s.substr(0, pos));
00115         if (ParseVarNumber(tempString, var))
00116         {
00117             var.expression = s.substr(pos + 1, s.length() - pos - 1);
00118             varVec.push_back(var);
00119         };
00120     };
00121 };
00122 
00123 //parse complete variables string
00124 void ParseVariableString(ParseVarVec& parseVec, const std::string& input, void (*func)(ParseVarVec&, const std::string&))
00125 {
00126     std::vector<std::string> splitResult = hugin_utils::SplitString(input, ", ");
00127     for(size_t i=0; i<splitResult.size(); i++)
00128     {
00129         (*func)(parseVec, splitResult[i]);
00130     };
00131 };
00132 
00133 // adds given varname to optVec
00134 // does some additional checking:
00135 //   1. don't add y,p,r for anchor image
00136 //   2. handle vignetting and EMoR parameters as group
00137 void AddToOptVec(HuginBase::OptimizeVector& optVec, std::string varname, size_t imgNr,
00138                  std::set<size_t> refImgs, bool linkRefImgsYaw, bool linkRefImgsPitch, bool linkRefImgsRoll, std::vector<std::set<std::string> > groupedVars)
00139 {
00140     if(varname=="y")
00141     {
00142         if(!set_contains(refImgs, imgNr) || linkRefImgsYaw)
00143         {
00144             optVec[imgNr].insert(varname);
00145         };
00146     }
00147     else
00148     {
00149         if(varname=="p")
00150         {
00151             if(!set_contains(refImgs, imgNr) || linkRefImgsPitch)
00152             {
00153                 optVec[imgNr].insert(varname);
00154             };
00155         }
00156         else
00157         {
00158             if(varname=="r")
00159             {
00160                 if(!set_contains(refImgs, imgNr) || linkRefImgsRoll)
00161                 {
00162                     optVec[imgNr].insert(varname);
00163                 };
00164             }
00165             else
00166             {
00167                 if(varname=="TrX" || varname=="TrY" || varname=="TrZ" || varname=="Tpy" || varname=="Tpp")
00168                 {
00169                     if(!set_contains(refImgs, imgNr))
00170                     {
00171                         optVec[imgNr].insert(varname);
00172                     };
00173                 }
00174                 else
00175                 {
00176                     for(size_t i=0; i<groupedVars.size(); i++)
00177                     {
00178                         if(set_contains(groupedVars[i], varname))
00179                         {
00180                             for(std::set<std::string>::const_iterator it=groupedVars[i].begin(); it!=groupedVars[i].end(); ++it)
00181                             {
00182                                 optVec[imgNr].insert(*it);
00183                             };
00184                             return;
00185                         };
00186                     };
00187                     optVec[imgNr].insert(varname);
00188                 };
00189             };
00190         };
00191     };
00192 };
00193 
00194 // remove given variable from optvec, handle also correct grouped variables
00195 void RemoveFromOptVec(HuginBase::OptimizeVector& optVec, std::string varname, size_t imgNr, std::vector<std::set<std::string> > groupedVars)
00196 {
00197     for(size_t i=0; i<groupedVars.size(); i++)
00198     {
00199         if(set_contains(groupedVars[i], varname))
00200         {
00201             for(std::set<std::string>::const_iterator it=groupedVars[i].begin(); it!=groupedVars[i].end(); ++it)
00202             {
00203                 optVec[imgNr].erase(*it);
00204             };
00205             return;
00206         };
00207     };
00208     optVec[imgNr].erase(varname);
00209 };
00210 
00211 // link or unlink the parsed image variables
00212 void UnLinkVars(HuginBase::Panorama& pano, ParseVarVec parseVec, bool link)
00213 {
00214     for(size_t i=0; i<parseVec.size(); i++)
00215     {
00216         //skip invalid image numbers
00217         if(parseVec[i].imgNr<0 || parseVec[i].imgNr>=(int)pano.getNrOfImages())
00218         {
00219             continue;
00220         };
00221 
00222         //convert to ImageVariableGroup::IVE_name format
00223         std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> variables;
00224 #define image_variable( name, type, default_value ) \
00225     if (HuginBase::PTOVariableConverterFor##name::checkApplicability(parseVec[i].varname))\
00226     {\
00227         variables.insert(HuginBase::ImageVariableGroup::IVE_##name);\
00228     };
00229 #include "panodata/image_variables.h"
00230 #undef image_variable
00231 
00232         if(!variables.empty())
00233         {
00234             //lens variable
00235             if(set_contains(HuginBase::StandardImageVariableGroups::getLensVariables(), *variables.begin()))
00236             {
00237                 HuginBase::ImageVariableGroup group(HuginBase::StandardImageVariableGroups::getLensVariables(), pano);
00238                 if (link)
00239                 {
00240                     group.linkVariableImage(*variables.begin(), parseVec[i].imgNr);
00241                 }
00242                 else
00243                 {
00244                     group.unlinkVariableImage(*variables.begin(), parseVec[i].imgNr);
00245                     group.updatePartNumbers();
00246                 }
00247             }
00248             else
00249             {
00250                 //stack variables
00251                 // handle yaw, pitch, roll, TrX, TrY and TrZ always together
00252                 if(set_contains(HuginBase::StandardImageVariableGroups::getStackVariables(), *variables.begin()))
00253                 {
00254                     HuginBase::ImageVariableGroup group(HuginBase::StandardImageVariableGroups::getStackVariables(), pano);
00255                     if (link)
00256                     {
00257                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_Yaw, parseVec[i].imgNr);
00258                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_Pitch, parseVec[i].imgNr);
00259                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_Roll, parseVec[i].imgNr);
00260                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_X, parseVec[i].imgNr);
00261                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_Y, parseVec[i].imgNr);
00262                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_Z, parseVec[i].imgNr);
00263                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_TranslationPlaneYaw, parseVec[i].imgNr);
00264                         group.linkVariableImage(HuginBase::ImageVariableGroup::IVE_TranslationPlanePitch, parseVec[i].imgNr);
00265                     }
00266                     else
00267                     {
00268                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_Yaw, parseVec[i].imgNr);
00269                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_Pitch, parseVec[i].imgNr);
00270                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_Roll, parseVec[i].imgNr);
00271                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_X, parseVec[i].imgNr);
00272                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_Y, parseVec[i].imgNr);
00273                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_Z, parseVec[i].imgNr);
00274                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_TranslationPlaneYaw, parseVec[i].imgNr);
00275                         group.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_TranslationPlanePitch, parseVec[i].imgNr);
00276                         group.updatePartNumbers();
00277                     }
00278                 }
00279                 else
00280                 {
00281                     std::cerr << "Warning: " << parseVec[i].varname << " is not a valid linkable variable." << std::endl;
00282                 };
00283             };
00284         };
00285     };
00286 };
00287 
00288 bool UpdateSingleVar(HuginBase::Panorama& pano, ParseVar parseVar, size_t imgNr)
00289 {
00290     double val=pano.getImage(imgNr).getVar(parseVar.varname);
00291     Parser::ConstantMap constMap;
00292     constMap["i"]=1.0*imgNr;
00293     constMap["val"]=val;
00294     std::cout << "Updating variable " << parseVar.varname << imgNr << ": " << val;
00295     if(Parser::ParseExpression(parseVar.expression, val, constMap))
00296     {
00297         std::cout << " -> " << val << std::endl;
00298         HuginBase::Variable var(parseVar.varname, val);
00299         pano.updateVariable(imgNr, var);
00300         return true;
00301     }
00302     else
00303     {
00304         std::cout << std::endl;
00305         std::cerr << "Could not parse given expression \"" << parseVar.expression << "\" for image " << imgNr << "." << std::endl;
00306         return false;
00307     };
00308 };
00309 
00310 static void usage(const char* name)
00311 {
00312     std::cout << name << ": change image variables inside pto files" << std::endl
00313          << name << " version " << hugin_utils::GetHuginVersion() << std::endl
00314          << std::endl
00315          << "Usage:  " << name << " [options] --opt|--link|--unlink|--set varlist input.pto" << std::endl
00316          << std::endl
00317          << "     -o, --output=file.pto  Output Hugin PTO file. Default: <filename>_var.pto" << std::endl
00318          << "     -h, --help             Shows this help" << std::endl
00319          << std::endl
00320          << "     --opt varlist          Change optimizer variables" << std::endl
00321          << "     --modify-opt           Modify the existing optimizer variables" << std::endl
00322          << "                            (without pto_var will start with an" << std::endl
00323          << "                             empty variables set)" << std::endl
00324          << "                            Examples:" << std::endl
00325          << "           --opt=y,p,r        Optimize yaw, pitch and roll of all images" << std::endl
00326          << "                              (special treatment for anchor image applies)" << std::endl
00327          << "           --opt=v0,b2        Optimize hfov of image 0 and barrel distortion" << std::endl
00328          << "                              of image 2" << std::endl
00329          << "           --opt=v,!v0        Optimize field of view for all images except" << std::endl
00330          << "                              for the first image" << std::endl
00331          << "           --opt=!a,!b,!c     Don't optimise distortion (works only with" << std::endl
00332          << "                              switch --modify-opt together)" << std::endl
00333          << std::endl
00334          << "     --link varlist         Link given variables" << std::endl
00335          << "                            Example:" << std::endl
00336          << "           --link=v3          Link hfov of image 3" << std::endl
00337          << "           --link=a1,b1,c1    Link distortions parameter for image 1" << std::endl
00338          << std::endl
00339          << "     --unlink varlist       Unlink given variables" << std::endl
00340          << "                            Examples:" << std::endl
00341          << "           --unlink=v5        Unlink hfov for image 5" << std::endl
00342          << "           --unlink=a2,b2,c2  Unlink distortions parameters for image 2" << std::endl
00343          << std::endl
00344          << "     --set varlist          Sets variables to new values" << std::endl
00345          << "                            Examples:" << std::endl
00346          << "           --set=y0=0,r0=0,p0=0  Resets position of image 0" << std::endl
00347          << "           --set=Vx4=-10,Vy4=10  Sets vignetting offset for image 4" << std::endl
00348          << "           --set=v=20            Sets the field of view to 20 for all images" << std::endl
00349          << "           --set=y=val+20        Increase yaw by 20 deg for all images" << std::endl
00350          << "           --set=v=val*1.1       Increase fov by 10 % for all images" << std::endl
00351          << "           --set=y=i*20          Set yaw to 0, 20, 40, ..." << std::endl
00352          << "     --set-from-file filename  Sets variables to new values" << std::endl
00353          << "                               It reads the varlist from a file" << std::endl
00354          << std::endl;
00355 }
00356 
00357 int main(int argc, char* argv[])
00358 {
00359     // parse arguments
00360     const char* optstring = "o:h";
00361 
00362     enum
00363     {
00364         SWITCH_OPT=1000,
00365         SWITCH_LINK,
00366         SWITCH_UNLINK,
00367         SWITCH_SET,
00368         SWITCH_SET_FILE,
00369         OPT_MODIFY_OPTVEC
00370     };
00371     static struct option longOptions[] =
00372     {
00373         {"output", required_argument, NULL, 'o' },
00374         {"opt", required_argument, NULL, SWITCH_OPT },
00375         {"link", required_argument, NULL, SWITCH_LINK },
00376         {"unlink", required_argument, NULL, SWITCH_UNLINK },
00377         {"set", required_argument, NULL, SWITCH_SET },
00378         {"set-from-file", required_argument, NULL, SWITCH_SET_FILE },
00379         {"modify-opt", no_argument, NULL, OPT_MODIFY_OPTVEC },
00380         {"help", no_argument, NULL, 'h' },
00381         0
00382     };
00383 
00384     ParseVarVec optVars;
00385     ParseVarVec linkVars;
00386     ParseVarVec unlinkVars;
00387     ParseVarVec setVars;
00388     bool modifyOptVec=false;
00389     int c;
00390     std::string output;
00391     while ((c = getopt_long (argc, argv, optstring, longOptions,nullptr)) != -1)
00392     {
00393         switch (c)
00394         {
00395             case 'o':
00396                 output = optarg;
00397                 break;
00398             case 'h':
00399                 usage(hugin_utils::stripPath(argv[0]).c_str());
00400                 return 0;
00401             case SWITCH_OPT:
00402                 ParseVariableString(optVars, std::string(optarg), ParseSingleOptVar);
00403                 break;
00404             case SWITCH_LINK:
00405                 ParseVariableString(linkVars, std::string(optarg), ParseSingleLinkVar);
00406                 break;
00407             case SWITCH_UNLINK:
00408                 ParseVariableString(unlinkVars, std::string(optarg), ParseSingleLinkVar);
00409                 break;
00410             case SWITCH_SET:
00411                 ParseVariableString(setVars, std::string(optarg), ParseSingleVar);
00412                 break;
00413             case SWITCH_SET_FILE:
00414                 {
00415                     std::ifstream ifs(optarg);
00416                     if(ifs.is_open())
00417                     {
00418                         std::ostringstream contents;
00419                         contents << ifs.rdbuf();
00420                         ifs.close();
00421                         std::string s(contents.str());
00422                         hugin_utils::ReplaceAll(s, "\n", ',');
00423                         ParseVariableString(setVars, s, ParseSingleVar);
00424                     }
00425                     else
00426                     {
00427                         std::cerr << hugin_utils::stripPath(argv[0]) << ": Could not open file " << optarg << std::endl;
00428                         return 1;
00429                     };
00430                 };
00431                 break;
00432             case OPT_MODIFY_OPTVEC:
00433                 modifyOptVec=true;
00434                 break;
00435             case ':':
00436             case '?':
00437                 // missing argument or invalid switch
00438                 return 1;
00439                 break;
00440             default:
00441                 // this should not happen
00442                 abort();
00443 
00444         }
00445     }
00446 
00447     if (argc - optind != 1)
00448     {
00449         if (argc - optind < 1)
00450         {
00451             std::cerr << hugin_utils::stripPath(argv[0]) << ": No project file given." << std::endl;
00452         }
00453         else
00454         {
00455             std::cerr << hugin_utils::stripPath(argv[0]) << ": Only one project file expected." << std::endl;
00456         };
00457         return 1;
00458     };
00459 
00460     if(optVars.size() + linkVars.size() + unlinkVars.size() + setVars.size()==0)
00461     {
00462         std::cerr << hugin_utils::stripPath(argv[0]) << ": 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 10 Dec 2016 for Hugintrunk by  doxygen 1.4.7