回答編集履歴

1

追記:動作確認

2018/09/16 07:31

投稿

mt08
mt08

スコア1825

test CHANGED
@@ -31,3 +31,77 @@
31
31
 
32
32
 
33
33
  上記コードだと、sleepがないので、カメラがうまく起動する前に撮影にいってしまってるのではないでしょうか?
34
+
35
+
36
+
37
+
38
+
39
+ # 追記
40
+
41
+ 私の環境で試してみましたが、撮影できました。
42
+
43
+ (python2でも3のどちらでも動作しました)
44
+
45
+
46
+
47
+ o 環境
48
+
49
+ - Raspberry Pi 3B と 3B+
50
+
51
+ - Raspberry Pi Camera V2.1
52
+
53
+ - Raspbian: 2018-06-27-raspbian-stretch
54
+
55
+ (Etcherにて、イメージをSDカードに焼いたあと、`raspi-config` で、CameraをEnableにしたのみ。#apt updateなし)
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+ ```
64
+
65
+ cd ~
66
+
67
+
68
+
69
+ #ファイル作成: picapture.py
70
+
71
+ cat << 'EOF' > picapture.py
72
+
73
+ import time
74
+
75
+ import picamera
76
+
77
+
78
+
79
+ with picamera.PiCamera() as camera:
80
+
81
+ camera.resolution = (1024, 768)
82
+
83
+ camera.start_preview()
84
+
85
+ # Camera warm-up time
86
+
87
+ time.sleep(2)
88
+
89
+ camera.capture('foo.jpg')
90
+
91
+ EOF
92
+
93
+
94
+
95
+ # 撮影.
96
+
97
+ #python ./picapture.py #Python 2.x
98
+
99
+ python3 ./picapture.py #Python 3.x
100
+
101
+
102
+
103
+ # 表示.
104
+
105
+ gpicview ./foo.jpg
106
+
107
+ ```