00001 #ifndef _SAMS_HYPOTHESIS_HPP_
00002 #define _SAMS_HYPOTHESIS_HPP_
00003
00004 #include "jafarConfig.h"
00005
00006 #include "jmath/ublasExtra.hpp"
00007 #include "sams/matching.hpp"
00008
00009 namespace jafar {
00010 namespace sams{
00011
00012 class Match;
00013
00014 struct Hypothesis {
00016 std::string m_label;
00018 int m_view_id;
00020 int m_width, m_height;
00022 double m_wght;
00024 double m_dx,m_dy,m_dt,m_ds;
00026 jblas::mat m_t;
00028 double m_err;
00030 double m_p;
00032 std::vector<jafar::sams::Match> m_matches;
00033
00034 int size() const {
00035 return m_matches.size();
00036 };
00037
00039 bool operator< (Hypothesis const & h_) const {
00040 return ( m_matches.size()*m_wght < h_.m_matches.size()*h_.m_wght );
00041 };
00042
00043 void computeProbability();
00044
00045 #ifdef HAVE_BOOST_SANDBOX
00046 #ifdef HAVE_LAPACK
00047
00055 void computeSimilarityTransform ();
00056
00062 void pruneByAff(std::vector<jafar::sams::Match> const & matches_);
00063
00064 static void pruneByAff(std::vector<jafar::sams::Match> const & matches_, std::vector<Hypothesis> & vHc_);
00065
00066 #endif
00067 #endif
00068
00069
00070 jblas::vec view2Frame () const {
00071 jblas::vec res(10);
00072 jblas::vec pos(3);
00073 jblas::mat t_inv(3,3);
00074 jmath::ublasExtra::lu_inv(m_t,t_inv);
00075
00076 pos(0) = 0.0; pos(1) = 0.0; pos(2) = 1.0;
00077 jblas::vec3 coords = ublas::prod(t_inv,pos);
00078 res(0) = floor(coords(0)+0.5);
00079 res(1) = floor(coords(1)+0.5);
00080
00081 pos(0) = 0.0; pos(1) = m_height; pos(2) = 1.0;
00082 coords = ublas::prod(t_inv,pos);
00083 res(2) = floor(coords(0)+0.5);
00084 res(3) = floor(coords(1)+0.5);
00085
00086 pos(0) = m_width; pos(1) = 0.0; pos(2) = 1.0;
00087 coords = ublas::prod(t_inv,pos);
00088 res(4) = floor(coords(0)+0.5);
00089 res(5) = floor(coords(1)+0.5);
00090
00091 pos(0) = m_width; pos(1) = m_height; pos(2) = 1.0;
00092 coords = ublas::prod(t_inv,pos);
00093 res(6) = floor(coords(0)+0.5);
00094 res(7) = floor(coords(1)+0.5);
00095
00096 pos(0) = m_width/2; pos(1) = m_height/2; pos(2) = 1.0;
00097 coords = ublas::prod(t_inv,pos);
00098 res(8) = floor(coords(0)+0.5);
00099 res(9) = floor(coords(1)+0.5);
00100 return res;
00101 };
00102
00103 jblas::vec part2Frame(int i) const {
00104 jblas::mat t_inv(3,3);
00105 jmath::ublasExtra::lu_inv(m_t,t_inv);
00106 return m_matches[i].modelRef->transform(t_inv);
00107 }
00108
00109
00110 std::string toString() const {
00111 std::stringstream s;
00112 s << "Hypthesis(" << m_label << "," << m_view_id << ","
00113 << m_wght << "," << m_p << "," << m_matches.size() << "," << m_dx << "," << m_dy << "," << m_dt << "," << m_ds << ")";
00114 return s.str();
00115 }
00116 };
00117
00118 }
00119 }
00120
00121 #endif