18 static const float FOV_H = 0.610865f;
19 static const float FOV_V = 0.479966f;
28 return ( std::abs( x ) < std::numeric_limits< float >::epsilon() );
47 std::vector< float > _filt_dist_arr(
_dist_queue.size() );
52 _filt_dist_arr.begin(),
55 _filt_dist_arr.resize( new_end - _filt_dist_arr.begin() );
57 if( 0 == _filt_dist_arr.size() )
58 throw std::logic_error(
"reflectivity N/A, not enough data was collected" );
60 float sum = std::accumulate( _filt_dist_arr.begin(), _filt_dist_arr.end(), 0.0f );
61 float mean = sum / _filt_dist_arr.size();
63 float standard_deviation = 9999.0f;
68 for(
auto val : _filt_dist_arr )
69 variance += std::pow(
val - mean, 2.0
f );
71 variance = variance / _filt_dist_arr.size();
72 standard_deviation = std::sqrt( variance );
76 auto range = mean / 1000.0f;
79 auto nest = raw_noise_estimation / 16.0f;
80 auto normalized_ir = 0.0f;
82 normalized_ir = std::pow( std::pow( ir_val, 2.0
f ) - std::pow( nest, 2.0
f ), 0.5
f );
84 auto ref_from_ir = 0.0f;
85 auto ref_from_std = 0.0f;
88 auto i_dist_85 = 0.0f;
89 auto s_dist_85 = 0.0f;
96 if( normalized_ir < 70.0f )
102 i_dist_85 = 6.75f * std::exp( -0.012f * normalized_ir );
106 if( 0.0f < i_dist_85 )
108 i_ref =
static_cast<float>(0.85f * std::pow( (
range / i_dist_85 ), 2 ));
122 if( standard_deviation >= 1.5f || standard_deviation <= 10.f )
124 if( standard_deviation > 2.5f )
132 s_dist_85 = ( 2.25f * (
std::log( standard_deviation ) ) + 1.56f ) * max_usable_range
136 s_ref = 0.85f * std::pow( (
range / s_dist_85 ), 2.0f );
139 ref_from_std = ref_from_std * 0.75f;
153 throw std::logic_error(
"reflectivity N/A" );
156 ref = ( i_ref * ref_from_ir + s_ref * ref_from_std ) / ( ref_from_ir + ref_from_std );
161 else if(
ref >= 0.7f )
163 else if(
ref >= 0.55f )
165 else if(
ref >= 0.4f )
167 else if(
ref >= 0.25f )
177 if( x_in_image >= 0 && x_in_image < VGA_WIDTH && y_in_image >= 0 && y_in_image <
VGA_HEIGHT )
182 auto dist_r = dist_z * std::sqrt( 1.0
f + (std::pow( 2.0
f * std::tan( x_ang ), 2.0
f ) + std::pow( 2.0
f * std::tan( y_ang ), 2.0
f ) ) / 4.0
f );
bool is_history_full() const
float get_reflectivity(float raw_noise_estimation, float max_usable_range, float ir_val) const
static const int VGA_HALF_WIDTH
static const float LONG_THERMAL
static const int VGA_HEIGHT
std::deque< float > _dist_queue
static bool is_close_to_zero(float x)
float max_usable_range(float nest)
static const int VGA_HALF_HEIGHT
float get_samples_ratio() const
static const int VGA_WIDTH
static const float INDOOR_MAX_RANGE
static const float MAX_RANGE_IN_UNIT
void log(std::string message)
size_t history_size() const
void add_depth_sample(float depth_val, int x_in_image, int y_in_image)
size_t history_capacity() const
static const int NINETY_FIVE_PERCENT_OF_STD_PERIOD
static const size_t N_STD_FRAMES