Skip to content

Commit

Permalink
histogram generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Arun-Prasad-V committed Apr 23, 2024
1 parent 97be414 commit 4636a38
Show file tree
Hide file tree
Showing 8 changed files with 905 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ include(include/CMakeLists.txt)
include(src/CMakeLists.txt)
include(third-party/CMakeLists.txt)

target_link_libraries( ${LRS_TARGET} PUBLIC rsutils )
target_link_libraries( ${LRS_TARGET} PUBLIC rsutils /opt/intel/oneapi/vtune/2024.0/sdk/lib64/libittnotify.a)

if(BUILD_WITH_DDS)
if (CMAKE_SYSTEM MATCHES "Windows" OR CMAKE_SYSTEM MATCHES "Linux")
Expand Down
1 change: 1 addition & 0 deletions examples/align-gl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ project(RealsenseExamplesAlignGl )

# Save the command line compile commands in the build output
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,stack-size=20000000")

if(BUILD_GRAPHICAL_EXAMPLES AND NOT APPLE)
add_executable(rs-align-gl rs-align-gl.cpp ../../third-party/imgui/imgui.cpp ../../third-party/imgui/imgui_draw.cpp ../../third-party/imgui/imgui_impl_glfw.cpp)
Expand Down
59 changes: 56 additions & 3 deletions examples/align-gl/rs-align-gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "example-imgui.hpp"
#include <librealsense2-gl/rs_processing_gl.hpp> // Include GPU-Processing API

#pragma comment(linker, "/STACK:838860800")

/*
This example introduces the concept of spatial stream alignment.
Expand Down Expand Up @@ -35,6 +36,7 @@ void render_slider(rect location, float* alpha, direction* dir);

int main(int argc, char * argv[]) try
{
rs2::log_to_console( RS2_LOG_SEVERITY_DEBUG );
std::string serial;
if (!device_with_streams({ RS2_STREAM_COLOR,RS2_STREAM_DEPTH }, serial))
return EXIT_SUCCESS;
Expand Down Expand Up @@ -71,15 +73,48 @@ int main(int argc, char * argv[]) try
// that should not be performed in the main loop
rs2::gl::align align_to_depth(RS2_STREAM_DEPTH);
rs2::gl::align align_to_color(RS2_STREAM_COLOR);
rs2::gl::pointcloud pc;
rs2::gl::uploader upload;

float alpha = 0.5f; // Transparancy coefficient
direction dir = direction::to_depth; // Alignment direction
direction dir = direction::to_color; // Alignment direction

while (app) // Application still alive?
{
// Using the align object, we block the application until a frameset is available
rs2::frameset frameset = pipe.wait_for_frames();

std::cout << "Raw frameset: size: " << frameset.size() << std::endl;
for (auto frame : frameset)
{
if(frame.is<rs2::gl::gpu_frame>())
std::cout << frame.get_profile().stream_type() << " " << frame.get_profile().format() << " Yes" << std::endl;
else
std::cout << frame.get_profile().stream_type() << " " << frame.get_profile().format() << " No" << std::endl;
}

/*frameset = c.process(frameset);
std::cout << "After colorizer frameset: size: " << frameset.size() << std::endl;
for (auto frame : frameset)
{
if(frame.is<rs2::gl::gpu_frame>())
std::cout << frame.get_profile().stream_type() << " " << frame.get_profile().format() << " Yes" << std::endl;
else
std::cout << frame.get_profile().stream_type() << " " << frame.get_profile().format() << " No" << std::endl;
}
frameset = pc.process(frameset);
std::cout << "After PC frameset: size: " << frameset.size() << std::endl;
for (auto frame : frameset)
{
if(frame.is<rs2::gl::gpu_frame>())
std::cout << frame.get_profile().stream_type() << " " << frame.get_profile().format() << " Yes" << std::endl;
else
std::cout << frame.get_profile().stream_type() << " " << frame.get_profile().format() << " No" << std::endl;
}*/

if (dir == direction::to_depth)
{
// Align all frames to depth viewport
Expand All @@ -90,11 +125,29 @@ int main(int argc, char * argv[]) try
// Align all frames to color viewport
frameset = align_to_color.process(frameset);
}
std::cout << "After Align frameset: size: " << frameset.size() << std::endl;
for (auto frame : frameset)
{
if(frame.is<rs2::gl::gpu_frame>())
{
std::cout << frame.get_profile().stream_type() << " " << frame.get_profile().format() << " Yes" << std::endl;
auto gpu_frame = frame.as<rs2::gl::gpu_frame>();
auto texture_id = gpu_frame.get_texture_id(0);
//auto hist_texture_id = gpu_frame.get_texture_id(1);
}
else
std::cout << frame.get_profile().stream_type() << " " << frame.get_profile().format() << " No" << std::endl;
}
std::cout << "Arun: Depth Process done" <<std::endl;

frameset = c.process(frameset);
std::cout << "Arun: Colorizer Process done" <<std::endl;

// With the aligned frameset we proceed as usual
auto depth = frameset.get_depth_frame();
auto colorized_depth = frameset.first(RS2_STREAM_DEPTH);
auto color = frameset.get_color_frame();

auto colorized_depth = c.colorize(depth);
//auto colorized_depth = c.colorize(depth);

glEnable(GL_BLEND);
// Use the Alpha channel for blending
Expand Down
Loading

0 comments on commit 4636a38

Please sign in to comment.