Files
OperationRoomMonitor/main_segments_offline.py
2026-06-02 16:59:42 +08:00

70 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""按结果 TSV 时间段对离线视频做手检 → 耗材分类(跳过分段与撕膜,无好坏帧门控)。"""
from __future__ import annotations
import argparse
import os
import sys
from pathlib import Path
PACK_ROOT = Path(__file__).resolve().parent
sys.path.insert(0, str(PACK_ROOT / "src"))
from paths import ensure_code_on_path
ensure_code_on_path(PACK_ROOT)
from config import load_run_config
from segments_offline_orchestrator import run_segments_offline_pipeline
def main() -> int:
os.environ.setdefault("OPENCV_FFMPEG_LOGLEVEL", "8")
ap = argparse.ArgumentParser(
description="TSV 时间段 → 离线视频段内耗材识别(无 ActionFormer / 无篮子分段 / 无撕膜)"
)
ap.add_argument("--video", type=Path, required=True, help="输入 MP4")
ap.add_argument(
"--segments-tsv",
type=Path,
required=True,
help="含 start_sec/end_sec 的结果 TSV如推流输出",
)
ap.add_argument(
"--excel",
type=Path,
required=True,
help="商品表 ExcelC 列白名单 + 产品编码)",
)
ap.add_argument("--out", type=Path, required=True, help="输出 TSV")
ap.add_argument(
"--config",
type=Path,
default=PACK_ROOT / "configs" / "default_config.yaml",
help="配置文件",
)
ap.add_argument(
"--skip-empty-segments",
action="store_true",
help="跳过 TSV 中 top1_name 为空或为失败文案的行",
)
args = ap.parse_args()
cfg_path = args.config.resolve()
if not cfg_path.is_file():
print("找不到配置:", cfg_path, file=sys.stderr)
return 1
run_cfg = load_run_config(PACK_ROOT, cfg_path)
run_cfg.video = args.video.resolve()
run_cfg.excel = args.excel.resolve()
run_cfg.out = args.out.resolve()
run_cfg.segments_tsv = args.segments_tsv.resolve()
run_cfg.segments_skip_empty = bool(args.skip_empty_segments)
return int(run_segments_offline_pipeline(run_cfg))
if __name__ == "__main__":
raise SystemExit(main())