# data_slicing **Repository Path**: littlesquid_mc/data_slicing ## Basic Information - **Project Name**: data_slicing - **Description**: 视频帧提取和图片去重项目 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2025-08-20 - **Last Updated**: 2026-01-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 视频帧提取和图片去重项目 ## 项目介绍 这个项目包含两个主要功能: 1. 从视频中提取帧图片 2. 对图片进行去重处理 ## 项目结构 ``` .\data_slicing ├── video_to_frames.py # 视频帧提取工具 ├── image_deduplicator.py # 图片去重工具 ├── .gitignore # Git忽略文件 └── readme.md # 项目说明文档 ``` ## 功能说明 ### 1. 视频帧提取工具 (video_to_frames.py) - 从指定视频文件中提取帧图片 - 支持自定义帧间隔 - 实时显示处理进度条 - 输出帧图片到指定目录 ### 2. 图片去重工具 (image_deduplicator.py) - 使用感知哈希算法比较图片相似度 - 支持自定义相似度阈值 - 实时显示去重进度 - 可选的可视化功能,生成去重结果统计图表 - 支持干运行模式,预览去重效果而不实际删除文件 ## 环境要求 - Python 3.6+ - OpenCV (cv2) - PIL (Pillow) - numpy - matplotlib - tqdm ## 使用方法 ### 视频帧提取 ```bash python video_to_frames.py --input_video path\to\video.mp4 --output_dir path\to\output_frames --frame_interval 10 ``` ### 图片去重 ```bash # 基本去重 python image_deduplicator.py --input_dir path\to\images --threshold 10 # 带可视化 python image_deduplicator.py --input_dir path\to\images --threshold 10 --visualize # 干运行模式 python image_deduplicator.py --input_dir path\to\images --threshold 10 --dry_run ``` ## 示例 ### 视频帧提取示例 ```python from video_to_frames import video_to_frames video_path = 'input/video.mp4' output_dir = 'output/frames' frame_interval = 5 success = video_to_frames(video_path, output_dir, frame_interval) if success: print(f'成功提取帧到 {output_dir}') ``` ### 图片去重示例 ```python from image_deduplicator import deduplicate_images image_dir = 'input/images' threshold = 8 dry_run = False visualize = True unique_images, duplicate_count = deduplicate_images(image_dir, threshold, dry_run, visualize) print(f'去重完成,保留 {len(unique_images)} 张唯一图片,移除 {duplicate_count} 张重复图片') ``` ## 作者信息 作者:店长小鱿鱼 仓库地址:https://gitee.com/littlesquid_mc/data_slicing.git