4 #include "../include/librealsense2/rs.hpp" 5 #include "../include/librealsense2/rsutil.h" 56 for (
int i = lo;
i *
i <= g && i <= hi; i++)
58 if ((g % i == 0) && (g / i) <= hi)
71 auto height_out =
width;
77 for (
int i = 0;
i < buffer_size; ++
i)
78 buffer[
i] =
new byte[buffer_size * SIZE];
81 for (
int i = 0;
i <= height - buffer_size;
i =
i + buffer_size)
83 for (
int j = 0;
j <= width - buffer_size;
j =
j + buffer_size)
85 for (
int ii = 0;
ii < buffer_size; ++
ii)
87 for (
int jj = 0; jj < buffer_size; ++jj)
89 auto source_index = ((
j + jj) + (width * (
i +
ii))) * SIZE;
90 memcpy((
void*)&(buffer[(buffer_size-1 - jj)][(buffer_size-1 -
ii) * SIZE]), &source[source_index], SIZE);
94 for (
int ii = 0;
ii < buffer_size; ++
ii)
96 auto out_index = (((height_out - buffer_size -
j + 1) * width_out) -
i - buffer_size + (
ii)*width_out);
97 memcpy(&
out[(out_index)*SIZE], (buffer[
ii]), buffer_size * SIZE);
102 for (
int i = 0;
i < buffer_size; ++
i)
120 int occDilationSz = 1;
123 auto pixels_ptr = pix_coord.data();
125 auto uv_map_ptr = uv_map;
126 float maxInLine = -1;
131 for(
int y = 0;
y < points_height; ++
y )
135 int occDilationLeft = 0;
137 for(
int x = 0;
x < points_width; ++
x )
142 if( pixels_ptr->x < maxInLine
143 || ( pixels_ptr->x == maxInLine && ( points_ptr->z - maxZ ) > occZTh ) )
145 *points_ptr = { 0, 0, 0 };
146 occDilationLeft = occDilationSz;
150 maxInLine = pixels_ptr->
x;
151 maxZ = points_ptr->z;
152 if( occDilationLeft > 0 )
154 *points_ptr = { 0, 0, 0 };
171 byte* depth_planes[1];
172 depth_planes[0] = alloc.data();
174 rotate_image_optimized<2>(depth_planes, (
const byte*)(depth.
get_data()), points_width, points_height);
179 for (
int i = 0;
i < rotated_depth_height;
i++)
181 for (
int j = 0;
j < rotated_depth_width;
j++)
186 auto index = (
j + (rotated_depth_width *
i));
187 auto uv_index = ((rotated_depth_height -
i - 1) + (rotated_depth_width -
j - 1) * rotated_depth_height);
188 auto index_right =
index + 1;
192 if (diff_right > scaled_threshold)
194 points_ptr = points + uv_index;
195 uv_map_ptr = uv_map + uv_index;
198 if (
j >= scan_win_size) {
199 maxInLine = (uv_map_ptr - 1 * points_width)->
y;
200 for (
int y = 0;
y <= scan_win_size; ++
y)
202 if (((uv_map_ptr +
y * points_width)->
y < maxInLine))
204 *(points_ptr +
y * points_width) = { 0.f, 0.f };
229 auto depth_points =
points;
230 auto mapped_pix = pix_coord.data();
236 static const float z_threshold = 0.05f;
242 for (
size_t i = 0;
i < points_height;
i++)
244 for (
size_t j = 0;
j < points_width;
j++)
246 if ((depth_points->z > 0.0001f) &&
247 (mapped_pix->x > 0.f) && (mapped_pix->x < mapped_tex_width) &&
248 (mapped_pix->y > 0.f) && (mapped_pix->y < mapped_tex_height))
250 size_t texel_index = (
size_t)(mapped_pix->y)*mapped_tex_width + (
size_t)(mapped_pix->x);
263 mapped_pix = pix_coord.data();
265 auto uv_ptr = uv_map;
268 for (
size_t i = 0;
i < points_height;
i++)
270 for (
size_t j = 0;
j < points_width;
j++)
272 if ((depth_points->z > 0.0001f) &&
273 (mapped_pix->x > 0.f) && (mapped_pix->x < mapped_tex_width) &&
274 (mapped_pix->y > 0.f) && (mapped_pix->y < mapped_tex_height))
276 size_t texel_index = (
size_t)(mapped_pix->y)*mapped_tex_width + (
size_t)(mapped_pix->x);
280 *uv_ptr = { 0.f, 0.f };
GLboolean GLboolean GLboolean b
void set_texel_intrinsics(const rs2_intrinsics &in)
void monotonic_heuristic_invalidation(float3 *points, float2 *uv_map, const std::vector< float2 > &pix_coord, const rs2::depth_frame &depth) const
int get_bytes_per_pixel() const
GLint GLint GLsizei GLsizei GLsizei depth
const void * get_data() const
GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat maxZ
occlusion_rect_type _occlusion_filter
optional_value< rs2_intrinsics > _depth_intrinsics
void comprehensive_invalidation(float3 *points, float2 *uv_map, const std::vector< float2 > &pix_coord) const
GLboolean GLboolean GLboolean GLboolean a
#define ROTATION_BUFFER_SIZE
GLint GLsizei GLsizei height
occlusion_scanning_type _occlusion_scanning
std::vector< float > _texels_depth
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value andis_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
void rotate_image_optimized(byte *dest[], const byte *source, int width, int height)
#define VERTICAL_SCAN_WINDOW_SIZE
GLsizei GLsizei GLchar * source
optional_value< rs2_intrinsics > _texels_intrinsics
void process(float3 *points, float2 *uv_map, const std::vector< float2 > &pix_coord, const rs2::depth_frame &depth) const
#define DEPTH_OCCLUSION_THRESHOLD
GLdouble GLdouble GLint GLint const GLdouble * points
std::string to_string(T value)
int maxDivisorRange(int a, int b, int lo, int hi)