43 #if defined(__APPLE__) && defined(nil)
46 #include <boost/graph/graphviz.hpp>
85 bool optHFOV,
bool optB)
93 m_li1 = (i1 < i2) ? 0 : 1;
94 m_li2 = (i1 < i2) ? 1 : 0;
98 for (
size_t i = 0; i <
m_cps.size();++i)
126 if (optHFOV || optB) {
139 for (
size_t i = 0; i <
m_optvars.size(); ++i)
151 bool estimate(
const std::vector<const ControlPoint *> & points, std::vector<double> & p)
const
166 for (
size_t i=0; i < points.size(); i++) {
167 cpoints[i] = *points[i];
174 for (
size_t i = 0; i <
m_optvars.size(); ++i)
201 for (
size_t i = 0; i <
m_optvars.size(); ++i)
214 for (
size_t i = 0; i <
m_optvars.size(); ++i)
225 double x1,y1,x2,y2,xt,yt,x2t,y2t;
239 DEBUG_DEBUG(
"Trafo i1 (0 " << x1 <<
" " << y1 <<
") -> ("<< xt <<
" "<< yt<<
") -> i2 (1 "<<x2t<<
", "<<y2t<<
"), real ("<<x2<<
", "<<y2<<
")")
243 double e = hypot(x2t,y2t);
276 bool optHFOV =
false;
291 DEBUG_DEBUG(
"Optimizing HFOV:" << optHFOV <<
" b:" << optB)
294 std::vector<double> parameters(estimator.
m_initParams.size());
296 std::vector<int> inlier_idx;
297 DEBUG_DEBUG(
"Number of control points: " << estimator.
m_xy_cps.size() <<
" Initial parameter[0]" << parameters[0]);
298 std::vector<const ControlPoint *> inliers =
Ransac::compute(parameters, inlier_idx, estimator, estimator.
m_xy_cps, 0.999, 0.3);
299 DEBUG_DEBUG(
"Number of inliers:" << inliers.size() <<
"optimized parameter[0]" << parameters[0]);
302 for (
size_t i = 0; i < estimator.
m_optvars.size(); ++i)
328 UIntSet imgs(visitedNeighbors);
337 unsigned currImg = 0;
339 for (UIntSet::const_iterator it = imgs.begin(); it != imgs.end(); ++it)
349 optvec[currImg] =
m_opt;
357 const std::set<std::string>&
m_opt;
368 std::set<std::string> optvars;
402 for (CPVector::const_iterator it = cps.begin(); it != cps.end(); ++it) {
405 newCP.push_back(*it);
423 double origLensPar[5];
429 bool alreadyCalibrated =
false;
430 for (
int i = 0; i < 5; i++) {
431 if (origLensPar[i] != 0) {
432 alreadyCalibrated =
true;
436 bool singleStack=
false;
437 if(!alreadyCalibrated) {
441 singleStack = (stacks.size() == 1);
446 if (!alreadyCalibrated && !singleStack) {
461 double rmin, rmax, rmean, rvar, rq10, rq90;
464 DEBUG_DEBUG(
"Ctrl Point radi statistics: min:" << rmin <<
" max:" << rmax <<
" mean:" << rmean <<
" var:" << rvar <<
" q10:" << rq10 <<
" q90:" << rq90);
472 if ( (rq90 - rq10) >= 1.2) {
476 }
else if ( (rq90 - rq10) > 1.0) {
505 bool smallHFOV =
false;
506 bool highDist =
false;
507 bool highShift =
false;
511 for (VariableMapVector::const_iterator it = vars.begin() ; it != vars.end(); ++it)
513 if (
const_map_get(*it,
"v").getValue() < 1.0) smallHFOV =
true;
514 if (fabs(
const_map_get(*it,
"a").getValue()) > 0.2) highDist =
true;
515 if (fabs(
const_map_get(*it,
"b").getValue()) > 0.2) highDist =
true;
516 if (fabs(
const_map_get(*it,
"c").getValue()) > 0.2) highDist =
true;
517 if (fabs(
const_map_get(*it,
"d").getValue()) > 1000) highShift =
true;
518 if (fabs(
const_map_get(*it,
"e").getValue()) > 1000) highShift =
true;
521 if (smallHFOV || highDist || highShift) {
522 DEBUG_DEBUG(
"Optimization with strange result. status: HFOV: " << smallHFOV <<
" dist:" << highDist <<
" shift:" << highShift);
546 bool highDist =
false;
550 for (VariableMapVector::const_iterator it = vars.begin() ; it != vars.end(); ++it)
552 if (fabs(
const_map_get(*it,
"b").getValue()) > 0.2) highDist =
true;
556 DEBUG_DEBUG(
"recover optimisation (2): " << optmode);
580 std::set<std::string> imgopt;
583 if (!iImage.RollisLinkedWith(anchorImage) &&
584 !iImage.PitchisLinkedWith(anchorImage) &&
585 !iImage.YawisLinkedWith(anchorImage))
595 if((i==anchorImg) && (mode &
OPT_POS))
604 imgopt.insert(
"Eev");
645 optvars.push_back(imgopt);
virtual bool runAlgorithm()
calls PTools::optimize()
std::vector< UIntSet > getHDRStacks(const PanoramaData &pano, UIntSet allImgs, PanoramaOptions opts)
returns vector of set of output stacks
declaration of functions to handle stacks and layers
virtual void setOptimizeVector(const OptimizeVector &optvec)=0
set optimize setting
std::vector< UIntSet > UIntSetVector
Generic implementation of the RanSaC algorithm.
virtual void setCtrlPoints(const CPVector &points)=0
set all control points (Ippei: Is this supposed to be 'add' method?)
PanoramaData * m_localPano
virtual const VariableMap getImageVariables(unsigned int imgNr) const =0
get variables of an image
static void smartOptimize(PanoramaData &pano)
static std::vector< const T * > compute(S ¶meters, std::vector< int > &inliers, const Estimator ¶mEstimator, const std::vector< T > &data, double desiredProbabilityForNoOutliers, double maximalOutlierPercentage)
Estimate the model parameters using the RanSac framework.
bool leastSquaresEstimate(const std::vector< const ControlPoint * > &points, std::vector< double > &p) const
virtual void updateVariable(unsigned int imgNr, const Variable &var)=0
update a single variable
static hugin_utils::FDiff2D calcFOV(const PanoramaData &panorama)
Somewhere to specify what variables belong to what.
static std::vector< int > findInliers(PanoramaData &pano, int i1, int i2, double maxError, Mode mode=RPY)
std::vector< double > m_initParams
a variable has a value and a name.
void Visit(const size_t vertex, const HuginBase::UIntSet &visitedNeighbors, const HuginBase::UIntSet &unvisitedNeighbors)
virtual void run()
runs the algorithm.
Estimator for RANSAC based adjustment of pairwise parameters.
represents a control point
const Map::mapped_type & const_map_get(const Map &m, const typename Map::key_type &key)
void linkVariablePart(ImageVariableEnum variable, unsigned int partNr)
link one of the variables across a given part
static void calcCtrlPntsRadiStats(const PanoramaData &pano, double &min, double &max, double &mean, double &var, double &q10, double &q90, const int &imgNr=-1)
std::set< unsigned int > UIntSet
virtual PanoramaData * getUnlinkedSubset(UIntSetVector &imageGroups) const =0
std::vector< VariableMap > VariableMapVector
empirical model of response
void VisitAllImages(const size_t startImg, bool forceAllComponents, BreadthFirstSearchVisitor *visitor)
visit all images via a breadth first search algorithm for each visited images, the functor visitor is...
int numForEstimate() const
OptVarSpec(int img, std::string name)
virtual bool runAlgorithm()
calls PTools::optimize()
virtual void setOptions(const PanoramaOptions &opt)=0
set new output settings This is not used directly for optimizing/stiching, but it can be feed into ru...
std::vector< int > o_inliers
virtual const PanoramaOptions & getOptions() const =0
returns the options for this panorama
bool agree(std::vector< double > &p, const ControlPoint &cp) const
ImageVariableGroup & getLenses()
Get the ImageVariableGroup representing the group of lens variables.
void set(PanoramaData &pano, double x) const
virtual const SrcPanoImage & getImage(std::size_t nr) const =0
get a panorama image, counting starts with 0
double getVar(const std::string &name) const
!! from PTOptimise.h 1951
virtual const CPVector & getCtrlPoints() const =0
get all control point of this Panorama
const std::set< std::string > & m_opt
std::vector< std::set< std::string > > m_opt_first_pass
AutoOptimiseVisitor(PanoramaData *pano, const std::set< std::string > &optvec)
PanoramaData & o_panorama
virtual VariableMapVector getVariables() const =0
get variables of this panorama
std::vector< ControlPoint > CPVector
std::vector< std::set< std::string > > OptimizeVector
void fill_set(_Container &c, typename _Container::key_type begin, typename _Container::key_type end)
std::vector< std::set< std::string > > m_opt_second_pass
virtual std::size_t getNrOfImages() const =0
number of images.
std::size_t getNumberOfParts() const
get the number of parts.
All variables of a source image.
PTOptEstimator(PanoramaData &pano, int i1, int i2, double maxError, bool optHFOV, bool optB)
bool estimate(const std::vector< const ControlPoint * > &points, std::vector< double > &p) const
Perform exact estimate.
virtual void updateVariables(const VariableMapVector &vars)=0
Set the variables.
static OptimizeVector createOptVars(const PanoramaData &optPano, int mode, unsigned anchorImg=0)
helper function for optvar creation
abstract base functor for breadth first search in ImageGraph
std::vector< OptVarSpec > m_optvars
static void autoOptimise(PanoramaData &pano, bool optRoll=true)
virtual PanoramaData * getNewSubset(const UIntSet &imgs) const =0
unsigned int optimizeReferenceImage
class to work with images graphs created from a HuginBase::Panorama class it creates a graph based on...