Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
b82ef5f
Fix: OpenGL based point cloud is empty if depth mapping texture is no…
vahapt Oct 17, 2024
7015b62
added parameters and changed read-write fields
Noy-Zini Apr 29, 2025
8af377c
Adjustments based on review comments
Noy-Zini May 4, 2025
d5ba687
replaced using strncpy with snprintf
Noy-Zini May 5, 2025
a839fe7
add multiple hubs support, fix failing tests
AviaAv May 4, 2025
47f1de7
handle GMSL location exception
AviaAv May 5, 2025
96e34fb
rs-dds-sensor-proxy register converters based on actual stream index
OhadMeir Apr 23, 2025
15928b2
rs-dds-sensor-proxy convert mjpeg to rgb8
OhadMeir May 6, 2025
4fdf8a9
Fix typo
OhadMeir May 7, 2025
5f8d3ae
rebase and conflicts
alexkunin-gh May 7, 2025
58c1d14
code review fixes
alexkunin-gh May 8, 2025
858a328
Update wrappers/python/examples/readme.md
alexkunin-gh May 8, 2025
5ea176f
Update wrappers/python/examples/align-with-software-device.py
alexkunin-gh May 8, 2025
68b3522
Update wrappers/python/examples/readme.md
alexkunin-gh May 8, 2025
3dfca73
code review fix
alexkunin-gh May 8, 2025
92a6f63
Update wrappers/python/examples/align-with-software-device.py
alexkunin-gh May 8, 2025
4a20574
code review fixes
alexkunin-gh May 8, 2025
6c64095
allow late initialization for platform camera in order not to hold re…
gilpazintel Apr 29, 2025
1b6ea5f
code review changes
gilpazintel May 7, 2025
acd2f76
additional code review changes. remove API method, implement platform…
gilpazintel May 8, 2025
661a461
safe pipe use in hdr long test
remibettan May 12, 2025
caabbef
unit-tests/live/d400/test-hdr-long.py
remibettan May 14, 2025
9101508
remove dead code
remibettan May 15, 2025
a0d4791
test added
remibettan May 12, 2025
68a7c18
cr
remibettan May 13, 2025
624e5aa
cr2
remibettan May 15, 2025
1b17c40
empty commit for tests rerun
remibettan May 15, 2025
02d0816
add gyro and accel as default for D457 and D430 (issue raised in rs-c…
gilpazintel May 8, 2025
30d745f
small adjustment
gilpazintel May 8, 2025
6e2753c
remove default profile tag from gyro and accel in order for them to b…
gilpazintel May 12, 2025
2c53578
allow 63 fps for accel
gilpazintel May 18, 2025
b332261
remove tab delimiters
gilpazintel May 18, 2025
614f317
removing age and gender sample
alexkunin-gh May 18, 2025
7b86b55
This reverts commit for CMakeLists.txt
alexkunin-gh May 18, 2025
616f44a
copilot code review
alexkunin-gh May 19, 2025
cb3a463
disable OCC when RGB streaming
Noy-Zini May 18, 2025
f2622ca
change error display
Noy-Zini May 19, 2025
3060b97
add Tare calib
Noy-Zini May 20, 2025
2fb187b
Handle YUYV format on D457
OhadMeir May 18, 2025
f4cc24d
uyvy_to_yuyv CUDA acceleration
OhadMeir May 18, 2025
fdb7d80
D436i added to SDK - TODO linux adjustments
remibettan Dec 23, 2024
86cac51
adding 36i to linux patch - noble, kernel 6.8
remibettan Dec 25, 2024
65df073
adding 36i to linux patch, jammy, kernel 6.5
remibettan Dec 29, 2024
6168d43
adding 36i linux patch, jammy, kernel 5.19
remibettan Dec 29, 2024
dfefad0
adding 36i linux patch, focal, kernel 5.15
SamerKhshiboun Dec 29, 2024
aded7a3
adding 36i linux patch, jammy, kernel 6.8
remibettan Dec 31, 2024
8478a91
adding 36i to linux patch, jammy, kernel 6.2
remibettan Dec 31, 2024
6123a67
adding 36i linux patch, focal, kernel 5.13
SamerKhshiboun Dec 31, 2024
0e532e3
adding 36i linux patch, focal, kernel 5.11
SamerKhshiboun Dec 31, 2024
61abfc5
cr and removing extrinsics restoring methods from 36i
remibettan Jan 2, 2025
8dae12c
visual preset from 435 depth and 455 color
remibettan Jan 2, 2025
6abf6de
removing the rgb extrinsics restoring, not needed code
remibettan Jan 7, 2025
f12cc0f
436i to 436 in code
remibettan Jan 8, 2025
d9eb5ea
436i to 436 in windows script
remibettan Jan 8, 2025
5c7a315
436i to 436 in linux patches
remibettan Jan 8, 2025
6eb2050
changing min version, and avoiding signed fw update via viewer for d436
remibettan Jan 8, 2025
2db6624
updating d436 minimum fw version
remibettan May 20, 2025
44c3acb
add signal handling to libci
AviaAv May 21, 2025
36d749e
small changes on signals.py
AviaAv May 21, 2025
c9e11ff
disable GLSL for prcessing by default
Nir-Az May 22, 2025
19db33d
PR review updates
Nir-Az May 25, 2025
df4fb76
remove check for port status on toggling ports
AviaAv May 26, 2025
d64c4b8
adding d415_gmsl
remibettan May 20, 2025
b2bd50f
creating mipi device when getting d415_gmsl pid
remibettan May 26, 2025
3824ac0
monochrome feature disabled for d415_gmsl device
remibettan May 27, 2025
22c97fc
FW logs - support dictionary per module
OhadMeir May 21, 2025
751de68
Create unit tests for fw-logs
OhadMeir May 26, 2025
89a963b
Fix typo
OhadMeir May 28, 2025
afc52e2
min fw updated
remibettan Jun 5, 2025
fbc0bd6
d436 avoidance to fw update removed
remibettan Jun 5, 2025
f0e6de5
fixes in playback test
alexkunin-gh Jun 1, 2025
574e387
more efficient solution
alexkunin-gh Jun 2, 2025
4854baf
more efficient solution
alexkunin-gh Jun 2, 2025
dbba93a
code review fixes
alexkunin-gh Jun 10, 2025
d3e9352
Update Windows actions runner image
Noy-Zini Jun 10, 2025
616b1de
fix build errors
Noy-Zini Jun 10, 2025
ba1222b
add load json / save for subpresets
AviaAv May 7, 2025
ce4c4d0
add errors and load file
AviaAv May 25, 2025
abb8e3e
write subpreset as root param
AviaAv Jun 3, 2025
696a01b
renaming
AviaAv Jun 12, 2025
aaf3972
AUTO_HDR def for button
AviaAv Jun 12, 2025
409c06d
enable some tests for D500
AviaAv Jun 10, 2025
fbe41a1
adjust timing for t2enum
AviaAv Jun 10, 2025
d1279c3
allow running tests without DDS device
AviaAv Jun 11, 2025
bfed207
fix UI multi camera advanced mode
Noy-Zini Jun 10, 2025
557ea92
adjustments
Noy-Zini Jun 15, 2025
181f075
fix quick disconnection bug
AviaAv Jun 17, 2025
0713058
add try catch block
AviaAv Jun 17, 2025
518c6ef
added auto hdr unit test and better hubs logs
AviaAv Jun 18, 2025
377692e
rename test
AviaAv Jun 19, 2025
a7910bd
fix pybackend2 compiling
AviaAv Jun 24, 2025
d661e40
simplify includes
AviaAv Jun 24, 2025
fea6a9e
fw compatibility added for mipi devices
remibettan Jul 1, 2025
cda356a
cr
remibettan Jul 1, 2025
6096202
create new rest api wrapper
ArthurRaizIntel Apr 28, 2025
bb42b12
pr fixes
ArthurRaizIntel Jun 22, 2025
8f0f20c
update ref
ashrafk93 Jul 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions src/gl/pointcloud-gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,62 @@ using namespace rs2;
using namespace librealsense;
using namespace librealsense::gl;

static const char* extract_points_text =
"#version 130\n"
"in vec2 textCoords;\n"
"out vec4 output_xyz;\n"
"uniform sampler2D textureSampler;\n"
"uniform vec2 focal;\n"
"uniform vec2 principal;\n"
"uniform float is_bc;\n"
"uniform float coeffs[5];\n"
"\n"
"uniform float depth_scale;\n"
"uniform float width;\n"
"uniform float height;\n"
"\n"
"void main(void) \n"
"{\n"
" float px = textCoords.x * width;\n"
" float py = (1.0 - textCoords.y) * height;\n"
" float x = (px - principal.x) / focal.x;\n"
" float y = (py - principal.y) / focal.y;\n"
" float xo = x;\n"
" float yo = y;\n"
" if(is_bc == 2.0)\n"
" {\n"
" for (int i = 0; i < 10; i++)\n"
" {\n"
" float r2 = x * x + y * y;\n"
" float icdist = 1.0 / (1.0 + ((coeffs[4] * r2 + coeffs[1])*r2 + coeffs[0])*r2);\n"
" float xq = x / icdist;\n"
" float yq = y / icdist;\n"
" float delta_x = 2 * coeffs[2] * xq*yq + coeffs[3] * (r2 + 2 * xq*xq);\n"
" float delta_y = 2 * coeffs[3] * xq*yq + coeffs[2] * (r2 + 2 * yq*yq);\n"
" x = (xo - delta_x)*icdist;\n"
" y = (yo - delta_y)*icdist;\n"
" }\n"
" }\n"
" if (is_bc == 4.0)\n"
" {\n"
" for (int i = 0; i < 10; i++)\n"
" {\n"
" float r2 = x * x + y * y;\n"
" float icdist = 1.0 / (1.0 + ((coeffs[4] * r2 + coeffs[1])*r2 + coeffs[0])*r2);\n"
" float delta_x = 2 * coeffs[2] * x*y + coeffs[3] * (r2 + 2 * x*x);\n"
" float delta_y = 2 * coeffs[3] * x*y + coeffs[2] * (r2 + 2 * y*y);\n"
" x = (xo - delta_x)*icdist;\n"
" y = (yo - delta_y)*icdist;\n"
" }\n"
" }\n"
" vec2 tex = vec2(textCoords.x, 1.0 - textCoords.y);\n"
" vec4 dp = texture(textureSampler, tex);\n"
" float nd = (dp.x + dp.y * 256.0) * 256.0;\n"
" float depth = depth_scale * nd;\n"
" vec4 xyz = vec4(x * depth, y * depth, depth, 1.0);\n"
" output_xyz = xyz;\n"
"}";

static const char* project_fragment_text =
"#version 130\n"
"in vec2 textCoords;\n"
Expand Down Expand Up @@ -234,6 +290,58 @@ static const char* occulution_fragment_text =
" }\n"
"}";

class extract_points_shader : public texture_2d_shader
{
public:
extract_points_shader()
: texture_2d_shader(shader_program::load(
texture_2d_shader::default_vertex_shader(),
extract_points_text,
"position", "textureCoords",
"output_xyz", nullptr))
{
_focal_location = _shader->get_uniform_location("focal");
_principal_location = _shader->get_uniform_location("principal");
_is_bc_location = _shader->get_uniform_location("is_bc");
_coeffs_location = _shader->get_uniform_location("coeffs");

_depth_scale_location = _shader->get_uniform_location("depth_scale");
_width_location = _shader->get_uniform_location("width");
_height_location = _shader->get_uniform_location("height");
}

void set_size(int w, int h)
{
_shader->load_uniform(_width_location, (float)w);
_shader->load_uniform(_height_location, (float)h);
}

void set_intrinsics(const rs2_intrinsics& intr)
{
rs2::float2 focal{ intr.fx, intr.fy };
rs2::float2 principal{ intr.ppx, intr.ppy };
_shader->load_uniform(_focal_location, focal);
_shader->load_uniform(_principal_location, principal);
_shader->load_uniform(_is_bc_location, (float)(int)intr.model);
glUniform1fv(_coeffs_location, 5, intr.coeffs);
}

void set_depth_scale(float depth_scale)
{
_shader->load_uniform(_depth_scale_location, depth_scale);
}

private:
int _focal_location;
int _principal_location;
int _is_bc_location;
int _coeffs_location;
int _depth_scale_location;

int _width_location;
int _height_location;
};

class project_shader : public texture_2d_shader
{
public:
Expand Down Expand Up @@ -375,6 +483,7 @@ void pointcloud_gl::cleanup_gpu_resources()
{
_projection_renderer.reset();
_occu_renderer.reset();
_point_cloud_processor.reset();
_enabled = 0;
}
void pointcloud_gl::create_gpu_resources()
Expand All @@ -383,6 +492,7 @@ void pointcloud_gl::create_gpu_resources()
{
_projection_renderer = std::make_shared<visualizer_2d>(std::make_shared<project_shader>());
_occu_renderer = std::make_shared<visualizer_2d>(std::make_shared<occulution_shader>());
_point_cloud_processor = std::make_shared<visualizer_2d>(std::make_shared<extract_points_shader>());
}
_enabled = glsl_enabled() ? 1 : 0;
}
Expand Down Expand Up @@ -423,12 +533,97 @@ const librealsense::float3* pointcloud_gl::depth_to_points(
_depth_data = depth_frame;
_depth_scale = depth_frame.get_units();
_depth_intr = depth_intrinsics;

//if map_texture is false (e.g. headless operation)
if(!_extrinsics.has_value() || !_other_intrinsics.has_value())
{
auto vid_frame = depth_frame.as<rs2::video_frame>();
auto height = vid_frame.get_height();
auto width = vid_frame.get_width();
get_gl_points(output, width, height);
}
//else, defer point extraction as it will be calculated along with texture mapping process
}, [&]{
_enabled = false;
});
return nullptr;
}

void pointcloud_gl::get_gl_points(rs2::points& output, const unsigned int width, const unsigned int height)
{
auto viz = _point_cloud_processor;
auto frame_ref = (frame_interface*)output.get();

auto gf = dynamic_cast<gpu_addon_interface*>(frame_ref);

if (!gf)
throw std::runtime_error("Frame interface is not gpu addon interface");

uint32_t depth_texture;

if (auto input_frame = _depth_data.as<rs2::gl::gpu_frame>())
{
depth_texture = input_frame.get_texture_id(0);
}
else
{
glGenTextures(1, &depth_texture);
glBindTexture(GL_TEXTURE_2D, depth_texture);
auto depth_data = _depth_data.get_data();
glTexImage2D(GL_TEXTURE_2D, 0, GL_RG8, width, height, 0, GL_RG, GL_UNSIGNED_BYTE, depth_data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}

// rendering output
uint32_t output_xyz;

gf->get_gpu_section().output_texture(0, &output_xyz, TEXTYPE_XYZ);

// fbo1 output
uint32_t fbo1_xyz = output_xyz;

// fbo1 - projection rendering
fbo fbo1(width, height);

glBindTexture(GL_TEXTURE_2D, fbo1_xyz);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, width, height, 0, GL_RGB, GL_FLOAT, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fbo1_xyz, 0);
glBindTexture(GL_TEXTURE_2D, 0);

gf->get_gpu_section().set_size(width, height);

fbo1.bind();

GLuint attachments[2] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
glDrawBuffers(2, attachments);

glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);

auto& shader = (extract_points_shader&)viz->get_shader();
shader.begin();
shader.set_depth_scale(_depth_scale);
shader.set_intrinsics(_depth_intr);
shader.set_size(width, height);

viz->draw_texture(depth_texture);
shader.end();

fbo1.unbind();

glBindTexture(GL_TEXTURE_2D, 0);
if (!_depth_data.is<rs2::gl::gpu_frame>())
{
glDeleteTextures(1, &depth_texture);
}
}

void pointcloud_gl::get_texture_map(
rs2::points output,
const librealsense::float3* points,
Expand Down
4 changes: 4 additions & 0 deletions src/gl/pointcloud-gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ namespace librealsense
const rs2_intrinsics &other_intrinsics,
const rs2_extrinsics& extr,
float2* pixels_ptr) override;
void get_gl_points(rs2::points& output,
const unsigned int width,
const unsigned int height);
rs2::points allocate_points(
const rs2::frame_source& source,
const rs2::frame& f) override;
Expand All @@ -39,6 +42,7 @@ namespace librealsense

std::shared_ptr<rs2::visualizer_2d> _projection_renderer;
std::shared_ptr<rs2::visualizer_2d> _occu_renderer;
std::shared_ptr<rs2::visualizer_2d> _point_cloud_processor;

rs2::depth_frame _depth_data;
float _depth_scale;
Expand Down
Loading