#include "depth_guide_controller_impl.h" #include "core/imgui_utility.hpp" depth_guide_controller::impl::impl(create_config _conf) { conf = _conf; } void depth_guide_controller::impl::build(render_config r_conf) { auto obj_ts = OBJ_TS(conf.img_in); if (obj_ts <= last_ts) return; auto img_in = OBJ_QUERY(image_u8c3, conf.img_in); auto depth_in = OBJ_QUERY(image_f32c1, conf.depth_in); if (img_in == nullptr || depth_in == nullptr) return; img_in->sync_create(r_conf.stream); depth_in->sync_create(r_conf.stream); auto out_info = create_image_info(img_in->size(), MEM_CUDA); auto depth_conf = depth_mask_config{ .lower = depth_range.min * 1000.f, // mm -> m .upper = depth_range.max * 1000.f, }; call_depth_mask( img_in->as_cuda(r_conf.stream), depth_in->as_cuda(r_conf.stream), out_info.as_cuda(), depth_conf, r_conf.stream->cuda); out_img = create_image(out_info, r_conf.stream); if (conf.img_out != invalid_obj_name) { OBJ_SAVE(conf.img_out, out_img); } last_ts = obj_ts; } void depth_guide_controller::impl::render(render_config r_conf) { build(r_conf); if (out_img == nullptr) return; auto ren_conf = color_image_render::config_type{ .fmt = COLOR_RGBA, .flip_y = true, .stream = r_conf.stream, }; ren.render_rgba(out_img->as_info(), ren_conf); } void depth_guide_controller::impl::show() { static constexpr float dep_hard_min = 0.15; // TODO: config value static constexpr float dep_hard_max = 1.00; ImGui::DragFloat2("Depth Range (m)", (float *) &depth_range, 0.02f, dep_hard_min, dep_hard_max, "%.2f"); } depth_guide_controller::depth_guide_controller(create_config conf) : pimpl(std::make_unique(conf)) { } depth_guide_controller::~depth_guide_controller() = default; void depth_guide_controller::render(render_config conf) { pimpl->render(conf); } void depth_guide_controller::show() { pimpl->show(); }