| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #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_camera_ui>(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<image_viewer>(bg_viewer_conf);
- auto out_down_conf = viewport_downloader::create_config{
- .stream = default_cuda_stream
- };
- out_downloader = std::make_unique<viewport_downloader>(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<image_streamer>(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);
- }
|