當前位置:編程學習大全網 - 網站源碼 - 如何用python實現視頻關鍵幀提取並保存為圖片

如何用python實現視頻關鍵幀提取並保存為圖片

import cv2

vc = cv2.VideoCapture('Test.avi') #讀入視頻文件

c=1

if vc.isOpened(): #判斷是否正常打開

rval , frame = vc.read()

else:

rval = False

timeF = 1000 #視頻幀計數間隔頻率

while rval: #循環讀取視頻幀

rval, frame = vc.read()

if(c%timeF == 0): #每隔timeF幀進行存儲操作

cv2.imwrite('image/'+str(c) + '.jpg',frame) #存儲為圖像

c = c + 1

cv2.waitKey(1)

vc.release()

  • 上一篇:zk連接工具curator使用上的壹些坑
  • 下一篇:什麽是MACD佛手形狀
  • copyright 2024編程學習大全網