python从视频中取图片

python从视频中取图片_第1张图片

import cv2
cap=cv2.VideoCapture(r'E:\zj\Imageprocessing\Video\20190507-130-300.avi')
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=1
flag=True
while(flag):
    (flag,frame)=cap.read()
    filename='C:\\Users\\yh\\Desktop\\test\\o'+str(i)+'.jpg'
    if flag==True:
        cv2.imwrite(filename,frame,[cv2.IMWRITE_JPEG_LUMA_QUALITY,100])
    i=i+1
print('endl')

python从视频中取图片_第2张图片

你可能感兴趣的:(python,opencv)