6.4
This commit is contained in:
@@ -41,6 +41,32 @@ from ultralytics import YOLO # noqa: E402
|
||||
from pipeline.hand_roi_merge import HandRoiGrouper, two_largest_hands, union_xyxy # noqa: E402
|
||||
|
||||
# 与 run_haocai_actionformer_consumables_e2e 段内失败 return 文案一致,供 Phase2 重试判断
|
||||
|
||||
|
||||
def _detect_hands_on_frame(
|
||||
det: Any,
|
||||
fr: np.ndarray,
|
||||
det_conf: float,
|
||||
imgsz_det: int,
|
||||
predict_kw: dict[str, Any] | None,
|
||||
) -> list[list[float]]:
|
||||
try:
|
||||
from hand_detector import detect_hands_xyxy
|
||||
|
||||
return detect_hands_xyxy(
|
||||
det,
|
||||
fr,
|
||||
det_conf=det_conf,
|
||||
imgsz_det=imgsz_det,
|
||||
predict_kw=predict_kw,
|
||||
)
|
||||
except ImportError:
|
||||
pred_kw = dict(predict_kw or {})
|
||||
r0 = det.predict(
|
||||
fr, conf=det_conf, imgsz=imgsz_det, verbose=False, **pred_kw
|
||||
)[0]
|
||||
return collect_hand_boxes(det, r0.boxes) if r0.boxes else []
|
||||
|
||||
REASON_NO_VALID_HAOCAI_FRAMES = "(无有效耗材帧:好帧/白名单/耗材置信度未全部满足)"
|
||||
# 推流 / TSV 离线(无好坏帧门控)
|
||||
REASON_NO_VALID_HAOCAI_FRAMES_STREAM = "(无有效耗材帧:白名单/耗材置信度未满足)"
|
||||
@@ -312,8 +338,9 @@ def process_segment_multi_hand_tear(
|
||||
if frame_stride > 1 and (frames_read_in_segment - 1) % frame_stride != 0:
|
||||
return
|
||||
|
||||
r0 = det.predict(fr, conf=det_conf, imgsz=imgsz_det, verbose=False, **fg.predict_kw)[0]
|
||||
hands = collect_hand_boxes(det, r0.boxes) if r0.boxes else []
|
||||
hands = _detect_hands_on_frame(
|
||||
det, fr, det_conf, imgsz_det, fg.predict_kw
|
||||
)
|
||||
if len(hands) < 2:
|
||||
return
|
||||
|
||||
@@ -602,8 +629,7 @@ def process_segment_haocai_from_frames(
|
||||
if frame_stride > 1 and (frames_in_segment - 1) % frame_stride != 0:
|
||||
return
|
||||
|
||||
r0 = det.predict(fr, conf=det_conf, imgsz=imgsz_det, verbose=False, **pred_kw)[0]
|
||||
hands = collect_hand_boxes(det, r0.boxes) if r0.boxes else []
|
||||
hands = _detect_hands_on_frame(det, fr, det_conf, imgsz_det, pred_kw)
|
||||
crop = _crop_two_hands_union(fr, hands, pad_ratio)
|
||||
if crop is None:
|
||||
return
|
||||
@@ -702,8 +728,7 @@ def process_segment_haocai_from_cap(
|
||||
return
|
||||
|
||||
img_h, img_w = fr.shape[:2]
|
||||
r0 = det.predict(fr, conf=det_conf, imgsz=imgsz_det, verbose=False, **pred_kw)[0]
|
||||
hands = collect_hand_boxes(det, r0.boxes) if r0.boxes else []
|
||||
hands = _detect_hands_on_frame(det, fr, det_conf, imgsz_det, pred_kw)
|
||||
crop = _crop_two_hands_union(fr, hands, pad_ratio)
|
||||
if crop is None:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user