| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- #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_camera_ui>(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<versatile_convertor>(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<stereo_augment_helper>(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<image_viewer>(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<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();
- }
|