Skip to content

Commit

Permalink
Merge pull request #5734 from rpadak/pull5733
Browse files Browse the repository at this point in the history
Fix what appears to be a copy/paste redundant code problem. Issue #5733
  • Loading branch information
dorodnic authored Feb 6, 2020
2 parents e863bd8 + 9532ef1 commit 1681e6d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
33 changes: 18 additions & 15 deletions src/proc/zero-order.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace librealsense
std::vector <T> get_zo_point_values(const T* frame_data_in, const rs2_intrinsics& intrinsics, int zo_point_x, int zo_point_y, int patch_r)
{
std::vector<T> values;
values.reserve((patch_r + 2) *(patch_r + 2));
values.reserve((patch_r + 2ULL) *(patch_r + 2ULL));

for (auto i = zo_point_y - 1 - patch_r; i <= (zo_point_y + patch_r) && i < intrinsics.height; i++)
{
Expand Down Expand Up @@ -103,7 +103,7 @@ namespace librealsense
return val == 0;
}), values_ir.end());

if (values_rtd.size() == 0 || values_rtd.size() == 0)
if (values_rtd.empty() || values_ir.empty())
return false;

*rtd_zo_value = get_zo_point_value(values_rtd);
Expand All @@ -115,21 +115,23 @@ namespace librealsense
template<class T>
void detect_zero_order(const double * rtd, const uint16_t* depth_data_in, const uint8_t* ir_data, T zero_pixel,
const rs2_intrinsics& intrinsics, const zero_order_options& options,
float zo_value, uint8_t iro_value)
double zo_value, uint8_t iro_value)
{
const int ir_dynamic_range = 256;
const double ir_dynamic_range = 256.0;

auto r = (double)std::exp((ir_dynamic_range / 2.0 + options.threshold_offset - iro_value) / (double)options.threshold_scale);
double r = std::exp((ir_dynamic_range / 2.0 + options.threshold_offset - iro_value) / (double)options.threshold_scale);

auto res = (1 + r);
auto i_threshold_relative = (double)options.ir_threshold / res;
double res = (1.0 + r);
double i_threshold_relative = options.ir_threshold / res;
for (auto i = 0; i < intrinsics.height*intrinsics.width; i++)
{
auto rtd_val = rtd[i];
auto ir_val = ir_data[i];
double rtd_val = rtd[i];
uint8_t ir_val = ir_data[i];

auto zero = (depth_data_in[i] > 0) && (ir_val < i_threshold_relative) &&
(rtd_val > (zo_value - options.rtd_low_threshold)) && (rtd_val < (zo_value + options.rtd_high_threshold));
bool zero = (depth_data_in[i] > 0) &&
(ir_val < i_threshold_relative) &&
(rtd_val > (zo_value - options.rtd_low_threshold)) &&
(rtd_val < (zo_value + options.rtd_high_threshold));

zero_pixel(i, zero);
}
Expand All @@ -141,9 +143,9 @@ namespace librealsense
rs2_intrinsics intrinsics,
const zero_order_options& options, int zo_point_x, int zo_point_y)
{
std::vector<double> rtd(intrinsics.height*intrinsics.width);
z2rtd(vertices, rtd.data(), intrinsics, options.baseline);
double rtd_zo_value;
std::vector<double> rtd(size_t(intrinsics.height)*intrinsics.width);
z2rtd(vertices, rtd.data(), intrinsics, int(options.baseline));
double rtd_zo_value;
uint8_t ir_zo_value;

if (try_get_zo_rtd_ir_point_values(rtd.data(), depth_data_in, ir_data, intrinsics,
Expand All @@ -157,7 +159,8 @@ namespace librealsense
}

zero_order::zero_order(std::shared_ptr<bool_option> is_enabled_opt)
: generic_processing_block("Zero Order Fix"), _first_frame(true), _is_enabled_opt(is_enabled_opt)
: generic_processing_block("Zero Order Fix"), _first_frame(true), _is_enabled_opt(is_enabled_opt),
_resolutions_depth { 0 }
{
auto ir_threshold = std::make_shared<ptr_option<uint8_t>>(
0,
Expand Down
3 changes: 2 additions & 1 deletion src/proc/zero-order.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ namespace librealsense
z_max(Z_MAX_VALUE),
ir_min(IR_MIN_VALUE),
threshold_offset(THRESHOLD_OFFSET),
threshold_scale(THRESHOLD_SCALE)
threshold_scale(THRESHOLD_SCALE),
read_baseline(false)
{}

uint8_t ir_threshold;
Expand Down

0 comments on commit 1681e6d

Please sign in to comment.