[英]Saving a Video in OpenCV (Linux, Python)
There is an example that works on Windows ( original ): 有一个可以在Windows( 原始 )上运行的示例:
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
fourcc = cv2.VideoWriter_fourcc(*'XDIV')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))
while(True):
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
out.write(frame)
cv2.imshow('frame',gray)
if cv2.waitKey(0) & 0xFF == ord('q'):
break
cap.release()
out.release()
cv2.destroyAllWindows()
In Linux program provides: 在Linux程序中提供:
AttributeError: 'module' object has no attribute 'VideoWriter_fourcc' AttributeError:“模块”对象没有属性“ VideoWriter_fourcc”
Help make it work in Linux. 帮助使其在Linux中工作。
我没有尝试过,但这应该可以工作:
fourcc = cv2.cv.CV_FOURCC(*'XVID')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.