・OpenCVで顔認識をしてみた
https://qiita.com/K_M95/items/f1a3e7c47800adb94095
初歩的な質問ですいません。。
Qiitaの記事を参考に顔認識を試したところ下記のエラーが出ました。
文字コードらしきエラーだとはわかるのですが「どこ」がエラーなのかがわりません・・
詳しい人いたら教えてください。
(最初に文字コードを指定するのでしょうか・・それとも出力するときに文字コードを指定するのでしょうか・・)
※print ("Hello World")ではちゃん出ています。
#coding: utf-8 import cv2 cascade_file = "/Users/.../Python/haarcascade_frontalface_alt.xml" image_file = "images/smIMGL4136_TP_V.jpg)" img = cv2.imread(image_file) img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) cascade = cv2.CascadeClassifier(cascade_file) face_list = cascade.detectMultiScale(img_gray, minSize=(150, 150)) if len(face_list) == 0: print("Fail recognise") quit() for (x, y, w, h) in face_list: print("顔の座標 =", x, y, w, h) color = (0, 0, 225) pen_w = 8 cv2.rectangle(img, (x, y), (x+w, y+h), color, thickness = pen_w) cv2.imwrite("after.jpg", img)
結果
Fail recognise
smIMGL4136_TP_V.jpg
回答2件
あなたの回答
tips
プレビュー