|
|
@@ -1,6 +1,7 @@
|
|
|
#include "endo_guide.h"
|
|
|
#include "core/imgui_utility.hpp"
|
|
|
#include "module/camera_augment_helper_v2.h"
|
|
|
+#include "image_process/process_funcs.h"
|
|
|
|
|
|
app_endo_guide::app_endo_guide(const create_config &_conf) {
|
|
|
main_conf = _conf;
|
|
|
@@ -9,6 +10,19 @@ app_endo_guide::app_endo_guide(const create_config &_conf) {
|
|
|
// initialize object manager
|
|
|
OBJ_SAVE(img_color, image_u8c3());
|
|
|
OBJ_SAVE(img_out, image_ptr());
|
|
|
+ OBJ_SAVE(left_raw, image_u8c1());
|
|
|
+ OBJ_SAVE(left_rgb, image_ptr());
|
|
|
+ OBJ_SAVE(left_out, image_ptr());
|
|
|
+ OBJ_SAVE(right_raw, image_u8c1());
|
|
|
+ OBJ_SAVE(right_rgb, image_ptr());
|
|
|
+ OBJ_SAVE(right_out, image_ptr());
|
|
|
+
|
|
|
+ OBJ_SIG(left_raw)->connect([this](auto _) {
|
|
|
+ debayer_raw::call({left_raw, left_rgb, &left_cam.stream});
|
|
|
+ });
|
|
|
+ OBJ_SIG(right_raw)->connect([this](auto _) {
|
|
|
+ debayer_raw::call({right_raw, right_rgb, &right_cam.stream});
|
|
|
+ });
|
|
|
|
|
|
// initialize sophiar
|
|
|
sophiar_thread = std::make_unique<std::thread>([conf_path = LOAD_STR("sophiar_config")] {
|
|
|
@@ -25,13 +39,21 @@ app_endo_guide::app_endo_guide(const create_config &_conf) {
|
|
|
};
|
|
|
uvc_cam = std::make_unique<uvc_camera_ui>(uvc_cam_conf);
|
|
|
|
|
|
+ auto mvs_conf = mvs_camera_ui::create_config{.ctx = main_conf.asio_ctx};
|
|
|
+ mvs_conf.cameras.push_back({.dev_name = LOAD_STR("left_camera_name"), .img_name = left_raw});
|
|
|
+ mvs_conf.cameras.push_back({.dev_name = LOAD_STR("right_camera_name"), .img_name = right_raw});
|
|
|
+ mvs_cam = std::make_unique<mvs_camera_ui>(mvs_conf);
|
|
|
+// mvs_cam->cap_info_sig.connect([this](auto info) {
|
|
|
+// out_streamer->change_frame_rate(info.frame_rate);
|
|
|
+// });
|
|
|
+
|
|
|
auto bg_viewer_conf = image_viewer::create_config{
|
|
|
.mode = VIEW_COLOR_ONLY, .flip_y = true,
|
|
|
.stream = default_cuda_stream,
|
|
|
};
|
|
|
auto &bg_extra_conf = bg_viewer_conf.extra.color;
|
|
|
bg_extra_conf.fmt = COLOR_RGB;
|
|
|
- bg_extra_conf.name = img_out;
|
|
|
+ bg_extra_conf.name = left_out;
|
|
|
bg_viewer = std::make_unique<image_viewer>(bg_viewer_conf);
|
|
|
|
|
|
auto saver_conf = image_saver::create_config{.ctx = main_conf.asio_ctx};
|
|
|
@@ -55,6 +77,11 @@ app_endo_guide::app_endo_guide(const create_config &_conf) {
|
|
|
};
|
|
|
cam_calib = std::make_unique<camera_calibrator>(calib_conf);
|
|
|
|
|
|
+ auto acl_conf = acl_guide::create_config::from_yaml(LOAD_SUB("acl_guide"));
|
|
|
+ acl_conf.sophiar_conn = sophiar_conn.get();
|
|
|
+ acl_conf.ctx = main_conf.asio_ctx;
|
|
|
+ acl = std::make_unique<acl_guide>(acl_conf);
|
|
|
+
|
|
|
auto aug_list_v1 = augment_manager::item_list_from_yaml(LOAD_LIST("augment_list"));
|
|
|
auto aug_list = augment_manager_v2::item_list_from_v1(aug_list_v1, extra_name);
|
|
|
auto aug_conf = augment_manager_v2::create_config{
|
|
|
@@ -63,8 +90,34 @@ app_endo_guide::app_endo_guide(const create_config &_conf) {
|
|
|
};
|
|
|
std::copy(aug_list.begin(), aug_list.end(), std::back_inserter(aug_conf.item_list));
|
|
|
aug_manager = std::make_unique<augment_manager_v2>(aug_conf);
|
|
|
+ aug_manager->pre_render_sig.connect(
|
|
|
+ [this](const auto &info) { acl->pre_render_slot(info); });
|
|
|
|
|
|
auto helper_conf = image_augment_helper_v2::create_config{
|
|
|
+ .img_name = left_rgb, .mask_name = invalid_obj_name,
|
|
|
+ .out_name = left_out, .img_flip_y = false,
|
|
|
+ .manager = aug_manager.get(), .stream = &left_cam.stream,
|
|
|
+ .ctx = main_conf.asio_ctx,
|
|
|
+ .sophiar_conn = sophiar_conn.get(),
|
|
|
+ .transform_var = LOAD_STR("left_camera_transform_var"),
|
|
|
+ };
|
|
|
+ left_cam.aug_helper = std::make_unique<image_augment_helper_v2>(helper_conf);
|
|
|
+ left_cam.aug_helper->set_camera_info(
|
|
|
+ camera_intrinsic::from_yaml(LOAD_SUB("left_camera_info")).to_v0());
|
|
|
+
|
|
|
+ helper_conf = image_augment_helper_v2::create_config{
|
|
|
+ .img_name = right_rgb, .mask_name = invalid_obj_name,
|
|
|
+ .out_name = right_out, .img_flip_y = false,
|
|
|
+ .manager = aug_manager.get(), .stream = &right_cam.stream,
|
|
|
+ .ctx = main_conf.asio_ctx,
|
|
|
+ .sophiar_conn = sophiar_conn.get(),
|
|
|
+ .transform_var = LOAD_STR("right_camera_transform_var"),
|
|
|
+ };
|
|
|
+ right_cam.aug_helper = std::make_unique<image_augment_helper_v2>(helper_conf);
|
|
|
+ right_cam.aug_helper->set_camera_info(
|
|
|
+ camera_intrinsic::from_yaml(LOAD_SUB("right_camera_info")).to_v0());
|
|
|
+
|
|
|
+ helper_conf = image_augment_helper_v2::create_config{
|
|
|
.img_name = img_color, .mask_name = invalid_obj_name,
|
|
|
.out_name = img_out, .img_flip_y = false,
|
|
|
.manager = aug_manager.get(), .stream = default_cuda_stream,
|
|
|
@@ -97,6 +150,11 @@ void app_endo_guide::show_ui() {
|
|
|
uvc_cam->show();
|
|
|
}
|
|
|
|
|
|
+ if (ImGui::CollapsingHeader("MVS Camera")) {
|
|
|
+ auto id_guard = imgui_id_guard("mvs_camera");
|
|
|
+ mvs_cam->show();
|
|
|
+ }
|
|
|
+
|
|
|
if (ImGui::CollapsingHeader("Tracker")) {
|
|
|
if (ImGui::Button("Start")) {
|
|
|
start_tracking();
|
|
|
@@ -114,6 +172,11 @@ void app_endo_guide::show_ui() {
|
|
|
cam_calib->show();
|
|
|
}
|
|
|
|
|
|
+ if (ImGui::CollapsingHeader("Guidance")) {
|
|
|
+ auto id_guard = imgui_id_guard("Guidance");
|
|
|
+ acl->show();
|
|
|
+ }
|
|
|
+
|
|
|
if (ImGui::CollapsingHeader("Debug")) {
|
|
|
if (ImGui::TreeNode("Image Saver")) {
|
|
|
out_saver->show();
|