|
@@ -2,8 +2,6 @@
|
|
|
#include "imgui_utility.hpp"
|
|
#include "imgui_utility.hpp"
|
|
|
#include "render/render_texture.h"
|
|
#include "render/render_texture.h"
|
|
|
|
|
|
|
|
-#include <opencv2/imgproc.hpp>
|
|
|
|
|
-
|
|
|
|
|
void image_viewer::impl::show_color_depth() {
|
|
void image_viewer::impl::show_color_depth() {
|
|
|
ImGui::RadioButton("Color", &chose_index, 0);
|
|
ImGui::RadioButton("Color", &chose_index, 0);
|
|
|
ImGui::SameLine();
|
|
ImGui::SameLine();
|
|
@@ -12,16 +10,17 @@ void image_viewer::impl::show_color_depth() {
|
|
|
ImGui::RadioButton("Both", &chose_index, 2);
|
|
ImGui::RadioButton("Both", &chose_index, 2);
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- auto guard = imgui_disable_guard(!manual_dep_range);
|
|
|
|
|
|
|
+ auto guard = imgui_disable_guard(!depth_conf.manual_depth_range);
|
|
|
static constexpr float dep_hard_min = 0.15; // TODO: config value
|
|
static constexpr float dep_hard_min = 0.15; // TODO: config value
|
|
|
static constexpr float dep_hard_max = 10.0;
|
|
static constexpr float dep_hard_max = 10.0;
|
|
|
- ImGui::DragFloat2("Depth Range", (float *) &dep_range, 0.05f, dep_hard_min, dep_hard_max, "%.2f");
|
|
|
|
|
|
|
+ ImGui::DragFloat2("Depth Range", (float *) &depth_conf.depth_range, 0.05f,
|
|
|
|
|
+ dep_hard_min, dep_hard_max, "%.2f");
|
|
|
}
|
|
}
|
|
|
ImGui::SameLine();
|
|
ImGui::SameLine();
|
|
|
- ImGui::Checkbox("##manual_dep_range", &manual_dep_range);
|
|
|
|
|
|
|
+ ImGui::Checkbox("##manual_dep_range", &depth_conf.manual_depth_range);
|
|
|
|
|
|
|
|
if (chose_index == 2) { // both
|
|
if (chose_index == 2) { // both
|
|
|
- ImGui::SliderFloat("Depth Alpha", &dep_alpha, 0.f, 1.f, "%.2f");
|
|
|
|
|
|
|
+ ImGui::SliderFloat("Depth Alpha", &depth_overlay_alpha, 0.f, 1.f, "%.2f");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -37,54 +36,13 @@ void image_viewer::impl::show() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-simple_rect image_viewer::impl::calc_range(cv::Size size) {
|
|
|
|
|
- return simple_rect{-1, -1, 2, 2}
|
|
|
|
|
- .fit_aspect(size.aspectRatio() /
|
|
|
|
|
- query_viewport_size().aspectRatio());
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void image_viewer::impl::render_rgb_image(const image_u8c3 &img, float alpha) {
|
|
|
|
|
- auto img_info = img->as_cuda_info(conf.stream);
|
|
|
|
|
- img_tex.upload(img_info, conf.stream);
|
|
|
|
|
-
|
|
|
|
|
- auto info = tex_render_info();
|
|
|
|
|
- info.mode = TEX_COLOR_ONLY;
|
|
|
|
|
- info.flip_y = conf.flip_y;
|
|
|
|
|
- info.range = calc_range(img_info.size);
|
|
|
|
|
- info.color.id = img_tex.id;
|
|
|
|
|
- info.color.alpha = alpha;
|
|
|
|
|
- render_texture(info);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void image_viewer::impl::render_color_obj(obj_name_type name, float alpha) {
|
|
|
|
|
- auto img = OBJ_QUERY(image_u8c3, name);
|
|
|
|
|
- if (img == nullptr) [[unlikely]] return;
|
|
|
|
|
- render_rgb_image(img, alpha);
|
|
|
|
|
|
|
+void image_viewer::impl::render_color_obj(obj_name_type name) {
|
|
|
|
|
+ color_render.render(name, color_conf);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void image_viewer::impl::render_depth_obj(obj_name_type name, float alpha) {
|
|
void image_viewer::impl::render_depth_obj(obj_name_type name, float alpha) {
|
|
|
- auto img = OBJ_QUERY(image_f32c1, name);
|
|
|
|
|
- if (img == nullptr) [[unlikely]] return;
|
|
|
|
|
- auto img_mat = img->as_host(conf.stream);
|
|
|
|
|
-
|
|
|
|
|
- // convert to u8c1 // TODO: accelerate with CUDA
|
|
|
|
|
- double min_val, max_val;
|
|
|
|
|
- if (!manual_dep_range) {
|
|
|
|
|
- cv::minMaxLoc(img_mat, &min_val, &max_val, nullptr, nullptr);
|
|
|
|
|
- } else {
|
|
|
|
|
- min_val = dep_range.min * 1000; // m -> mm
|
|
|
|
|
- max_val = dep_range.max * 1000;
|
|
|
|
|
- }
|
|
|
|
|
- auto img_u8 = create_image_info<uchar1>(img_mat.size(), MEM_HOST);
|
|
|
|
|
- img_mat.convertTo(img_u8.as_mat(), CV_8UC1,
|
|
|
|
|
- 255.0 / (max_val - min_val),
|
|
|
|
|
- -min_val / (max_val - min_val));
|
|
|
|
|
-
|
|
|
|
|
- // add false color // TODO: accelerate with CUDA
|
|
|
|
|
- auto img_color = create_image_info<uchar3>(img_mat.size(), MEM_HOST);
|
|
|
|
|
- cv::applyColorMap(img_u8.as_mat(), img_color.as_mat(), cv::COLORMAP_TURBO);
|
|
|
|
|
-
|
|
|
|
|
- render_rgb_image(create_image(img_color), alpha);
|
|
|
|
|
|
|
+ depth_conf.alpha = alpha;
|
|
|
|
|
+ depth_render.render(name, depth_conf);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void image_viewer::impl::render_color_depth() {
|
|
void image_viewer::impl::render_color_depth() {
|
|
@@ -100,7 +58,7 @@ void image_viewer::impl::render_color_depth() {
|
|
|
}
|
|
}
|
|
|
case 2: { // both
|
|
case 2: { // both
|
|
|
render_color_obj(info.c_name);
|
|
render_color_obj(info.c_name);
|
|
|
- render_depth_obj(info.d_name, dep_alpha);
|
|
|
|
|
|
|
+ render_depth_obj(info.d_name, depth_overlay_alpha);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
default: {
|
|
default: {
|
|
@@ -121,9 +79,16 @@ void image_viewer::impl::render() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+image_viewer::impl::impl(create_config _conf) {
|
|
|
|
|
+ conf = _conf;
|
|
|
|
|
+ color_conf.flip_y = conf.flip_y;
|
|
|
|
|
+ color_conf.stream = conf.stream;
|
|
|
|
|
+ depth_conf.flip_y = conf.flip_y;
|
|
|
|
|
+ depth_conf.stream = conf.stream;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
image_viewer::image_viewer(create_config conf)
|
|
image_viewer::image_viewer(create_config conf)
|
|
|
- : pimpl(std::make_unique<impl>()) {
|
|
|
|
|
- pimpl->conf = conf;
|
|
|
|
|
|
|
+ : pimpl(std::make_unique<impl>(conf)) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
image_viewer::~image_viewer() = default;
|
|
image_viewer::~image_viewer() = default;
|