Go to the documentation of this file.
20 color_map(std::map<float, float3> map,
int steps = 4000) : _map(map)
27 for (
size_t i = 0;
i <
values.size();
i++)
38 if (_max == _min)
return *_data;
39 auto t = (
value - _min) / (_max - _min);
41 return _data[(int)(
t * (_size - 1))];
47 const std::vector<float3>&
get_cache()
const {
return _cache; }
52 return b *
t +
a * (1 -
t);
59 if (_map.find(
value) != _map.end())
return _map.at(
value);
61 if (
value < _map.begin()->first)
return _map.begin()->second;
62 if (
value > _map.rbegin()->first)
return _map.rbegin()->second;
64 auto lower = _map.lower_bound(
value) == _map.begin() ? _map.begin() : --(_map.lower_bound(
value));
65 auto upper = _map.upper_bound(
value);
67 auto t = (
value - lower->first) / (upper->first - lower->first);
68 auto c1 = lower->second;
69 auto c2 = upper->second;
75 if (_map.size() == 0)
return;
77 _min = _map.begin()->first;
78 _max = _map.rbegin()->first;
80 _cache.resize(steps + 1);
81 for (
int i = 0;
i <= steps;
i++)
83 auto t = (float)
i / steps;
84 auto x = _min +
t*(_max - _min);
89 _size = _cache.size();
90 _data = _cache.data();
93 std::map<float, float3>
_map;
107 memset(hist, 0, MAX_DEPTH *
sizeof(
int));
108 for (
auto i = 0;
i <
w*
h; ++
i)
110 T depth_val = depth_data[
i];
111 int index =
static_cast< int >( depth_val );
115 for (
auto i = 2;
i < MAX_DEPTH; ++
i) hist[
i] += hist[
i - 1];
118 static const int MAX_DEPTH = 0x10000;
119 static const int MAX_DISPARITY = 0x2710;
127 template<
typename T,
typename F>
130 auto cm = _maps[_map_index];
133 auto d = depth_data[
i];
134 colorize_pixel(rgb_data,
i, cm,
d, coloring_func);
138 template<
typename T,
typename F>
143 auto f = coloring_func(
data);
151 rgb_data[
idx * 3 + 0] = 0;
152 rgb_data[
idx * 3 + 1] = 0;
153 rgb_data[
idx * 3 + 2] = 0;
170 float _depth_units = 0.f;
171 float _d2d_convert_factor = 0.f;
float3 calc(float value) const
float3 get(float value) const
color_map(const std::vector< float3 > &values, int steps=4000)
GLboolean GLboolean GLboolean b
float lerp(float a, float b, float t)
std::vector< color_map * > _maps
#define LRS_EXTENSION_API
void initialize(int steps)
std::vector< int > _histogram
std::map< float, float3 > _map
const std::vector< float3 > & get_cache() const
rs2::stream_profile _source_stream_profile
GLint GLsizei GLsizei height
def process_frame(frame, frame_source)
GLdouble GLdouble GLdouble w
GLboolean GLboolean GLboolean GLboolean a
GLuint const GLchar * name
static void update_histogram(int *hist, const T *depth_data, int w, int h)
void colorize_pixel(uint8_t *rgb_data, int idx, color_map *cm, T data, F coloring_func)
GLsizei GLsizei GLchar * source
void make_rgb_data(const T *depth_data, uint8_t *rgb_data, int width, int height, F coloring_func)
rs2::stream_profile _target_stream_profile
float3 lerp(const float3 &a, const float3 &b, float t) const
GLsizei const GLfloat * values
std::vector< float3 > _cache
color_map(std::map< float, float3 > map, int steps=4000)
librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Fri Aug 2 2024 08:30:01