fix: 场景检测
This commit is contained in:
27
python_core/services/scene_detection/__init__.py
Normal file
27
python_core/services/scene_detection/__init__.py
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
场景检测服务模块
|
||||
"""
|
||||
|
||||
from .types import (
|
||||
DetectorType, SceneInfo, VideoSceneResult,
|
||||
BatchDetectionConfig, BatchDetectionResult, DetectionStats
|
||||
)
|
||||
from .detector import SceneDetectionService
|
||||
from .cli import SceneDetectionCommander
|
||||
|
||||
__all__ = [
|
||||
# 数据类型
|
||||
"DetectorType",
|
||||
"SceneInfo",
|
||||
"VideoSceneResult",
|
||||
"BatchDetectionConfig",
|
||||
"BatchDetectionResult",
|
||||
"DetectionStats",
|
||||
|
||||
# 服务
|
||||
"SceneDetectionService",
|
||||
|
||||
# 命令行接口
|
||||
"SceneDetectionCommander"
|
||||
]
|
||||
76
python_core/services/scene_detection/types.py
Normal file
76
python_core/services/scene_detection/types.py
Normal file
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
场景检测相关的数据类型定义
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import List, Optional
|
||||
from enum import Enum
|
||||
|
||||
class DetectorType(Enum):
|
||||
"""检测器类型"""
|
||||
CONTENT = "content"
|
||||
THRESHOLD = "threshold"
|
||||
ADAPTIVE = "adaptive"
|
||||
|
||||
@dataclass
|
||||
class SceneInfo:
|
||||
"""场景信息"""
|
||||
index: int
|
||||
start_time: float
|
||||
end_time: float
|
||||
duration: float
|
||||
confidence: float = 0.0
|
||||
frame_count: int = 0
|
||||
thumbnail_path: Optional[str] = None
|
||||
|
||||
@dataclass
|
||||
class VideoSceneResult:
|
||||
"""单个视频的场景检测结果"""
|
||||
video_path: str
|
||||
filename: str
|
||||
success: bool
|
||||
total_scenes: int
|
||||
total_duration: float
|
||||
scenes: List[SceneInfo]
|
||||
detection_time: float
|
||||
detector_type: str
|
||||
threshold: float
|
||||
error: Optional[str] = None
|
||||
|
||||
@dataclass
|
||||
class BatchDetectionConfig:
|
||||
"""批量检测配置"""
|
||||
detector_type: DetectorType = DetectorType.CONTENT
|
||||
threshold: float = 30.0
|
||||
min_scene_length: float = 1.0
|
||||
adaptive_threshold: bool = False
|
||||
generate_thumbnails: bool = False
|
||||
output_format: str = "json" # json, csv, txt
|
||||
save_scenes: bool = False
|
||||
|
||||
@dataclass
|
||||
class BatchDetectionResult:
|
||||
"""批量检测结果"""
|
||||
total_files: int
|
||||
processed_files: int
|
||||
failed_files: int
|
||||
total_scenes: int
|
||||
total_duration: float
|
||||
average_scenes_per_video: float
|
||||
detection_time: float
|
||||
results: List[VideoSceneResult]
|
||||
failed_list: List[dict]
|
||||
config: BatchDetectionConfig
|
||||
|
||||
@dataclass
|
||||
class DetectionStats:
|
||||
"""检测统计信息"""
|
||||
total_videos: int
|
||||
total_scenes: int
|
||||
total_duration: float
|
||||
average_duration_per_scene: float
|
||||
shortest_scene: float
|
||||
longest_scene: float
|
||||
most_scenes_video: str
|
||||
least_scenes_video: str
|
||||
Reference in New Issue
Block a user