0
我正在修補OpenCV,我在計算什麼fps我應該錄製攝像頭鏡頭時遇到了一些麻煩。當我在15 fps
上錄製時,錄製的視頻比「現實生活」要快得多。我想知道是否有一個「最佳」的fps,我可以記錄,只要拍攝視頻花費的時間,記錄就會是,正好是?什麼是記錄OpenCV視頻的最佳fps?
以下是我正在運行的程序(雖然我認爲這是無關緊要的問題):
import cv2
cap = cv2.VideoCapture(0)
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
fps = 15.0 # Controls the fps of the video created: todo look up optimal fps for webcam
out = cv2.VideoWriter()
success = out.open('../assets/output.mp4v',fourcc, fps, (1280,720),True)
while(cap.isOpened()):
ret, frame = cap.read()
if ret==True:
frame = cv2.flip(frame,1)
# write the flipped frame
out.write(frame)
cv2.imshow('frame',frame)
# If user presses escape key program terminates
userInput = cv2.waitKey(1)
if userInput == 27:
break
else:
break
# Release everything if job is finished
cap.release()
out.release()
cv2.destroyAllWindows()