2
私はカメラからビデオをキャプチャするコードを持っています。キャプチャされたフレームはリストに追加されます。しかし、このキャプチャに時間制限を設定する方法は??録画を停止しなければならない最初の2分をキャプチャしたいだけです。リアルタイムビデオキャプチャで時間制限を設定するにはどうすればよいですか?
import cv2
import numpy
#creating video capture object
capture=cv2.VideoCapture(0)
#Set the resolution of capturing to 640W*480H
capture.set(3,640)
capture.set(4,480)
frame_set=[]
while(True):
# Capture frame-by-frame
ret, frame = capture.read()
# Converting to Gray Scale
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
frame_set.append(gray)
# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
capture.release()
cv2.destroyAllWindows()
はどうもありがとうございました – user6745741