31 auto rtd = sqrt(
x*
x +
y*
y +
z*
z) + sqrt((
x - baseline) *(
x - baseline) +
y*
y + z*z);
47 values.reserve((patch_r + 2ULL) *(patch_r + 2ULL));
49 for (
auto i = zo_point_y - 1 - patch_r;
i <= (zo_point_y + patch_r) &&
i < intrinsics.
height;
i++)
51 for (
auto j = (zo_point_x - 1 - patch_r);
j <= (zo_point_x + patch_r) &&
i < intrinsics.
width;
j++)
53 values.push_back(frame_data_in[
i*intrinsics.
width +
j]);
65 if ((values.size()) % 2 == 0)
67 return (values[values.size() / 2 - 1] + values[values.size() / 2]) / 2;
69 else if (values.size() > 0)
70 return values[values.size() / 2];
77 double *rtd_zo_value,
uint8_t* ir_zo_data)
87 for (
auto i = 0;
i < values_rtd.size();
i++)
89 if ((values_z[
i] / 8.0) > options.
z_max || (values_ir[
i] < options.
ir_min))
96 values_rtd.erase(std::remove_if(values_rtd.begin(), values_rtd.end(), [](
double val)
99 }), values_rtd.end());
101 values_ir.erase(std::remove_if(values_ir.begin(), values_ir.end(), [](
uint8_t val)
104 }), values_ir.end());
106 if (values_rtd.empty() || values_ir.empty())
118 double zo_value,
uint8_t iro_value)
120 const double ir_dynamic_range = 256.0;
124 double res = (1.0 +
r);
128 double rtd_val = rtd[
i];
131 bool zero = (depth_data_in[
i] > 0) &&
132 (ir_val < i_threshold_relative) &&
146 std::vector<double> rtd(
size_t(intrinsics.
height)*intrinsics.
width);
152 options,zo_point_x, zo_point_y, &rtd_zo_value, &ir_zo_value))
155 options, rtd_zo_value, ir_zo_value);
163 _resolutions_depth { 0 }
165 auto ir_threshold = std::make_shared<ptr_option<uint8_t>>(
172 ir_threshold->on_set([ir_threshold](
float val)
174 if (!ir_threshold->is_valid(val))
176 <<
"Unsupported ir threshold " << val <<
" is out of range.");
181 auto rtd_high_threshold = std::make_shared<ptr_option<uint16_t>>(
187 "RTD high threshold");
188 rtd_high_threshold->on_set([rtd_high_threshold](
float val)
190 if (!rtd_high_threshold->is_valid(val))
192 <<
"Unsupported rtd high threshold " << val <<
" is out of range.");
197 auto rtd_low_threshold = std::make_shared<ptr_option<uint16_t>>(
203 "RTD high threshold");
204 rtd_low_threshold->on_set([rtd_low_threshold](
float val)
206 if (!rtd_low_threshold->is_valid(val))
208 <<
"Unsupported rtd low threshold " << val <<
" is out of range.");
213 auto baseline = std::make_shared<ptr_option<float>>(
224 <<
"Unsupported patch size value " << val <<
" is out of range.");
228 auto patch_size = std::make_shared<ptr_option<int>>(
235 patch_size->on_set([patch_size](
float val)
237 if (!patch_size->is_valid(val))
239 <<
"Unsupported patch size value " << val <<
" is out of range.");
243 auto zo_max = std::make_shared<ptr_option<int>>(
250 zo_max->on_set([zo_max](
float val)
252 if (!zo_max->is_valid(val))
254 <<
"Unsupported patch size value " << val <<
" is out of range.");
258 auto ir_min = std::make_shared<ptr_option<int>>(
264 "Minimum IR value (saturation)");
265 ir_min->on_set([ir_min](
float val)
267 if (!ir_min->is_valid(val))
269 <<
"Unsupported patch size value " << val <<
" is out of range.");
273 auto offset = std::make_shared<ptr_option<int>>(
282 if (!
offset->is_valid(val))
284 <<
"Unsupported patch size value " << val <<
" is out of range.");
288 auto scale = std::make_shared<ptr_option<int>>(
297 if (!
scale->is_valid(val))
299 <<
"Unsupported patch size value " << val <<
" is out of range.");
306 switch (static_cast<zero_order_invalidation_options>(option))
309 return "IR Threshold";
311 return "RTD high Threshold";
313 return "RTD Low Threshold";
319 return "ZO max value";
321 return "IR min value";
323 return "Threshold offset";
325 return "Threshold scale";
335 if(
auto l5 = dynamic_cast<l500_depth_sensor_interface*>(
sensor.get()))
343 auto extendable = As<librealsense::extendable_interface>(
sensor);
346 return l5->read_baseline();
359 if (
auto l5 = dynamic_cast<l500_depth_sensor_interface*>(
sensor.get()))
366 auto extendable = As<librealsense::extendable_interface>(
sensor);
373 throw std::runtime_error(
"didn't succeed to get intrinsics");
387 if (!is_enabled->is_true())
391 std::vector<rs2::frame>
result;
396 LOG_DEBUG(
"ZO values: "<<zo.first<<
", "<<zo.second);
407 LOG_ERROR(
"Frame received is not a frameset.");
418 auto ir_frame =
data.get_infrared_frame();
426 if (confidence_frame)
438 auto depth_output = (
uint16_t*)depth_out.get_data();
441 if (confidence_frame)
449 (
const uint8_t*)ir_frame.get_data(),
450 [&](
int index,
bool zero)
454 if (confidence_frame)
456 confidence_output[
index] = zero ? 0 : ((
uint8_t*)confidence_frame.get_data())[index];
463 result.push_back(depth_out);
464 if (confidence_frame)
465 result.push_back(confidence_out);
470 if (confidence_frame)
471 result.push_back(confidence_frame);
484 if (!
set.get_depth_frame() || !
set.get_infrared_frame())
515 results.push_back(f);
rs2::stream_profile _source_profile_depth
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
rs2::frame process_frame(const rs2::frame_source &source, const rs2::frame &f) override
static ivcam2::intrinsic_params get_intrinsic_params(const uint32_t width, const uint32_t height, ivcam2::intrinsic_depth intrinsic)
GLenum GLenum GLenum GLenum GLenum scale
std::weak_ptr< bool_option > _is_enabled_opt
T get_zo_point_value(std::vector< T > &values)
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)
stream_profile get_profile() const
bool should_process(const rs2::frame &frame) override
const void * get_data() const
bool try_get_zo_rtd_ir_point_values(const double *rtd, const uint16_t *depth_data_in, const uint8_t *ir_data, const rs2_intrinsics &intrinsics, const zero_order_options &options, int zo_point_x, int zo_point_y, double *rtd_zo_value, uint8_t *ir_zo_data)
rs2::stream_profile _target_profile_confidence
zero_order(std::shared_ptr< bool_option > is_enabled_opt=nullptr)
void sort(sort_type m_sort_type, const std::string &in, const std::string &out)
rs2::frame prepare_output(const rs2::frame_source &source, rs2::frame input, std::vector< rs2::frame > results) override
void register_option(rs2_option id, std::shared_ptr< option > option)
frame allocate_video_frame(const stream_profile &profile, const frame &original, int new_bpp=0, int new_width=0, int new_height=0, int new_stride=0, rs2_extension frame_type=RS2_EXTENSION_VIDEO_FRAME) const
double get_pixel_rtd(const rs2::vertex &v, int baseline)
bool zero_order_invalidation(const uint16_t *depth_data_in, const uint8_t *ir_data, T zero_pixel, const rs2::vertex *vertices, rs2_intrinsics intrinsics, const zero_order_options &options, int zo_point_x, int zo_point_y)
uint16_t rtd_high_threshold
points calculate(frame depth) const
frame allocate_composite_frame(std::vector< frame > frames) const
void z2rtd(const rs2::vertex *vertices, double *rtd, const rs2_intrinsics &intrinsics, int baseline)
GLsizei const GLfloat * values
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, double zo_value, uint8_t iro_value)
std::pair< int, int > get_zo_point(const rs2::frame &frame)
rs2_format format() const
zero_order_invalidation_options
static const struct @18 vertices[3]
rs2::stream_profile _source_profile_confidence
GLenum GLenum GLenum input
ivcam2::intrinsic_params try_read_intrinsics(const rs2::frame &frame)
const rs2_stream_profile * get() const
bool try_read_baseline(const rs2::frame &frame)
GLsizei GLsizei GLchar * source
zero_order_options _options
const char * get_option_name(rs2_option option) const override
uint16_t rtd_low_threshold
virtual const char * get_option_name(rs2_option option) const override
rs2_stream stream_type() const
rs2::stream_profile _target_profile_depth
stream_profile clone(rs2_stream type, int index, rs2_format format) const
std::string to_string(T value)