質問編集履歴
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -17,61 +17,3 @@
|
|
17
17
|
単純にPiCameraの動画を録画することは出来ますので、
|
18
18
|
|
19
19
|
OpenCVを使った方法をご教授ください。
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
```python
|
24
|
-
|
25
|
-
import cv2
|
26
|
-
|
27
|
-
import picamera
|
28
|
-
|
29
|
-
import picamera.array
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
fourcc = cv2.cv.CV_FOURCC('M','J','P','G')
|
34
|
-
|
35
|
-
out = cv2.VideoWriter('output.avi',fourcc,20.0,(1280,720))
|
36
|
-
|
37
|
-
with picamera.PiCamera() as camera:
|
38
|
-
|
39
|
-
with picamera.array.PiRGBArray(camera) as stream:
|
40
|
-
|
41
|
-
camera.resolution = (1280, 720)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
while True:
|
46
|
-
|
47
|
-
camera.capture(stream, 'bgr', use_video_port=True)
|
48
|
-
|
49
|
-
# stream.array now contains the image data in BGR order
|
50
|
-
|
51
|
-
cv2.imshow('frame', stream.array)
|
52
|
-
|
53
|
-
out.write(stream.array)
|
54
|
-
|
55
|
-
if cv2.waitKey(1) & 0xFF == ord('q'):
|
56
|
-
|
57
|
-
break
|
58
|
-
|
59
|
-
# reset the stream before the next capture
|
60
|
-
|
61
|
-
stream.seek(0)
|
62
|
-
|
63
|
-
stream.truncate()
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
cv2.destroyAllWindows()
|
68
|
-
|
69
|
-
out.release()
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
```
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
よろしくお願い致します。
|