teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

7

エラーコードの追加

2019/12/13 05:57

投稿

maru19
maru19

スコア5

title CHANGED
File without changes
body CHANGED
@@ -100,7 +100,24 @@
100
100
  TypeError: string indices must be integers
101
101
 
102
102
  ```
103
+ conn.request("POST", "/face/v1.0/detect?returnFaceAttributes=emotions", image, headers)のemotionに書き直した場合
104
+ ```Python
105
+ captured!
106
+ face rectangle
107
+ [[174 170 240 240]]
108
+ [{"faceId":"222cb191-eac7-4f4d-bd12-85804a4f06ae","faceRectangle":{"top":186,"left":182,"width":237,"height":237},"faceAttributes":{"emotion":{"anger":0.0,"contempt":0.0,"disgust":0.0,"fear":0.0,"happiness":0.0,"neutral":0.956,"sadness":0.043,"surprise":0.0}}}]
109
+ Traceback (most recent call last):
110
+ File "/home/pi/emoji-unicornhathd/emoji-unicornhathd-stream.py", line 127, in <module>
111
+ drawEmotion(data)
112
+ File "/home/pi/emoji-unicornhathd/emoji-unicornhathd-stream.py", line 78, in drawEmotion
113
+ f_rec = face['scores']
114
+ KeyError: 'scores'
103
115
 
116
+ ```
117
+ キャプチャした表情の感情はフィードバックされるものの、
118
+ 最終的に達成したいRaspberry PiのHATに感情に適した絵文字を表示させることができない。
119
+
120
+
104
121
  ### 使用しているコード
105
122
  emoji-unicornhathd/emoji-unicornhathd-stream.py
106
123
  を使用しています。

6

エラーコードの追加

2019/12/13 05:57

投稿

maru19
maru19

スコア5

title CHANGED
File without changes
body CHANGED
@@ -61,8 +61,46 @@
61
61
 
62
62
 
63
63
  ```
64
+ リクエストURLを私のエンドポイントにした場合
65
+ conn = httplib.HTTPSConnection('私の名前.cognitiveservices.azure.com')
64
66
 
67
+ ```Python
68
+ captured!
69
+ face rectangle
70
+ [[442 327 76 76]]
71
+ [Errno -3] Temporary failure in name resolution
65
72
 
73
+ None
74
+ Traceback (most recent call last):
75
+ File "/home/pi/emoji-unicornhathd/emoji-unicornhathd-stream.py", line 127, in <module>
76
+ drawEmotion(data)
77
+ File "/home/pi/emoji-unicornhathd/emoji-unicornhathd-stream.py", line 76, in drawEmotion
78
+ data = json.loads(data)
79
+ File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
80
+ return _default_decoder.decode(s)
81
+ File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
82
+ obj, end = self.raw_decode(s, idx=_w(s, 0).end())
83
+ TypeError: expected string or buffer
84
+
85
+ ```
86
+
87
+ リクエストURLをconn = httplib.HTTPSConnection('japaneast.api.cognitive.microsoft.com')にした場合
88
+
89
+ ```Python
90
+ captured!
91
+ face rectangle
92
+ [[212 106 220 220]
93
+ [544 392 46 46]]
94
+ {"error":{"code":"BadArgument","message":"Invalid argument returnFaceAttributes."}}
95
+ Traceback (most recent call last):
96
+ File "/home/pi/emoji-unicornhathd/emoji-unicornhathd-stream.py", line 127, in <module>
97
+ drawEmotion(data)
98
+ File "/home/pi/emoji-unicornhathd/emoji-unicornhathd-stream.py", line 78, in drawEmotion
99
+ f_rec = face['scores']
100
+ TypeError: string indices must be integers
101
+
102
+ ```
103
+
66
104
  ### 使用しているコード
67
105
  emoji-unicornhathd/emoji-unicornhathd-stream.py
68
106
  を使用しています。

5

変更した際のエラーメッセージの追記

2019/12/13 05:36

投稿

maru19
maru19

スコア5

title CHANGED
File without changes
body CHANGED
@@ -37,7 +37,32 @@
37
37
  f_rec = face['scores']
38
38
  KeyError: 'scores'
39
39
  ```
40
+ 「/face/v1.0/detect?」を「/face/v1.0/detect?returnFaceAttributes=emotions」に変更した場合
41
+ ```Python
42
+ pi@raspberrypi:~ $ python /home/pi/emoji-unicornhathd/emoji-unicornhathd-stream.py
43
+ unicorn hat hd detected
44
+ Unicorn HAT HD: Emoji
40
45
 
46
+ Press Ctrl+C to exit!
47
+ .
48
+ .
49
+ .
50
+ .
51
+ captured!
52
+ face rectangle
53
+ [[250 106 225 225]]
54
+ {"error":{"code":"BadArgument","message":"Invalid argument returnFaceAttributes."}}
55
+ Traceback (most recent call last):
56
+ File "/home/pi/emoji-unicornhathd/emoji-unicornhathd-stream.py", line 126, in <module>
57
+ drawEmotion(data)
58
+ File "/home/pi/emoji-unicornhathd/emoji-unicornhathd-stream.py", line 77, in drawEmotion
59
+ f_rec = face['scores']
60
+ TypeError: string indices must be integers
61
+
62
+
63
+ ```
64
+
65
+
41
66
  ### 使用しているコード
42
67
  emoji-unicornhathd/emoji-unicornhathd-stream.py
43
68
  を使用しています。

4

エラーメッセージの全文追加

2019/12/12 14:41

投稿

maru19
maru19

スコア5

title CHANGED
File without changes
body CHANGED
@@ -11,6 +11,25 @@
11
11
  ## 発生している問題・エラーメッセージ
12
12
 
13
13
  ```
14
+ pi@raspberrypi:~ $ python /home/pi/emoji-unicornhathd/emoji-unicornhathd-stream.py
15
+ unicorn hat hd detected
16
+ Unicorn HAT HD: Emoji
17
+
18
+ Press Ctrl+C to exit!
19
+
20
+
21
+ captured!
22
+ face rectangle
23
+ []
24
+ .
25
+ .
26
+ .
27
+ .
28
+ .
29
+ captured!
30
+ face rectangle
31
+ [[224 130 172 172]]
32
+ [{"faceId":"c5ed71c5-706a-4f25-b408-75189dd0f58a","faceRectangle":{"top":144,"left":223,"width":172,"height":172}}]
14
33
  Traceback (most recent call last):
15
34
  File "/home/pi/emoji-unicornhathd/emoji-unicornhathd-stream.py", line 123, in <module>
16
35
  drawEmotion(data)

3

エラー部分の追記

2019/12/11 15:10

投稿

maru19
maru19

スコア5

title CHANGED
File without changes
body CHANGED
@@ -163,7 +163,8 @@
163
163
  また自分の環境に応じてパスを加えております。
164
164
  しかし、カメラやUnicorn HAT HDは動作するものの表情を認識し、
165
165
  HATにフィードバックする際にエラーが起きます。
166
+ いろいろ試しては見ましたがどうも、
166
- いろいろ試しては見ましたがどうも「def drawEmotion(data)」辺りでエラーが発生します。
167
+ 「def drawEmotion(data)」**「f_rec = face['scores']」**辺りでエラーが発生します。
167
168
  解決法方法などあればご教授お願いします。
168
169
 
169
170
 

2

URLの表記の修正

2019/12/11 11:02

投稿

maru19
maru19

スコア5

title CHANGED
File without changes
body CHANGED
@@ -169,9 +169,9 @@
169
169
 
170
170
  #### 補足情報(FW/ツールのバージョンなど)
171
171
  ・Raspberry Pi 3B+
172
- Description: Raspbian GNU/Linux 10 (buster)
172
+  Description: Raspbian GNU/Linux 10 (buster)
173
- Release: 10
173
+  Release: 10
174
- Codename: buster
174
+  Codename: buster
175
175
 
176
176
  ・Raspberry Pi カメラモジュール V2
177
177
  ・Unicorn HAT HD

1

書式の改善

2019/12/11 10:44

投稿

maru19
maru19

スコア5

title CHANGED
File without changes
body CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Raspberry piをFACE APIを使用してemoji-unicornhathdの動作を試みています。
4
4
 
5
- https://fabcross.jp/category/make/sorepi/20171206_face.html
5
+ [emoji-unicornhathd](https://fabcross.jp/category/make/sorepi/20171206_face.html)
6
- https://github.com/kazme-egawa/emoji-unicornhathd
6
+ [github](https://github.com/kazme-egawa/emoji-unicornhathd)
7
7
 
8
8
  上記を参考にしながら動作を試みたのですが、
9
9
  数年前とFACE APIの内容が変わっておりうまく動作しません。