#include "depth_guide.h" #include "core/image_utility.hpp" #include "core/imgui_utility.hpp" #include "image_process/impl/versatile_convertor_impl.h" 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_depth_fake, image_u8c3()); auto fake_info = fake_color_config{.mode = FAKE_800P, .lower = 200, .upper = 1000}; OBJ_SAVE(img_depth_fake_info, versatile_convertor_impl::encode_config(fake_info)); OBJ_SAVE(img_out, image_u8c4()); // 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 fake_conf = versatile_convertor::create_config{ .in_name = img_depth, .ext_in = img_depth_fake_info, .out_name = img_depth_fake, .cvt_opt = CVT_FAKE_ENCODE_800P, .stream = default_cuda_stream, }; depth_encode = std::make_unique(fake_conf); auto out_conf = stereo_augment_helper::create_config{ .left_name = img_color, .right_name = img_depth_fake, .out_name = img_out, .stream = default_cuda_stream }; out_combiner = std::make_unique(out_conf); out_combiner->fix_ui_config({.follow_image_size=true, .enable_halve_width=false}); 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_streamer_conf = image_streamer::create_config{ .img_name = img_out, .ext_name = img_depth_fake_info, // comment this for tiny player to work .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(); }