28 if( old_uvmap.size() != new_uvmap.size() )
30 <<
"did not expect different uvmap sizes (" << old_uvmap.size()
31 <<
" vs " << new_uvmap.size() <<
")" );
39 size_t const n_pixels = old_uvmap.size();
41 throw std::runtime_error(
"no pixels found in uvmap" );
43 for(
auto i = 0;
i < n_pixels;
i++ )
47 double dx = o.
x - n.
x, dy = o.
y - n.
y;
48 double movement = sqrt( dx * dx + dy * dy );
51 return sum / n_pixels;
61 AC_LOG(
INFO,
" average pixel movement= " << xy_movement );
66 if( xy_movement > max_movement )
68 AC_LOG(
WARNING,
"Pixel movement too big: clipping at limit for iteration (" << iteration_number <<
")= " << max_movement );
71 double const mul_factor = max_movement / xy_movement;
83 new_calib = old_calib + (new_calib - old_calib) * mul_factor;
92 throw std::runtime_error(
"section_map has not been initialized");
99 size_t const n_sections = n_sections_x * n_sections_y;
102 std::vector< size_t > N_per_section(n_sections, 0);
108 [&](
size_t i,
double d_val,
double weight,
double vertex_cost) {});
114 [&](
size_t i,
double d_val,
double weight,
double vertex_cost) {});
117 for (
auto i = 0; i < cost_per_vertex_new.size(); i++)
119 if (d_vals_old[i] != std::numeric_limits<double>::max() && d_vals_new[
i] != std::numeric_limits<double>::max())
122 cost_per_section_diff[section] += (cost_per_vertex_new[
i] - cost_per_vertex_old[
i]);
123 ++N_per_section[section];
127 for (
size_t x = 0;
x < n_sections; ++
x)
130 double & cost = cost_per_section_diff[
x];
131 size_t N = N_per_section[
x];
145 double const new_h_scale = ac_data_in.
h_scale 151 <<
" is not within {step}" 153 <<
" of {old}" << ac_data_in.
h_scale <<
"; clipping to {final}" 154 << new_h_scale <<
" [CLIP-H]" );
155 ac_data_new.
h_scale = new_h_scale;
159 double const new_v_scale = ac_data_in.
v_scale 165 <<
" is not within {step}" 167 <<
" of {old}" << ac_data_in.
v_scale <<
"; clipping to {final}" 168 << new_v_scale <<
" [CLIP-V]" );
169 ac_data_new.
v_scale = new_v_scale;
176 std::vector< double >
res;
188 max_elem = std::max(*it, *(it + 2));
189 min_elem =
std::min(*it, *(it + 2));
193 max_elem = std::max(*(it + 1), *(it + 3));
194 min_elem =
std::min(*(it + 1), *(it + 3));
258 std::vector< double > x_norm;
260 for (
auto i = 0;
i < features.size();
i++)
262 x_norm.push_back((*(features.begin() +
i) - *(svm_model.
mu.begin() +
i)) / (*(svm_model.
sigma.begin() +
i)));
266 auto mu = svm_model.
mu;
267 auto sigma = svm_model.
sigma;
278 std::vector< double > inner_product;
281 for (
auto i = 0;
i < y_sv.size();
i++)
284 for (
auto k = 0; k < x_norm.size(); k++)
286 double res1 = *(x_norm.begin() + k) - *(x_sv[k].
begin() +
i);
287 sum_raw += res1 * res1;
289 double final_sum = exp(-gamma * sum_raw);
290 inner_product.push_back(final_sum);
291 score += *(
alpha.begin() +
i) * *(y_sv.begin() +
i) * final_sum;
322 AC_LOG(
INFO,
"Calibration invalid according to SVM linear model" );
332 AC_LOG(
DEBUG,
"ERROR : Unknown SVM kernel " << model);
358 AC_LOG(
DEBUG,
" average pixel movement from factory calibration= " << xy_movement );
361 AC_LOG( ERROR,
"Calibration has moved too far from the original factory calibration (" << xy_movement <<
" pixels)" );
367 AC_LOG(
DEBUG,
" no factory calibration available; skipping distance check" );
385 AC_LOG(
DEBUG,
" min cost diff= " << min_cost_diff <<
" max= " << max_cost_diff );
398 AC_LOG( ERROR,
"Result DSM parameters are invalid: " << e.
what() );
426 error +=
to_string() <<
" {mode}" << +dsm_params.
model <<
" must be AOT";
429 error +=
to_string() <<
" {H-scale}" << dsm_params.
h_scale <<
" exceeds 1.5% change";
431 error +=
to_string() <<
" {V-scale}" << dsm_params.
v_scale <<
" exceeds [-0.5%-1.5%]";
434 error +=
to_string() <<
" {H-offset}" << dsm_params.
h_offset <<
" is limited to 2 degrees";
436 error +=
to_string() <<
" {V-offset}" << dsm_params.
v_offset <<
" is limited to 2 degrees";
438 if( ! error.empty() )
bool get_final_data_from_bin
std::vector< double > alpha
std::vector< double3 > vertices
std::vector< double3 > orig_vertices
std::vector< double2 > uvmap_t
double max_over_min_depth
calib _optimaized_calibration
double xy_movement_from_origin
std::vector< double > sigma
Video DSM (Digital Sync Module) parameters for calibration (same layout as in FW ac_depth_params) Thi...
svm_model_linear _svm_model_linear
double negative_improvement_sum
std::vector< double > support_vectors_labels
bool valid_by_svm(svm_model model)
double max_xy_movement_per_calibration[3]
std::vector< double > calc_cost_per_vertex(std::vector< double > const &d_vals, z_frame_data const &z_data, yuy2_frame_data const &yuy_data, std::function< void(size_t i, double d_val, double weight, double vertex_cost) > fn)
GLsizei const GLchar *const * string
std::vector< double > sum_weights_per_direction
GLuint GLuint GLfloat weight
bool is_valid(const plane_3d &p)
p_matrix const calc_p_mat() const
std::vector< double > extract_features(decision_params &decision_params)
void clip_ac_scaling(rs2_dsm_params_double const &ac_data_orig, rs2_dsm_params_double &ac_data_new) const
void clip_pixel_movement(size_t iteration_number=0)
GLfloat GLfloat GLfloat alpha
rs2_dsm_params const & get_dsm_params() const
std::vector< double > improvement_per_section
double positive_improvement_sum
std::vector< double3 > _vertices_from_bin
std::vector< double > distribution_per_section_rgb
std::vector< double > distribution_per_section_depth
double max_xy_movement_from_origin
void collect_decision_params(z_frame_data &z_data, yuy2_frame_data &yuy_data)
std::vector< double > sum_weights_per_section
std::vector< double > _extracted_features
double max_global_los_scaling_step
bool svm_rbf_predictor(std::vector< double > &features, svm_model_gaussian &svm_model)
std::vector< double > biliniar_interp(std::vector< double > const &vals, size_t width, size_t height, uvmap_t const &uv)
decision_params _decision_params
calib _factory_calibration
std::vector< byte > section_map
#define AC_LOG(TYPE, MSG)
double xy_movement_from_origin
size_t num_of_sections_for_edge_distribution_y
std::vector< double > edge_weights_per_dir
void validate_dsm_params(struct rs2_dsm_params const &dsm_params)
double calc_correction_in_pixels(std::vector< double2 > const &old_uvmap, std::vector< double2 > const &new_uvmap) const
double min_max_ratio_depth
const char * what() const noexceptoverride
double max_improvement_per_section
uvmap_t get_texture_map(std::vector< double3 > const &points, const calib &cal, const p_matrix &p_mat)
svm_model_gaussian _svm_model_gaussian
std::vector< double > cost_diff_per_section
double min_improvement_per_section
double calc_cost(const z_frame_data &z_data, const yuy2_frame_data &yuy_data, const std::vector< double2 > &uv, std::vector< double > *p_interpolated_edges)
double kernel_param_scale
std::vector< double > edges_IDT
std::vector< double > beta
calib _original_calibration
p_matrix _p_mat_from_bin_opt
std::vector< double > cost_per_section_diff(calib const &old_calib, calib const &new_calib)
std::vector< double > sigma
calib decompose_p_mat(p_matrix p)
std::vector< double > sum_weights_per_section
std::vector< double > weights
std::vector< double > support_vectors[10]
size_t num_of_sections_for_edge_distribution_x
std::string to_string(T value)