pythonとopencvを使ってリアルタイムに顔を認識して認識された数をリアルタイムで出力し続けたいのですがエラーが出てしまいます。
分かる方回答よろしくお願いします。
python
1import cv2 2 3img = cv2.imread('/Users//Downloads/japan.jpg') 4cascade = cv2.CascadeClassifier('/Users/miyajimakeitaro/Downloads/haarcascade_frontalface_default.xml') 5cap = cv2.VideoCapture(0) 6 7while True: 8 ret,frame = cap.read() 9 gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 10 faces = cascade.detectMultiScale(gray, 1.3, 5) 11 print(faces.shape[0]) 12 cv2.imshow('img',frame) 13 if cv2.waitKey(1) & 0xff == ord('q'): 14 break
エラー
Traceback (most recent call last):
File "test.py", line 11, in <module>
print(faces.shape[0])
AttributeError: 'tuple' object has no attribute 'shape'
###動作環境
Mac
python3.7
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/11/11 10:05