0
仮想環境であろうと通常のPythonシェルであろうと、スクリプトを実行しようとしているときにこのメッセージが表示されます。ここでRaspberry Pi 3顔認識のためのPythonとOpencv
File "/home/pi/facesample1.py", line 10, in <module>
gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
error: /home/pi/opencv-3.1.0/modules/imgproc/src/color.cpp:8000: error: (-215) scn == 3 || scn == 4 in function cvtColor
は私のコードです:
import cv2
#Load an image from file
image = cv2.imread("fronthead.jpg", 1)
#Load a cascade file for detecting faces
face_cascade = cv2.CascadeClassifier('/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml')
#Convert to grayscale
gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
#Look for faces in the image using the loaded cascade file
faces = face_cascade.detectMultiScale(gray, 1.1, 5)
print "Found "+str(len(faces))+" face(s)"
#Draw a rectangle around every found face
for (x,y,w,h) in faces:
cv2.rectangle(image,(x,y),(x+w,y+h),(255,0,0),2)
#Save the result image
cv2.imwrite('camresult.jpg',image)
は、なぜ私はこのエラーを取得していますか?
ありがとうございます。画像をロードするときにフルドライブを指定していなかった。 –