feat: 增加视频截帧功能,支持--video参数自动截帧+OCR
This commit is contained in:
@@ -4,19 +4,36 @@
|
||||
|
||||
## Features
|
||||
|
||||
- Batch frame processing
|
||||
- PaddleOCR/Tesseract support
|
||||
- Confidence scoring
|
||||
- Text merging
|
||||
- **视频截帧**: 直接从视频文件截取帧图片
|
||||
- **批量处理**: 支持处理帧目录
|
||||
- **双引擎**: EasyOCR / Tesseract
|
||||
- **置信度评分**: 每帧识别结果带置信度
|
||||
- **文本合并**: 自动合并所有帧的识别结果
|
||||
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
# Process frames
|
||||
# 方式1: 直接从视频截帧并OCR(推荐)
|
||||
python ocr_processor.py --video ./video.flv --output ocr.json
|
||||
|
||||
# 方式2: 处理已截取的帧目录
|
||||
python ocr_processor.py --input ./frames/ --output ocr.json
|
||||
|
||||
# With custom FPS
|
||||
python ocr_processor.py --input ./frames/ --fps 0.1 --output ocr.json
|
||||
# 指定截帧帧率(默认1帧/秒)
|
||||
python ocr_processor.py --video ./video.flv --fps 2 --output ocr.json
|
||||
|
||||
# 同时生成合并的文本文件
|
||||
python ocr_processor.py --video ./video.flv --output ocr.json --merge
|
||||
|
||||
# 使用 Tesseract 引擎
|
||||
python ocr_processor.py --input ./frames/ --engine tesseract --output ocr.json
|
||||
```
|
||||
|
||||
## Workflow 中的使用
|
||||
|
||||
```bash
|
||||
# 步骤5: OCR处理(视频无字幕时)
|
||||
python ocr_processor.py --video ${CONTENT_VIDEO_PATH} --output ${CONTENT_DIR}/ocr.json --merge
|
||||
```
|
||||
|
||||
## Output
|
||||
@@ -24,14 +41,15 @@ python ocr_processor.py --input ./frames/ --fps 0.1 --output ocr.json
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"frames": {
|
||||
"frame_0001.jpg": {
|
||||
"texts": [{"text": "字幕", "confidence": 0.95}]
|
||||
}
|
||||
},
|
||||
"merged_text": "合并的字幕文本..."
|
||||
}
|
||||
"engine": "easyocr",
|
||||
"total_frames": 619,
|
||||
"results": [
|
||||
{
|
||||
"source": "0001.jpg",
|
||||
"text": "字幕文字",
|
||||
"confidence": 0.95
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -40,4 +58,9 @@ python ocr_processor.py --input ./frames/ --fps 0.1 --output ocr.json
|
||||
```bash
|
||||
cp -r kb-ocr-processor/ ~/skills/
|
||||
pip install -r requirements.txt
|
||||
|
||||
# 依赖说明
|
||||
# - easyocr: 主要OCR引擎(自动下载模型)
|
||||
# - pytesseract: Tesseract引擎
|
||||
# - ffmpeg: 视频截帧(apt install ffmpeg)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user