pref: 20cm靶子检测
This commit is contained in:
@@ -631,7 +631,7 @@ def detect_circle_v3(frame, laser_point=None, img_cv=None):
|
||||
min_r = min(rc["radius"], yellow_radius)
|
||||
max_r = max(rc["radius"], yellow_radius)
|
||||
size_ratio = min_r / max_r if max_r > 0 else 0
|
||||
if dist_centers < max_dist and size_ratio > 0.5:
|
||||
if dist_centers < max_dist and size_ratio >= 0.4:
|
||||
if logger:
|
||||
logger.info(f"[target] -> 找到匹配的红圈: 黄心({yellow_center}), "
|
||||
f"红心({rc['center']}), 距离:{dist_centers:.1f}, "
|
||||
@@ -797,12 +797,12 @@ def estimate_pixel(physical_distance_cm, target_distance_m):
|
||||
|
||||
def _save_shot_image_impl(img_cv, center, radius, method, ellipse_params,
|
||||
laser_point, distance_m, shot_id=None, photo_dir=None,
|
||||
yolo_roi_xyxy=None):
|
||||
yolo_roi_xyxy=None, force_save=False):
|
||||
"""
|
||||
内部实现:在 img_cv (numpy HWC RGB) 上绘制标注并保存。
|
||||
由 save_shot_image(同步)和存图 worker(异步)调用。
|
||||
"""
|
||||
if not config.SAVE_IMAGE_ENABLED:
|
||||
if not config.SAVE_IMAGE_ENABLED and not force_save:
|
||||
return None
|
||||
if photo_dir is None:
|
||||
photo_dir = config.PHOTO_DIR
|
||||
@@ -938,11 +938,12 @@ def start_save_shot_worker():
|
||||
|
||||
def enqueue_save_shot(result_img, center, radius, method, ellipse_params,
|
||||
laser_point, distance_m, shot_id=None, photo_dir=None,
|
||||
yolo_roi_xyxy=None):
|
||||
yolo_roi_xyxy=None, force_save=False):
|
||||
"""
|
||||
将存图任务放入队列,由 worker 异步保存。主线程传入 result_img 的复制,不阻塞。
|
||||
force_save=True 时,忽略 SAVE_IMAGE_ENABLED 配置强制保存(用于检测失败时的调试图像)。
|
||||
"""
|
||||
if not config.SAVE_IMAGE_ENABLED:
|
||||
if not config.SAVE_IMAGE_ENABLED and not force_save:
|
||||
return
|
||||
if photo_dir is None:
|
||||
photo_dir = config.PHOTO_DIR
|
||||
@@ -965,6 +966,7 @@ def enqueue_save_shot(result_img, center, radius, method, ellipse_params,
|
||||
shot_id,
|
||||
photo_dir,
|
||||
yolo_roi_xyxy,
|
||||
force_save,
|
||||
)
|
||||
try:
|
||||
_save_queue.put_nowait(task)
|
||||
@@ -976,12 +978,12 @@ def enqueue_save_shot(result_img, center, radius, method, ellipse_params,
|
||||
|
||||
def save_shot_image(result_img, center, radius, method, ellipse_params,
|
||||
laser_point, distance_m, shot_id=None, photo_dir=None,
|
||||
yolo_roi_xyxy=None):
|
||||
yolo_roi_xyxy=None, force_save=False):
|
||||
"""
|
||||
保存射击图像(带标注)。同步调用,会阻塞。
|
||||
主流程建议使用 enqueue_save_shot;此处保留供校准、测试等场景使用。
|
||||
"""
|
||||
if not config.SAVE_IMAGE_ENABLED:
|
||||
if not config.SAVE_IMAGE_ENABLED and not force_save:
|
||||
return None
|
||||
if photo_dir is None:
|
||||
photo_dir = config.PHOTO_DIR
|
||||
@@ -998,6 +1000,7 @@ def save_shot_image(result_img, center, radius, method, ellipse_params,
|
||||
shot_id,
|
||||
photo_dir,
|
||||
yolo_roi_xyxy,
|
||||
force_save,
|
||||
)
|
||||
except Exception as e:
|
||||
logger = logger_manager.logger
|
||||
|
||||
Reference in New Issue
Block a user