私はrubikのキューブタイマーの始まりである短いスクリプトを作ったが、録画したビデオを再生すると非常にスピードアップする。Python OpenCVビデオ録画早送り
私のウェブカメラは'Creative Labs Live! Cam Chat HD'で、解像度は1280×720ピクセルです。その解像度の再生でスクリプトエンコードを試してみると、30fpsのフレームレートになります。
以下は、効果を示す動画のコードとリンクです。
from time import clock as t
import time
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
fourcc = cv2.VideoWriter_fourcc(*"XVID")
out = cv2.VideoWriter("output.avi", fourcc, 30.0, (640, 480))
timing = False
while True:
ret, frame = cap.read()
#frame = cv2.flip(frame, 1)
cv2.imshow("frame", frame)
if timing:
out.write(frame)
if cv2.waitKey(1) & 0xFF == ord(" "):
if timing:
after = t()
break
else:
timing = True
start = t()
cap.release()
out.release()
cv2.destroyAllWindows()
print(after - start)
Example of the accelerated video.
のためのFPS = cap.getよう
検索フレームレート(cv2.CAP_PROP_FPS)、変更はおそらく20に30のFPSをハードコーディングし、私たちに、私はそれを試してみました結果 – Aleksandar