PairNode.h
Go to the documentation of this file.
00001 #ifndef ATOMPAIR_H_
00002 #define ATOMPAIR_H_
00003 
00004 #include "pano_core/ModelFitter.h"
00005 #include <iostream>
00006 
00007 namespace pano {
00008 
00013 struct PairNodeData {
00014 
00015     float distance;
00016     int  depth;
00017     int visited;
00018     bool mode;
00019 
00020     PairNodeData( float dist, int depth, int vis ) :
00021             distance(dist), depth(depth), visited(vis),
00022             mode(true) { }
00023     PairNodeData( const PairNodeData& node ) :
00024     distance(node.distance), depth(node.depth), visited(node.visited),
00025         mode(node.mode) { }
00026     AtomPairSet neighbors;
00027 
00028     static int max_depth;
00029     static int min_depth;
00030 };
00031 
00035 typedef float (*PairMatchErrFPT)(const AtomPair& pair, const PairNodeData& node_data );
00036 
00041 typedef float (*PairBlendConfFPT)(  float err_new, float err_prv );
00042 
00045 inline float PairConfExpLaw(  float err_new, float err_prv ) {
00046  double C_0   = 20.0;
00047  double C_1   = 0.5;
00048  double beta0 = 0.5;   // E=beta0 => C=C_0
00049  double beta1 = 100.0; // E=beta1 => C=C_1
00050  double alpha = 1e-2;  // lim(C)_{E->infty) = alpha
00051  double gamma = -1.0/(beta1-beta0) * log( (C_1-alpha) / C_0 );
00052  double err_net = err_new + err_prv;
00053  return (float) alpha + C_0 * exp( -(err_net-beta0) * gamma );
00054 }
00055 
00061 inline float PairConfInvLaw( float err_new, float err_prv) {
00062  double C_0   = 1.0;
00063  double eps0  = 1e-1;
00064  double alpha = 1e-3;  // lim(C)_{E->infty) = alpha
00065  double err   = err_new + err_prv; // allow previous weight somewhat
00066         err   = pow(err,1.5);
00067  return (float) alpha + C_0 / (err + eps0 );
00068 }
00069 
00074 inline float PairErrorInliers(const AtomPair& pair, const PairNodeData& node_data ){
00075    return 10*pair.result().err()*pair.result().err()   + 10/(float)pair.result().inliers();
00076 }
00077 
00078 inline float PairErrorSimple(const AtomPair& pair, const PairNodeData& node_data){
00079     return  10*pair.result().err()*pair.result().err() ;
00080 }
00081 
00086 inline float PairErrorAvoidCompassChain(const AtomPair& pair, const PairNodeData& node_data){ // big penalty to chaining compass atoms together
00087     float gamma0 = 0.0;
00088     if( node_data.mode      ==  true )
00089         gamma0 += 1e2;
00090     return pair.result().err() + gamma0;
00091 }
00092 
00093 struct PairNode{
00094 
00095     PairNode(PairMatchErrFPT error_func = PairErrorInliers,
00096      PairBlendConfFPT bconf_func = PairConfInvLaw ):
00097             error_func(error_func), bconf_func(bconf_func),
00098             node_data(INFINITY,0,false) {  }
00099 
00100     PairNode( const PairNode& node ) : error_func(node.error_func),
00101      bconf_func(node.bconf_func), node_data(node.node_data) { }
00102 
00103     PairMatchErrFPT     error_func;
00104     PairBlendConfFPT    bconf_func;
00105     PairNodeData node_data;
00106 
00107     cv::Ptr<ImageAtom> min_prev; /* The N-1 optimal atom for sub-problem
00108                                          terminating at 'this' Nth node */
00109     cv::Ptr<ImageAtom> atom;     /* 'this' Nth node in dynamic-programming-like traversal  */
00110 
00111     bool operator < (const PairNode& rhs){
00112         return node_data.distance < rhs.node_data.distance;
00113     }
00114 
00118     void setDist(const AtomPair& pair, const PairNode& prev_node);
00119 
00123     static void graphviz_dump(std::ostream& out, const std::map<cv::Ptr<ImageAtom>,PairNode>&  node_map);
00124 
00128     static void graphviz_dump_all(std::ostream& out, const std::map<cv::Ptr<ImageAtom>,PairNode>&  node_map);
00129 
00130 };
00131 
00132 
00135 std::ostream& operator << (std::ostream& out, const PairNode& node);
00136 
00139 std::ostream& operator << (std::ostream& out, const AtomPair& pair);
00140 
00141 
00142 }
00143 
00144 #endif


pano_core
Author(s): Ethan Rublee
autogenerated on Mon Mar 14 2016 10:56:54