Go to the documentation of this file.00001
00002 #ifndef strk_tracker_h_
00003 #define strk_tracker_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <vcl_vector.h>
00025 #include <vil1/vil1_image.h>
00026 #include <vil1/vil1_memory_image_of.h>
00027 #include <vtol/vtol_face_2d_sptr.h>
00028 #include <vtol/vtol_intensity_face_sptr.h>
00029 #include <strk/strk_tracker_params.h>
00030
00031
00032
00033 struct strk_correlated_face
00034 {
00035 strk_correlated_face ();
00036 ~strk_correlated_face();
00037 void set_face(vtol_intensity_face_sptr const& f);
00038 void set_correlation(const float c) {c_ = c;}
00039 vtol_intensity_face_sptr face() {return f_;}
00040 float correlation() const {return c_;}
00041 float Ix(int i){return Ix_[i];}
00042 float Iy(int i){return Iy_[i];}
00043 void set_Ix(int i, const float Ix){Ix_[i] = Ix;}
00044 void set_Iy(int i, const float Iy){Iy_[i] = Iy;}
00045 private:
00046 float c_;
00047 vtol_intensity_face_sptr f_;
00048 float* Ix_;
00049 float* Iy_;
00050 };
00051
00052 class strk_tracker : public strk_tracker_params
00053 {
00054 public:
00055
00056 strk_tracker(strk_tracker_params& tp);
00057
00058 ~strk_tracker();
00059
00060 void set_image_0(vil1_image& image);
00061 void set_image_i(vil1_image& image);
00062 void set_initial_model(vtol_face_2d_sptr const& face);
00063 vtol_face_2d_sptr get_best_sample();
00064 void get_samples(vcl_vector<vtol_face_2d_sptr> & samples);
00065
00066 void init();
00067 void generate_samples();
00068 void cull_samples();
00069 void track();
00070 void clear();
00071
00072 protected:
00073
00074
00075 vtol_intensity_face_sptr
00076 transform_face(vtol_intensity_face_sptr const& face,
00077 double tx, double ty, double theta, double scale);
00078
00079
00080 void fill_face(vtol_intensity_face_sptr const& face,
00081 vil1_memory_image_of<float> const& image);
00082
00083 void set_gradient(strk_correlated_face* cf,
00084 vil1_memory_image_of<float> const& Ix,
00085 vil1_memory_image_of<float> const& Iy);
00086
00087 void correlate_face(strk_correlated_face* cf);
00088
00089
00090 vtol_intensity_face_sptr
00091 generate_sample(vtol_intensity_face_sptr const& seed);
00092
00093
00094 strk_correlated_face*
00095 generate_cf_sample(strk_correlated_face* seed);
00096
00097
00098 strk_correlated_face*
00099 regenerate_cf_sample(strk_correlated_face* sample);
00100
00101
00102 void transform_sample_in_place(strk_correlated_face* sample,
00103 double tx, double ty,
00104 double theta, double scale);
00105
00106
00107 bool compute_motion(strk_correlated_face* cf,
00108 double& tx, double& ty,
00109 double& theta, double& scale);
00110
00111 double compute_correlation(strk_correlated_face* cf);
00112
00113 double compute_gradient_angle(strk_correlated_face* cf);
00114
00115 double compute_angle_motion(strk_correlated_face* cf);
00116 bool compute_scale_motion(strk_correlated_face* cf, double& sx, double& sy);
00117
00118 vil1_memory_image_of<float> image_0_;
00119 vil1_memory_image_of<float> image_i_;
00120 vil1_memory_image_of<float> Ix_0_;
00121 vil1_memory_image_of<float> Iy_0_;
00122 vil1_memory_image_of<float> Ix_i_;
00123 vil1_memory_image_of<float> Iy_i_;
00124 vtol_face_2d_sptr initial_model_;
00125 vcl_vector<strk_correlated_face*> current_samples_;
00126 vcl_vector<strk_correlated_face*> hypothesized_samples_;
00127 vcl_vector<double> sample_scores_;
00128 };
00129
00130 #endif // strk_tracker_h_