質問編集履歴

1

プログラムコードを更新しました。

2019/11/08 02:58

投稿

raspypy
raspypy

スコア247

test CHANGED
File without changes
test CHANGED
@@ -20,29 +20,45 @@
20
20
 
21
21
  ```python
22
22
 
23
- import cv2
23
+ import time
24
+
25
+ from datetime import datetime
26
+
27
+ cap = cv2.VideoCapture(0)
24
28
 
25
29
 
26
-
27
- cap = cv2.VideoCapture(0)
28
30
 
29
31
  width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
30
32
 
31
33
  height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
32
34
 
33
- writer = cv2.VideoWriter('./test.mov', cv2.VideoWriter_fourcc(*'mp4v'),25, (width, height))
35
+ writer = cv2.VideoWriter('/home/pi/dev/data/capture.mov', cv2.VideoWriter_fourcc(*'mp4v'),25, (width, height))
34
36
 
35
37
 
36
38
 
39
+ starttime = time.time()
40
+
41
+ wait = 0
42
+
43
+ set_time = 10000
44
+
37
45
  while True:
38
-
39
-
40
46
 
41
47
  ret, frame = cap.read()
42
48
 
43
49
  writer.write(frame)
44
50
 
51
+ endtime = time.time()
45
52
 
53
+ diff = int((endtime - starttime) * 1000)
54
+
55
+ key = cv2.waitKey(wait) & 0xFF
56
+
57
+ print (diff)
58
+
59
+ if diff > set_time or key == ord('q'):
60
+
61
+ break
46
62
 
47
63
  cap.release()
48
64