This commit is contained in:
yrx
2026-08-14 15:25:35 +08:00
parent e1f12ae609
commit 9be7cffbb2
86 changed files with 32670 additions and 3 deletions
+31
View File
@@ -323,6 +323,18 @@ def process_shot(adc_val):
frame = camera_manager.read_frame()
network_manager.safe_enqueue({"shoot_event": "start"}, msg_type=2, high=True)
# 每箭只识别当前帧,不复用上一箭的靶规格结果。
target_class_result = None
try:
from target_roi_yolo import try_get_target_class_from_yolo
target_class_result = try_get_target_class_from_yolo(frame, logger=logger)
if logger:
logger.info(f"[YOLO-TARGET] 当前箭业务结果: {target_class_result}")
except Exception as exc:
if logger:
logger.warning(f"[YOLO-TARGET] 当前箭分类失败,按未知处理: {exc}")
# 调用算法分析
analysis_result = analyze_shot(frame)
@@ -382,11 +394,25 @@ def process_shot(adc_val):
srv_y = round(float(dy), 4) if dy is not None else 200.0
# 构造上报数据
target_label = (
target_class_result.get("label")
if isinstance(target_class_result, dict)
else None
)
target_confidence = (
target_class_result.get("confidence")
if isinstance(target_class_result, dict)
else None
)
inner_data = {
"shot_id": shot_id,
"x": srv_x,
"y": srv_y,
"r": 20.0, # 保留字段(服务端当前忽略,物理外环半径 cm)
"target_class": target_label,
"target_class_confidence": (
float(target_confidence) if target_confidence is not None else None
),
"d": round((distance_m or 0.0) * 100),
"d_laser": round((laser_distance_m or 0.0) * 100),
"d_laser_quality": laser_signal_quality,
@@ -414,6 +440,11 @@ def process_shot(adc_val):
inner_data["ellipse_center_y"] = None
report_data = {"cmd": 1, "data": inner_data}
if logger:
logger.info(
f"[REPORT-TARGET] enqueue shot_id={shot_id}, "
f"target_class={target_label}, confidence={target_confidence}"
)
network_manager.safe_enqueue(report_data, msg_type=2, high=True)
# 数据上报后再画标注,不干扰检测阶段的原始画面