From a4a68500949d4329c7411e8ac0117a0f0bf05dd4 Mon Sep 17 00:00:00 2001 From: Mateo de Mayo Date: Wed, 23 Aug 2023 13:50:00 -0300 Subject: [PATCH] h/mercury: Add min detection confidence option --- src/xrt/tracking/hand/mercury/hg_debug_instrumentation.hpp | 1 + src/xrt/tracking/hand/mercury/hg_model.cpp | 4 ++-- src/xrt/tracking/hand/mercury/hg_sync.cpp | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/xrt/tracking/hand/mercury/hg_debug_instrumentation.hpp b/src/xrt/tracking/hand/mercury/hg_debug_instrumentation.hpp index d612dd833..12f8cc8ae 100644 --- a/src/xrt/tracking/hand/mercury/hg_debug_instrumentation.hpp +++ b/src/xrt/tracking/hand/mercury/hg_debug_instrumentation.hpp @@ -33,6 +33,7 @@ struct hg_tuneable_values struct u_var_draggable_f32 max_reprojection_error; struct u_var_draggable_f32 opt_smooth_factor; struct u_var_draggable_f32 max_hand_dist; + struct u_var_draggable_f32 min_detection_confidence; bool scribble_predictions_into_next_frame = false; bool scribble_keypoint_model_outputs = false; bool scribble_optimizer_outputs = true; diff --git a/src/xrt/tracking/hand/mercury/hg_model.cpp b/src/xrt/tracking/hand/mercury/hg_model.cpp index e54fd393d..a2b2a9df3 100644 --- a/src/xrt/tracking/hand/mercury/hg_model.cpp +++ b/src/xrt/tracking/hand/mercury/hg_model.cpp @@ -383,7 +383,7 @@ run_hand_detection(void *ptr) for (int hand_idx = 0; hand_idx < 2; hand_idx++) { hand_region_of_interest &output = info->outputs[hand_idx]; - output.found = hand_exists[hand_idx] > 0.3; + output.found = hand_exists[hand_idx] > hgt->tuneable_values.min_detection_confidence.val; if (output.found) { output.hand_detection_confidence = hand_exists[hand_idx]; @@ -983,4 +983,4 @@ release_onnx_wrap(onnx_wrap *wrap) wrap->api->ReleaseEnv(wrap->env); } -} // namespace xrt::tracking::hand::mercury \ No newline at end of file +} // namespace xrt::tracking::hand::mercury diff --git a/src/xrt/tracking/hand/mercury/hg_sync.cpp b/src/xrt/tracking/hand/mercury/hg_sync.cpp index 2b670e439..1a7d893eb 100644 --- a/src/xrt/tracking/hand/mercury/hg_sync.cpp +++ b/src/xrt/tracking/hand/mercury/hg_sync.cpp @@ -26,6 +26,7 @@ namespace xrt::tracking::hand::mercury { DEBUG_GET_ONCE_LOG_OPTION(mercury_log, "MERCURY_LOG", U_LOGGING_WARN) DEBUG_GET_ONCE_BOOL_OPTION(mercury_optimize_hand_size, "MERCURY_optimize_hand_size", true) +DEBUG_GET_ONCE_FLOAT_OPTION(mercury_min_detection_confidence, "MERCURY_MIN_DETECTION_CONFIDENCE", 0.3) // Flags to tell state tracker that these are indeed valid joints static const enum xrt_space_relation_flags valid_flags_ht = (enum xrt_space_relation_flags)( @@ -1192,6 +1193,11 @@ t_hand_tracking_sync_mercury_create(struct t_stereo_camera_calibration *calib, hgt->tuneable_values.max_hand_dist.step = 0.05f; hgt->tuneable_values.max_hand_dist.val = 1.7f; + hgt->tuneable_values.min_detection_confidence.max = 1.0f; + hgt->tuneable_values.min_detection_confidence.min = 0.0f; + hgt->tuneable_values.min_detection_confidence.step = 0.01f; + hgt->tuneable_values.min_detection_confidence.val = debug_get_float_option_mercury_min_detection_confidence(); + u_var_add_draggable_f32(hgt, &hgt->tuneable_values.amt_use_depth, "Amount to use depth prediction"); @@ -1207,6 +1213,7 @@ t_hand_tracking_sync_mercury_create(struct t_stereo_camera_calibration *calib, u_var_add_draggable_f32(hgt, &hgt->tuneable_values.max_reprojection_error, "Max reprojection error"); u_var_add_draggable_f32(hgt, &hgt->tuneable_values.opt_smooth_factor, "Optimizer smoothing factor"); u_var_add_draggable_f32(hgt, &hgt->tuneable_values.max_hand_dist, "Max hand distance"); + u_var_add_draggable_f32(hgt, &hgt->tuneable_values.min_detection_confidence, "Min detection confidence"); u_var_add_i32(hgt, &hgt->tuneable_values.max_num_outside_view, "max allowed number of hand joints outside view");