first commit
This commit is contained in:
commit
54ccfb11fe
218 files changed
+19525
No files matched your search
Executable
+55
@@ -0,0 +1,55 @@
|
||||
'''
|
||||
author : Hatcher W
|
||||
Email: hcwang@semi.ac.cn
|
||||
use: 视频抽帧
|
||||
|
||||
'''
|
||||
# -*- coding:utf8 -*-
|
||||
import cv2
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
# 视频文件名字l
|
||||
|
||||
# 保存图片的路径
|
||||
def vedio_img(input,output,fps):
|
||||
isExists = os.path.exists(output)
|
||||
if not isExists:
|
||||
os.makedirs(output)
|
||||
print('path of %s is build' % (output))
|
||||
else:
|
||||
shutil.rmtree(output)
|
||||
os.makedirs(output)
|
||||
print('path of %s already exist and rebuild' % (output))
|
||||
|
||||
# 视频帧率12
|
||||
# fps = 1
|
||||
# 保存图片的帧率间隔
|
||||
#count = 1
|
||||
|
||||
# 开始读视频
|
||||
videoCapture = cv2.VideoCapture(input)
|
||||
i = 0
|
||||
j = 0
|
||||
|
||||
while True:
|
||||
success, frame = videoCapture.read()
|
||||
|
||||
if not success:
|
||||
print('video is all read')
|
||||
break
|
||||
#frame = cv2.resize(frame, (1024, 768))
|
||||
i += 1
|
||||
if (i % fps == 0):
|
||||
# 保存图片
|
||||
j += 1
|
||||
savedname = output+"/" + "{}".format(j).zfill(7)+ '.jpg' #density
|
||||
#savedname = output + "/" + "{}".format(j).zfill(7) + '.jpg' #detection
|
||||
cv2.imwrite( savedname, frame)
|
||||
print('image of %s is saved' % (savedname))
|
||||
|
||||
if __name__ == '__main__':
|
||||
filename = '../data_MPKFNet/rawdata/1_3.mp4'
|
||||
savedpath = '../data_MPKFNet/result_raw/' + "2021.2.23"
|
||||
vedio_img(filename,savedpath,1000)
|
||||
Reference in new issue
Block a user