hole-filling-filter.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2018 Intel Corporation. All Rights Reserved.
3 // Implementation details of hole-filling modes
4 
5 #include "../include/librealsense2/hpp/rs_sensor.hpp"
6 #include "../include/librealsense2/hpp/rs_processing.hpp"
7 #include "option.h"
8 #include "environment.h"
9 #include "context.h"
10 #include "software-device.h"
11 #include "proc/synthetic-stream.h"
13 
14 namespace librealsense
15 {
16  // The holes filling mode
21 
23  depth_processing_block("Hole Filling Filter"),
24  _width(0), _height(0), _stride(0), _bpp(0),
25  _extension_type(RS2_EXTENSION_DEPTH_FRAME),
26  _current_frm_size_pixels(0),
27  _hole_filling_mode(hole_fill_def)
28  {
31 
32  auto hole_filling_mode = std::make_shared<ptr_option<uint8_t>>(
37  &_hole_filling_mode, "Hole Filling mode");
38 
39  hole_filling_mode->set_description(hf_fill_from_left, "Fill from Left");
40  hole_filling_mode->set_description(hf_farest_from_around, "Farest from around");
41  hole_filling_mode->set_description(hf_nearest_from_around, "Nearest from around");
42 
43  hole_filling_mode->on_set([this, hole_filling_mode](float val)
44  {
45  std::lock_guard<std::mutex> lock(_mutex);
46 
47  if (!hole_filling_mode->is_valid(val))
49  << "Unsupported mode for hole filling selected: value " << val << " is out of range.");
50 
51  _hole_filling_mode = static_cast<uint8_t>(val);
52  });
53 
54  register_option(RS2_OPTION_HOLES_FILL, hole_filling_mode);
55  }
56 
58  {
60  auto tgt = prepare_target_frame(f, source);
61 
62  // Hole filling pass
64  apply_hole_filling<float>(const_cast<void*>(tgt.get_data()));
65  else
66  apply_hole_filling<uint16_t>(const_cast<void*>(tgt.get_data()));
67 
68  return tgt;
69  }
70 
72  {
74  {
77 
79  _bpp = (_extension_type == RS2_EXTENSION_DISPARITY_FRAME) ? sizeof(float) : sizeof(uint16_t);
81  _width = vp.width();
82  _height = vp.height();
83  _stride = _width * _bpp;
85 
86  }
87  }
88 
90  {
91  // Allocate and copy the content of the input data to the target
93 
94  memmove(const_cast<void*>(tgt.get_data()), f.get_data(), _current_frm_size_pixels * _bpp);
95  return tgt;
96  }
97 
98 }
static const textual_icon lock
Definition: model-views.h:218
const uint8_t hole_fill_min
stream_profile get_profile() const
Definition: rs_frame.hpp:557
const void * get_data() const
Definition: rs_frame.hpp:545
unsigned short uint16_t
Definition: stdint.h:79
unsigned char uint8_t
Definition: stdint.h:78
void update_configuration(const rs2::frame &f)
void register_option(rs2_option id, std::shared_ptr< option > option)
Definition: options.h:86
rs2::frame process_frame(const rs2::frame_source &source, const rs2::frame &f) override
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
GLuint GLfloat * val
GLdouble f
bool is() const
Definition: rs_frame.hpp:570
const uint8_t hole_fill_max
rs2::frame prepare_target_frame(const rs2::frame &f, const rs2::frame_source &source)
rs2_format format() const
Definition: rs_frame.hpp:44
const rs2_stream_profile * get() const
Definition: rs_frame.hpp:137
GLsizei GLsizei GLchar * source
const uint8_t hole_fill_def
stream_profile clone(rs2_stream type, int index, rs2_format format) const
Definition: rs_frame.hpp:63
const uint8_t hole_fill_step
std::string to_string(T value)


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:16