diff --git a/modules/gpu/src/cuda/constantspacebp.cu b/modules/gpu/src/cuda/constantspacebp.cu index 460123d670..a404e0eaed 100644 --- a/modules/gpu/src/cuda/constantspacebp.cu +++ b/modules/gpu/src/cuda/constantspacebp.cu @@ -160,21 +160,21 @@ namespace csbp_krnls for(int i = 0; i < nr_plane; i++) { - T fmin_ = data_cost[i * cdisp_step1]; - int id = i; - for(int j = 0; j < nr_plane; j++) + T minimum = TypeLimits::max(); + int id = 0; + for(int d = 0; d < cndisp; d++) { - T cur = data_cost[j * cdisp_step1]; - if(cur < fmin_) + T cur = data_cost[d * cdisp_step1]; + if(cur < minimum) { - fmin_ = cur; - id = j; + minimum = cur; + id = d; } } - data_cost_selected[i * cdisp_step1] = fmin_; + data_cost_selected[i * cdisp_step1] = minimum; selected_disparity[i * cdisp_step1] = id; - data_cost [id * cdisp_step1] = TypeLimits::max();; + data_cost [id * cdisp_step1] = TypeLimits::max(); } } }