00001
00002
00003 #ifndef SAMS_FEATURE_HPP
00004 #define SAMS_FEATURE_HPP
00005
00006 #include <cmath>
00007 #include <vector>
00008 #include "jmath/jblas.hpp"
00009 #include "kernel/jafarDebug.hpp"
00010
00011 namespace jafar {
00012 namespace sams {
00013
00014
00015 typedef enum FeatureType {
00016 SSAL,
00017 DOG
00018 };
00019
00020 class Feature {
00021 public:
00022 FeatureType type;
00023
00024 jblas::vec app;
00025 jblas::vec info;
00026
00027 Feature() : app(),
00028 info(jblas::zero_vec(8)) {
00029 info(2) = 1.0;
00030 };
00031
00032 Feature(const Feature& f_) {
00033 app = f_.app;
00034 info = f_.info;
00035 };
00036
00037 inline double x() const { return info(0); };
00038 inline double y() const { return info(1); };
00039 inline double s() const { return info(3); };
00040 inline double o() const { return info(4); };
00041 inline double hd() const { return info(5); };
00042 inline double wd() const { return info(6); };
00043 inline double yd() const { return info(7); };
00044 inline jblas::vec2 const pt() const {
00045 return ublas::project(info,ublas::range(0,2));
00046 };
00047
00048 inline jblas::vec3 const h_pt() const {
00049 return ublas::project(info,ublas::range(0,3));
00050 };
00051
00052 inline double &x() { return info(0); };
00053 inline double &y() { return info(1); };
00054 inline double &s() { return info(3); };
00055 inline double &o() { return info(4); };
00056 inline double &hd() { return info(5); };
00057 inline double &wd() { return info(6); };
00058 inline double &yd() { return info(7); };
00059
00060 inline bool operator<(const Feature& f_) const {
00061 return ( yd() < f_.yd() );
00062 };
00063
00064 inline bool operator>(const Feature& f_) const {
00065 return ( yd() > f_.yd() );
00066 };
00067
00068 inline Feature& operator=(const Feature& f_) {
00069 app = f_.app;
00070 info = f_.info;
00071 return *this;
00072 };
00073
00074 inline double app_dist(const Feature& f_) const {
00075 return ublas::norm_2(app-f_.app);
00076 };
00077
00078 inline double si_dist(const Feature& f_) const {
00079 return sqrt(pow(x()-f_.x(),2)+pow(y()-f_.y(),2))/sqrt(s()*s()+f_.s()*f_.s());
00080 };
00081
00082 inline double angle(const Feature& f_) const {
00083 return atan2(f_.y()-y(),f_.x()-x());
00084 };
00085
00086 double appSimilarity(const Feature& f_) const;
00087
00088 };
00089
00090
00091 }
00092 }
00093
00094 #endif // SAMS_FEATURE_HPP