Skip to content

Commit 3d325c8

Browse files
committed
fix:二值化红点.采纳#299的两条评审建议.
具体在pr中标注.
1 parent f630e4f commit 3d325c8

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

agent/recognition/binarymatch.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,10 @@ def _try_recognition(self, context: Context, node_name: str,
551551
_DEFAULT_MIN_CONF = 0.25 # 精准 ROI 感叹号默认阈值;大 ROI 泛找请显式调高
552552

553553
# 同一检测点(节点名+ROI)两次落盘的最小间隔(秒),防 next 自循环刷屏;RDD_DUMP_INTERVAL 可调
554-
_DUMP_MIN_INTERVAL = float(os.environ.get("RDD_DUMP_INTERVAL", "2.0"))
554+
try:
555+
_DUMP_MIN_INTERVAL = float(os.environ.get("RDD_DUMP_INTERVAL", "2.0"))
556+
except (TypeError, ValueError):
557+
_DUMP_MIN_INTERVAL = 2.0 # 环境变量非法时兜底,避免 import 阶段崩溃中断 Agent 启动
555558
_RESOLVED_LOG_DIR = None
556559

557560

@@ -635,17 +638,29 @@ def _run_preset(self, context: Context,
635638
finally:
636639
self._caller = None
637640

638-
if reco and reco.hit:
641+
# reco is None:识别根本没跑起来(预设节点名写错/被禁用/图像空) —— 配置错误,与漏检区分
642+
if reco is None:
643+
mfaalog.error(f"[RedDotDetector] preset 未启动: {preset_node}(节点不存在/被禁用/图像空?)")
644+
return CustomRecognition.AnalyzeResult(box=None, detail={
645+
"result": "error", "mode": "preset", "preset": preset_node,
646+
"roi": [rx, ry, rw, rh],
647+
"error": f"preset node not started: {preset_node}",
648+
})
649+
650+
if reco.hit:
639651
bx, by, bw, bh = reco.box
640652
adjusted = (bx + rx, by + ry, bw, bh)
641653
mfaalog.info(f"[RedDotDetector] [preset:{preset_node}] hit -> {adjusted}")
642654
return CustomRecognition.AnalyzeResult(
643655
box=adjusted, detail={"result": "hit", "preset": preset_node})
644656

657+
# 真未命中:阶段原因已由预设节点(独立模式)记进嵌套识别记录;这里附带透传其 raw_detail
658+
raw = getattr(reco, "raw_detail", None)
645659
mfaalog.warning(f"[RedDotDetector] miss@preset | {argv.node_name} via {preset_node}")
646660
return CustomRecognition.AnalyzeResult(box=None, detail={
647661
"result": "miss", "mode": "preset", "preset": preset_node,
648662
"roi": [rx, ry, rw, rh],
663+
"preset_detail": raw,
649664
"hint": "阶段原因见预设节点(独立模式)的 detail;失败截图见 debug/RedDotDetector/ 下以本节点名命名的 rdd_* 文件",
650665
})
651666

0 commit comments

Comments
 (0)