#include "depth_guide.h" #include "core/image_utility.hpp" #include "core/imgui_utility.hpp" app_depth_guide::app_depth_guide(const create_config &_conf) { conf = _conf; // initialize object manager OBJ_SAVE(img_color, image_u8c3()); OBJ_SAVE(img_depth, image_f32c1()); OBJ_SAVE(img_bg, image_u8c3()); OBJ_SAVE(img_out, image_u8c4()); OBJ_SIG(img_color)->connect(INT_MIN, [=](obj_name_type _) { OBJ_SAVE(img_bg, OBJ_QUERY(image_u8c3, img_color)); }); // initialize modules auto orb_cam_conf = orb_camera_ui::create_config{ .cf_name = img_color, .df_name = img_depth, .ctx = conf.asio_ctx, .stream = default_cuda_stream, }; orb_cam = std::make_unique(orb_cam_conf); auto bg_viewer_conf = image_viewer::create_config{ .mode = VIEW_COLOR_DEPTH, .flip_y = true, .stream = default_cuda_stream, }; auto &bg_extra_conf = bg_viewer_conf.extra.color_depth; bg_extra_conf.c_name = img_color; bg_extra_conf.d_name = img_depth; bg_viewer = std::make_unique(bg_viewer_conf); auto out_down_conf = viewport_downloader::create_config{ .stream = default_cuda_stream }; out_downloader = std::make_unique(out_down_conf); auto out_streamer_conf = image_streamer::create_config{ .img_name = img_out, .asio_ctx = conf.asio_ctx, .cuda_ctx = conf.cuda_ctx, .stream = default_cuda_stream }; out_streamer = std::make_unique(out_streamer_conf); } void app_depth_guide::show_ui() { auto ctx = conf.asio_ctx; if (ImGui::Begin("Depth Guide Control")) { ImGui::PushItemWidth(200); if (ImGui::CollapsingHeader("Camera")) { auto id_guard = imgui_id_guard("camera"); orb_cam->show(); } if (ImGui::CollapsingHeader("Streamer")) { auto id_guard = imgui_id_guard("streamer"); out_streamer->show(); } if (ImGui::CollapsingHeader("Debug")) { if (ImGui::TreeNode("Background")) { bg_viewer->show(); ImGui::TreePop(); } if (ImGui::TreeNode("Memory Pool")) { if (ImGui::Button("Purge")) { post(*ctx, [] { global_mp.purge(); }); } ImGui::TreePop(); } if (ImGui::TreeNode("Performance")) { ImGui::Text("UI Refresh Rate: %.2fms", perf_timer.query().interval); ImGui::TreePop(); } } ImGui::PopItemWidth(); } ImGui::End(); perf_timer.record(); } void app_depth_guide::render_background() { bg_viewer->render(); // TODO: for test auto bg_img = out_downloader->download_argb(); OBJ_SAVE(img_out, bg_img); }