繁体   English   中英

使用opencv逐帧处理视频

[英]Processing video frame by frame using opencv

import numpy as np
import cv2
cap = cv2.VideoCapture(0)
count = 0

fourcc = cv2.VideoWriter_fourcc("drop.avi")
out = cv2.VideoWriter('drop.avi',fourcc, 20.0, (640,480))

while True:
   # Capture frame-by-frame
   ret, frame = cap.read()

   # Our operations on the frame come here
   gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
   name = "frame%d.jpg"%count   # save frame as JPEG file
   cv2.imwrite(name,frame)


   # Display the resulting frame
   cv2.imshow('frame',gray)
   if cv2.waitKey(10):
      break

您指定的 focc 错误。

fourcc = cv2.cv.CV_FOURCC(*'XVID') 
video_writer = cv2.VideoWriter("drop.avi", fourcc, 20, (640,480))

在这里查看更多信息

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM