From 54d5319b474b99f8081fa3871d195bc40a5e190e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=83=B3?= <1318173008@qq.com> Date: Thu, 12 May 2022 20:27:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/视频转图像/.idea/workspace.xml | 243 ------------------------ src/视频转图像/huidu_shuai.py | 46 ----- src/视频转图像/qingxi_shuai.py | 27 --- src/视频转图像/video_to_photo.py | 50 ----- src/视频转图像/xiangsu_shuai.py | 22 --- 5 files changed, 388 deletions(-) delete mode 100644 src/视频转图像/.idea/workspace.xml delete mode 100644 src/视频转图像/huidu_shuai.py delete mode 100644 src/视频转图像/qingxi_shuai.py delete mode 100644 src/视频转图像/video_to_photo.py delete mode 100644 src/视频转图像/xiangsu_shuai.py diff --git a/src/视频转图像/.idea/workspace.xml b/src/视频转图像/.idea/workspace.xml deleted file mode 100644 index e6c8f94b..00000000 --- a/src/视频转图像/.idea/workspace.xml +++ /dev/null @@ -1,243 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1650350031963 - - - - - - - - - - file://$PROJECT_DIR$/../first.py - - - - - - - - - - - \ No newline at end of file diff --git a/src/视频转图像/huidu_shuai.py b/src/视频转图像/huidu_shuai.py deleted file mode 100644 index 4db402a0..00000000 --- a/src/视频转图像/huidu_shuai.py +++ /dev/null @@ -1,46 +0,0 @@ -import PIL.Image -import numpy -import os -import shutil -def sum_right(path): - img = PIL.Image.open(path) - array = numpy.array(img) - num = array.sum(axis=0) - print(type(num)) - res_left = 0 - res_right = 0 - for i in range(256,512): - res_right += num[i] - print(res_right) - -# if __name__ == '__main__': -# dir2 = r"C:\Users\xinluo\PycharmProjects\pythonProject\Camera Roll" -# dir1 = r"C:\Users\xinluo\PycharmProjects\pythonProject\Saved Pictures" -# names = os.listdir(dir1) -# n = len(names) -# print("文件数量",n) -# res = 0 -# average_5 = 25565356 -# average_25 = 26409377 -# average_5_right = 10006019 -# #average_tmp = (average_25+average_5)//2 -# count = 0 -# #show(os.path.join(dir1, "uni4F6C.png")) -# for i in range(n): -# #取图片 -# img = PIL.Image.open(os.path.join(dir1,names[i])) -# file = os.path.join(dir1,names[i]) -# rmfile = os.path.join(dir2,names[i]) -# array = numpy.array(img) -# num = array.sum(axis=0) -# res_right = 0 -# for i in range(256, 512): -# res_right += num[i] -# average_5_right += res_right/n -# -# if (res_right > average_5_right).all(): -# shutil.copyfile(file, rmfile) -# os.remove(file) -# count += 1 -# print(average_5_right) -# print(count) diff --git a/src/视频转图像/qingxi_shuai.py b/src/视频转图像/qingxi_shuai.py deleted file mode 100644 index 6b38de3c..00000000 --- a/src/视频转图像/qingxi_shuai.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: UTF-8 -*- - -import argparse -import cv2 -import os - -# 使用方法:命令行cd到脚本所在文件夹,python picture.py -i "图片路径" -#便历图片,合格则保存,不合格则删除 - - -def variance_of_laplacian(image): - # 使用拉普拉斯算子提取图像边缘信息,计算边缘的平均方差 - return cv2.Laplacian(image, cv2.CV_64F).var() -def read_path(file_pathname): - #遍历该目录下的所有图片文件 - for filename in os.listdir(file_pathname): - print(filename) - image = cv2.imread(file_pathname+'/'+filename) - # 取图片的灰度通道 - gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) - fm = variance_of_laplacian(gray) - - # 如果得分比阈值低,认为是模糊 - if fm < 100.0: - os.remove(file_pathname+'/'+filename) -#read_path(r"C:\Users\xinluo\PycharmProjects\pythonProject\Saved Pictures") -#print(os.getcwd()) diff --git a/src/视频转图像/video_to_photo.py b/src/视频转图像/video_to_photo.py deleted file mode 100644 index ce2e686c..00000000 --- a/src/视频转图像/video_to_photo.py +++ /dev/null @@ -1,50 +0,0 @@ -import cv2 -import argparse -import os - - -def parse_args(): - """ - Parse input arguments - """ - parser = argparse.ArgumentParser(description='Process pic') - parser.add_argument('--input', help='video to process', dest='input', default=None, type=str) - parser.add_argument('--output', help='pic to store', dest='output', default=None, type=str) - # default为间隔多少帧截取一张图片 - parser.add_argument('--skip_frame', dest='skip_frame', help='skip number of video', default=10, type=int) - # input为输入视频的路径 ,output为输出存放图片的路径 - args = parser.parse_args(['--input', r'C:\Users\xinluo\PycharmProjects\pythonProject\1234.mp4', '--output', r'C:\Users\xinluo\PycharmProjects\pythonProject\Saved Pictures']) - return args - - -def process_video(i_video, o_video, num): - cap = cv2.VideoCapture(i_video) - num_frame = cap.get(cv2.CAP_PROP_FRAME_COUNT) - expand_name = '.jpg' - if not cap.isOpened(): - print("Please check the path.") - cnt = 0 - count = 0 - while 1: - ret, frame = cap.read() - cnt += 1 - # how - # many - # frame - # to - # cut - if cnt % num == 0: - count += 1 - cv2.imwrite(os.path.join(o_video, str(count) + expand_name), frame) - - if not ret: - break - - -if __name__ == '__main__': - args = parse_args() - if not os.path.exists(args.output): - os.makedirs(args.output) - print('Called with args:') - print(args) - process_video(args.input, args.output, args.skip_frame) diff --git a/src/视频转图像/xiangsu_shuai.py b/src/视频转图像/xiangsu_shuai.py deleted file mode 100644 index 64604d0e..00000000 --- a/src/视频转图像/xiangsu_shuai.py +++ /dev/null @@ -1,22 +0,0 @@ -import os -from PIL import Image, ImageFile - -# ImageFile.LOAD_TRUNCATED_IMAGES = True #如果图片太大报错可以使用这个 - - - -def pixel(): - b = 0 - dir = r'C:\Users\xinluo\PycharmProjects\pythonProject\Camera Roll' # 需要处理的图片目录 - files = os.listdir(dir) # 得到需要处理的所有图片 - files.sort() # 对图片进行排序 - for each_bmp in files: # 遍历图片,进行筛选 - - each_bmp_root = os.path.join(dir, each_bmp) # 得到每个图片路径 - image = Image.open(each_bmp_root) # 打开每个图片 - img = image.convert('RGB') # 转化成RGB,其实图片大多都是RGB,即使灰度图也不一定转RGB,看需求 - width = img.size[0] # 获取图像的宽和长 - height = img.size[1] - - if (width < 650) or (height < 650): # 判断图形尺寸有一条边小于600像素的直接删除 - os.remove(each_bmp_root)