视频水印检测
更新时间:2026-06-15
简介
视频水印检测
功能描述
- 智能检测:基于一致性分析识别视频中的固定文本水印区域
- 采样优化:通过智能采样策略提升检测效率和准确性
- 格式兼容:输出格式与视频修复算子完全兼容
- CPU处理:当前版本仅支持CPU模式处理
- 多输入支持:支持路径输入和二进制输入
- 建议处理分辨率不超过1080p的视频
- 采样帧数可根据视频长度调整
- 一致性阈值建议保持在0.7-0.9之间
- 位置一致性:检测在多帧中位置稳定的文本区域
- 坐标标准化:输出标准化的区域坐标格式
- 检测加去除:与视频修复算子组合使用,实现水印去除
算子参数
输入
| 输入 | 含义 |
|---|---|
| video_paths | 视频文件路径列(本地、BOS、HTTP等),与video_binaries二选一 |
| video_binaries | 视频二进制数据列,与video_paths二选一 |
| video_formats | 视频格式字符串列,配合video_binaries使用 |
输出
| 输出 | 含义 |
|---|---|
| watermark_regions | 检测到的水印区域列表 |
| video_resolution | 视频分辨率[width, height] |
| total_frames | 视频总帧数 |
参数
| 参数名称 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| model_path | str | '/opt/aihc/models' | 模型文件存储的根目录路径 默认值:"/opt/aihc/models" |
| model_name | str | 'PP-OCRv4/ch_det' | 使用的OCR检测模型名称 默认值:"PP-OCRv4/ch_det" |
| sample_count | int | 15 | 从视频中采样的帧数,用于水印一致性检测 默认值:15 |
| consistency_threshold | float | 0.8 | 水印位置一致性阈值,范围0-1,值越高要求越严格 默认值:0.8 |
| position_tolerance | int | 15 | 位置容差像素值,用于判断多帧间文本位置是否一致 默认值:15 |
调用示例
Python
1from __future__ import annotations
2
3import os
4
5import daft
6from daft import col
7
8from daft.aihc.common.udf import aihc_udf
9from daft.aihc.functions.video.video_watermark_detect import VideoWatermarkDetect
10
11if __name__ == "__main__":
12 if os.getenv("DAFT_RUNNER", "native") == "ray":
13 import ray
14 ray.init(dashboard_host="0.0.0.0", ignore_reinit_error=True)
15 daft.set_runner_ray()
16 daft.set_execution_config(actor_udf_ready_timeout=6000, min_cpu_per_task=0)
17
18 # TODO: 根据实际场景准备样本数据
19 samples = {
20 "video_paths": ["bos://bucket/test/aihc/test_data/test_video.mp4"],
21 }
22 ds = daft.from_pydict(samples)
23 constructor_kwargs = {
24 "model_path": '/opt/aihc/models',
25 "model_name": 'PP-OCRv4/ch_det',
26 "sample_count": 15,
27 "consistency_threshold": 0.8,
28 "position_tolerance": 15,
29 }
30 ds = ds.with_column(
31 "result",
32 aihc_udf(
33 VideoWatermarkDetect,
34 construct_args=constructor_kwargs,
35 num_cpus=1,
36 concurrency=4,
37 batch_size=8,
38 )(col("video_paths"), col("video_binaries"), col("video_formats")),
39 )
40 ds.show()
评价此篇文章
