1 #include "bvpl_gauss_convolution_functor.h" 2 //: 3 // \file 4 5 6 //: Default Constructor bvpl_gauss_convolution_functor()7bvpl_gauss_convolution_functor::bvpl_gauss_convolution_functor() 8 { 9 max_ =0.0; 10 init(); 11 } 12 13 //: Constructor bvpl_gauss_convolution_functor(const bvpl_kernel_iterator & kernel)14bvpl_gauss_convolution_functor::bvpl_gauss_convolution_functor(const bvpl_kernel_iterator& kernel) 15 { 16 //compute max 17 set_max(kernel); 18 init(); 19 } 20 21 //: Initialize class variables init()22void bvpl_gauss_convolution_functor::init() 23 { 24 mean_= 0.0f; 25 var_ = 0.0f; 26 } 27 28 //: Multiply the dispatch and the input gaussians together apply(bsta_gauss_sf1 & gauss,bvpl_kernel_dispatch & d)29void bvpl_gauss_convolution_functor::apply(bsta_gauss_sf1& gauss, bvpl_kernel_dispatch& d) 30 { 31 mean_+= d.c_*gauss.mean(); 32 var_+= d.c_*d.c_*gauss.var(); 33 } 34 35 //: Return the final result result()36bsta_gauss_sf1 bvpl_gauss_convolution_functor::result() 37 { 38 bsta_gauss_sf1 final_gauss; 39 //if (max_ > 1.0e-10){ 40 // final_gauss.set_mean(mean_/max_); 41 // final_gauss.set_var(var_); 42 //} 43 //else{ // this case is happens when max_ is not initialized 44 final_gauss.set_mean(mean_); 45 final_gauss.set_var(var_); 46 //} 47 init(); 48 return final_gauss; 49 } 50 set_max(bvpl_kernel_iterator kernel_iter)51void bvpl_gauss_convolution_functor::set_max(bvpl_kernel_iterator kernel_iter) 52 { 53 float max_val = 0.0f; 54 kernel_iter.begin(); 55 while (!kernel_iter.isDone()) { 56 bvpl_kernel_dispatch d = *kernel_iter; 57 if ( d.c_>0.0f) 58 max_val += d.c_ * 0.99f; 59 else 60 max_val += d.c_ *0.01f; 61 62 ++kernel_iter; 63 } 64 65 std::cout << "max response : " << max_val << std::endl; 66 max_ = max_val; 67 } 68