Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PanoToolsUtils.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
27 #include <hugin_config.h>
28 
29 #include <sstream>
30 #include <hugin_utils/utils.h>
31 
32 // libpano includes ------------------------------------------------------------
33 
34 #include <stdlib.h>
35 
36 #ifdef _WIN32
37 // include windows.h with sensible defines, otherwise
38 // panotools might include with its stupid, commonly
39 // named macros all over the place.
40 #define _STLP_VERBOSE_AUTO_LINK
41 //#define _USE_MATH_DEFINES
42 #define NOMINMAX
43 #define VC_EXTRALEAN
44 #include <windows.h>
45 #undef DIFFERENCE
46 #endif
47 
48 #include "PanoToolsInterface.h"
49 #include "PanoToolsUtils.h"
50 
51 namespace HuginBase { namespace PTools {
52 
54 {
55  if(pano.getNrOfImages()>0 && pano.getNrOfCtrlPoints()>0)
56  {
57  char * p=setlocale(LC_ALL,NULL);
58  char * oldlocale=strdup(p);
59  setlocale(LC_ALL,"C");
60  UIntSet allImg;
61  std::ostringstream scriptbuf;
62  fill_set(allImg,0, unsigned(pano.getNrOfImages()-1));
63  //create temporary non-empty optimize vector
64  OptimizeVector optVec;
65  std::set<std::string> opt;
66  opt.insert("y");
67  for(unsigned int i=0;i<pano.getNrOfImages();i++)
68  {
69  optVec.push_back(opt);
70  };
71  pano.printPanoramaScript(scriptbuf, optVec,
72  pano.getOptions(), allImg, true);
73 
74  char * script = 0;
75  script = strdup(scriptbuf.str().c_str());
76  AlignInfo ainf;
77  if (ParseScript( script, &ainf ) == 0)
78  {
79  if( CheckParams( &ainf ) == 0 )
80  {
81  ainf.fcn = fcnPano;
82  SetGlobalPtr( &ainf );
84  }
85  }
86  DisposeAlignInfo(&ainf);
87  free(script);
88  setlocale(LC_ALL,oldlocale);
89  free(oldlocale);
90  };
91 }
92 
93 
94 } // PTools namespace
95 } // HuginBase namespace
virtual void printPanoramaScript(std::ostream &o, const OptimizeVector &optvars, const PanoramaOptions &options, const UIntSet &imgs, bool forPTOptimizer, const std::string &stripPrefix="") const =0
create an optimizer script
std::set< unsigned int > UIntSet
Definition: PanoramaData.h:51
void calcCtrlPointErrors(PanoramaData &pano)
Update the Ctrl Point errors without optimizing.
virtual void updateCtrlPointErrors(const CPVector &controlPoints)=0
update control points distances.
virtual const PanoramaOptions & getOptions() const =0
returns the options for this panorama
Model for a panorama.
Definition: PanoramaData.h:81
Utility calls into PanoTools using CPP interface.
CPVector GetAlignInfoCtrlPoints(const AlignInfo &gl)
virtual std::size_t getNrOfCtrlPoints() const =0
number of control points
std::vector< std::set< std::string > > OptimizeVector
void fill_set(_Container &c, typename _Container::key_type begin, typename _Container::key_type end)
Definition: stl_utils.h:81
virtual std::size_t getNrOfImages() const =0
number of images.