21.11.8
为了自己做数据集今天学习了一项新技能!
过程极简单直接上代码
import cv2
cap = cv2.VideoCapture("7.mp4")
isOpened = cap.isOpened
print(isOpened)
fps = cap.get(cv2.CAP_PROP_FPS)
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
print(fps,width,height)
i = 0
while(isOpened):
if i == 200:
break
else:
i = i+1
(flag,frame) = cap.read()
fileName = 'img//in//'+str(i+990)+'.jpg'
print(fileName)
if flag == True:
cv2.imwrite(fileName,frame,[cv2.IMWRITE_JPEG_QUALITY,100])
print('finish!')
|