前提・実現したいこと
https://qiita.com/JotaroS/items/421459d98adc2dfe6d98
Pythonで、Face APIというAPIを利用したいと思っています。
上記のサイトのサンプルを動かしたいのですが、以下のエラーが
出ています。
発生している問題・エラーメッセージ
Traceback (most recent call last):
File "emotion.py", line 64, in <module>
display_expression(data,img)
File "emotion.py", line 31, in display_expression
f_rec = face['faceRectangle']
TypeError: string indices must be integers
該当のソースコード
Python 3.7.1
/////
def display_expression(data,img):
font = cv2.FONT_HERSHEY_PLAIN
text = "test cyber"
font_size = 1
data = json.loads(data)
for face in data:
f_rec = face['faceRectangle']
width = f_rec['width']
height = f_rec['height']
left = f_rec['left']
top = f_rec['top']
f_rec = face['scores']
f_rec = sorted(f_rec.items(), key=lambda x:x[1],reverse = True)
cv2.rectangle(img,(left,top),(left+width,top+height),(130,130,130),2)
cv2.rectangle(img,(left+width,top),(left+width+150,top+50),(130,130,130),-1)
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。