質問編集履歴
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,93 +9,3 @@
|
|
9
9
|
時刻に関係なく5分経過したら保存するにはどうすればよいでしょうか?
|
10
10
|
|
11
11
|
よろしくお願いいたします。
|
12
|
-
|
13
|
-
### 発生している問題・エラーメッセージ
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
```
|
18
|
-
|
19
|
-
import numpy as np
|
20
|
-
|
21
|
-
import cv2
|
22
|
-
|
23
|
-
import os
|
24
|
-
|
25
|
-
import shutil
|
26
|
-
|
27
|
-
import itertools
|
28
|
-
|
29
|
-
import time
|
30
|
-
|
31
|
-
import datetime
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
cap = cv2.VideoCapture(0)
|
36
|
-
|
37
|
-
width = int(cap.get(3))
|
38
|
-
|
39
|
-
height = int(cap.get(4))
|
40
|
-
|
41
|
-
oldpath = 'output.mp4'
|
42
|
-
|
43
|
-
newpath = '/home/pi/output.mp4'
|
44
|
-
|
45
|
-
fourcc = cv2.VideoWriter_fourcc(*'XVID')
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
bfdt = nowdt = datetime.datetime.now()
|
50
|
-
|
51
|
-
filename = 'cap' + nowdt.strftime('%Y%m%d_%H%M') + '.mp4'
|
52
|
-
|
53
|
-
out = cv2.VideoWriter(filename,fourcc, 30, (width,height))
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
while(True):
|
60
|
-
|
61
|
-
ret, frame = cap.read()
|
62
|
-
|
63
|
-
if ret==True:
|
64
|
-
|
65
|
-
cv2.imshow('frame',frame)
|
66
|
-
|
67
|
-
out.write(frame)
|
68
|
-
|
69
|
-
#現在時刻を取得
|
70
|
-
|
71
|
-
nowdt = datetime.datetime.now()
|
72
|
-
|
73
|
-
#bfとの分の差を計算
|
74
|
-
|
75
|
-
diff = nowdt.minute - bfdt.minute
|
76
|
-
|
77
|
-
#分の差が5以上なら(5分以上たったら)
|
78
|
-
|
79
|
-
if diff >= 5:
|
80
|
-
|
81
|
-
bfdt = nowdt
|
82
|
-
|
83
|
-
filename = 'cap' + nowdt.strftime('%Y%m%d_%H%M') + '.mp4'
|
84
|
-
|
85
|
-
out = cv2.VideoWriter(filename,fourcc, 30, (width,height))
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
if cv2.waitKey(1) & 0xFF == ord('q'):
|
90
|
-
|
91
|
-
break
|
92
|
-
|
93
|
-
# Release everything if job is finished
|
94
|
-
|
95
|
-
cap.release()
|
96
|
-
|
97
|
-
cv2.destroyAllWindows()
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
```
|