Browse Source

Fixed some error.

jcsyshc 1 year ago
parent
commit
90f7d64a4c

+ 7 - 2
src/image_process/impl/camera_calibrator.cpp

@@ -316,7 +316,7 @@ namespace camera_calibrator_impl {
         result_mat = glm::inverse(calib_hand_eye());
         SPDLOG_INFO("Estimated temporal offset is {}ms", result_ts_offset / 1000);
 
-        auto err_val = evaluate_hand_eye(result_mat);
+        auto err_val = evaluate_hand_eye(glm::inverse(result_mat));
         obj_reproj_err = err_val[0];
         SPDLOG_INFO("Average 3D projection error is {:.2f}mm", obj_reproj_err);
         img_reproj_err = err_val[1];
@@ -579,7 +579,12 @@ void camera_calibrator::impl::render() {
 
     auto size = query_viewport_size();
     nvgBeginFrame(vg, size.width, size.height, 1.0f);
-    auto closer = sg::make_scope_guard([this] { nvgEndFrame(vg); });
+    auto closer = sg::make_scope_guard([this] {
+        nvgEndFrame(vg);
+
+        // TODO: ugly hacked, NanoVG sets ColSrc to One
+        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+    });
 
     nvgBeginPath(vg);
     static constexpr auto r = 5.0f;

+ 1 - 1
src/image_process/impl/camera_calibrator_impl.h

@@ -17,7 +17,7 @@
 namespace camera_calibrator_impl {
 
     // TODO: make configurable
-    static constexpr auto sharpness_threshold = 6.f;
+    static constexpr auto sharpness_threshold = 4.f;
 
     using corner_type = std::vector<cv::Point2f>;
 

+ 1 - 1
src/impl/apps/endo_guide/endo_guide.cpp

@@ -81,7 +81,7 @@ app_endo_guide::app_endo_guide(const create_config &_conf) {
     monitor = std::make_unique<sophiar_monitor>(monitor_conf);
 
 //    auto sim_info = camera_calibrator::simulate_info_type{
-//            .data_path = "/home/tpx/project/DepthGuide/cmake-build-debug/calib_data_10.96.txt",
+//            .data_path = "/home/tpx/project/DepthGuide/cmake-build-debug/calib_data_v2.txt",
 //            .img_size = cv::Size(1920, 1080),
 //    };
 //    cam_calib->simulate_process(sim_info);

+ 2 - 0
src/module/impl/image_augment_helper_v2.cpp

@@ -70,11 +70,13 @@ void image_augment_helper_v2::impl::set_camera_info(const camera_intrinsic_v0 &i
     auto y_min = remap_bound.y, y_max = y_min + remap_bound.height;
     auto x_len = std::max(-x_min, x_max);
     auto y_len = std::max(-y_min, y_max);
+    y_len = std::min(y_len, max_camera_y_axis_len);
     auto cam_fov = 2.f * std::atan(y_len);
 
     auto aspect = x_len / y_len;
     auto aug_size = cv::Size(info.height * aspect, // width
                              info.height);
+    aug_size *= 2; // double render size
     fbo_aug_conf.size = aug_size;
 
     // convert to texture coordinate

+ 3 - 0
src/module/impl/image_augment_helper_v2_impl.h

@@ -8,6 +8,9 @@
 
 struct image_augment_helper_v2::impl {
 
+    // TODO: make configurable
+    static constexpr auto max_camera_y_axis_len = 3.f;
+
     image_augment_helper_v2 *q_this = nullptr;
     create_config conf;
     obj_conn_type img_conn;

+ 6 - 1
src/render/impl/render_utility.cpp

@@ -124,6 +124,11 @@ void smart_texture::create(GLenum _format, cv::Size _size) {
     glGenTextures(1, &next_id);
     glBindTexture(GL_TEXTURE_2D, next_id);
     glTexStorage2D(GL_TEXTURE_2D, 1, _format, _size.width, _size.height);
+
+    // TODO: check the default value
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
+
     glBindTexture(GL_TEXTURE_2D, 0);
 
     deallocate();
@@ -134,7 +139,7 @@ void smart_texture::create(GLenum _format, cv::Size _size) {
     id = next_id;
 
     // config
-    set_filter(GL_NEAREST, GL_NEAREST);
+    set_filter(GL_LINEAR, GL_LINEAR);
 }
 
 void smart_texture::upload_impl(const image_mem_info &img, smart_cuda_stream *stream) {