#include "remote_ar_v2.h" #include "image_process_v5/sp_image.h" #include "image_process_v5/osg_helper.h" #include "image_process_v5/image_process.h" #include "core/yaml_utility.hpp" #include "core/imgui_utility.hpp" #include "device_v5/ndi_stray_point_tracker.h" // from sophiar #include "core/local_connection.h" app_remote_ar_v2::app_remote_ar_v2(create_config _conf) : main_conf(std::move(_conf)) { auto conf = main_conf.ext_conf; // OBJ_SIG(left_img_id)->connect([](auto _) { auto img = OBJ_QUERY(sp_image, left_img_id); raise(SIGTRAP); }); // OBJ_SIG(output_img_id)->connect([](auto _) { auto img = OBJ_QUERY(sp_image, left_img_id); raise(SIGTRAP); }); if (true) { auto sub_conf = mvs_camera_ui::create_config{.ctx = main_conf.asio_ctx}; sub_conf.cameras.push_back({.dev_name = LOAD_STR("left_camera_name"), .img_name = left_img_id}); sub_conf.cameras.push_back({.dev_name = LOAD_STR("right_camera_name"), .img_name = right_img_id}); mvs_cam.emplace(sub_conf); // mvs_cam->cap_info_sig.connect([this](auto info) { // out_streamer->change_frame_rate(info.frame_rate); // }); } if (true) { auto uvc_cam_conf = uvc_camera_ui::create_config{ .img_name = uvc_img_id, .ctx = main_conf.asio_ctx, }; uvc_cam.emplace(uvc_cam_conf); } if (true) { auto sub_conf = stereo_output_helper::create_config(); sub_conf.left_name = left_img_id; sub_conf.right_name = right_img_id; sub_conf.out_name = output_img_id; // sub_conf.size = cv::Size(1920, 804); sub_conf.halve_width = false; output_helper.emplace(sub_conf); } if (true) { auto sub_conf = image_viewer_v2::create_config(); sub_conf.items.emplace_back(uvc_img_id, "Endoscope", true); sub_conf.items.emplace_back(left_img_id, "Left", true); sub_conf.items.emplace_back(right_img_id, "Right", true); bg_viewer.emplace(sub_conf); } if (true) { auto sub_conf = image_streamer::create_config(); sub_conf.img_name = output_img_id; sub_conf.asio_ctx = main_conf.asio_ctx; streamer.emplace(sub_conf); } if (true) { auto sub_conf = versatile_saver::create_config(); // sub_conf.items.emplace_back(left_img_id, "Left", true); // sub_conf.items.emplace_back(right_img_id, "Right", true); sub_conf.items.emplace_back(uvc_img_id, "Endoscope", true); saver.emplace(sub_conf); } start_sophiar(LOAD_STR("sophiar_config"), LOAD_STR("sophiar_start_name")); if (true) { auto sub_conf = ndi_stray_point_tracker::create_config(); sub_conf.ip_addr = LOAD_STR("ndi_ip"); sub_conf.port = LOAD_NUMBER(uint16_t, "ndi_port"); create_ndi_stray_points_tracker(sub_conf); } if (true) { auto sub_conf = oblique_calibrator::create_config(); sub_conf.camera_ref_name = LOAD_STR("camera_ref_transform_var"); endo_calib.emplace(sub_conf); } } app_remote_ar_v2::~app_remote_ar_v2() = default; void app_remote_ar_v2::render_background() { bg_viewer->render(); } void app_remote_ar_v2::show_ui() { if (ImGui::Begin("Remote AR Control")) { ImGui::PushItemWidth(200); if (ImGui::CollapsingHeader("MVS Camera")) { auto id_guard = imgui_id_guard("mvs_camera"); mvs_cam->show(); } if (ImGui::CollapsingHeader("UVC Camera")) { auto id_guard = imgui_id_guard("uvc_camera"); uvc_cam->show(); } if (ImGui::CollapsingHeader("Endoscope Calibration")) { auto id_guard = imgui_id_guard("endo_calib"); endo_calib->show_ui(); } if (ImGui::CollapsingHeader("Streamer")) { auto id_guard = imgui_id_guard("streamer"); streamer->show(); } if (ImGui::CollapsingHeader("Debug")) { if (ImGui::TreeNode("Background")) { bg_viewer->show_ui(); ImGui::TreePop(); } if (ImGui::TreeNode("Saver")) { saver->show_ui(); ImGui::TreePop(); } } ImGui::PopItemWidth(); } ImGui::End(); }