I am using Python 3 and OpenCV 3. I am trying to use the EigenFace Recognizer which uses the same size images for the training and test dataset. I read the image from a webcam and I resize the images to 200 x 200 but it shows an error .
This is my code:
faceDetect=cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
cam=cv2.VideoCapture(0);
rec=cv2.face.EigenFaceRecognizer_create()
#rec=cv2.face.LBPHFaceRecognizer_create()
rec.read("recognizer/EigenData.xml")
id=0
fontFace = cv2.FONT_HERSHEY_SIMPLEX
fontScale = 1
fontColor = (0, 0, 255)
while(True):
ret,img=cam.read();
resize_img = img.resize((200,200) , img)
gray=cv2.cvtColor(resize_img,cv2.COLOR_BGR2GRAY)
faces=faceDetect.detectMultiScale(gray,1.3,5);
for(x,y,w,h) in faces:
cv2.rectangle(img,(x,y),(x+w, y+h), (0,255,0) , 2)
id, conf=rec.predict(gray[y:y+h, x:x+w]) #EigenFace Predict
cv2.putText(img,str(id),(x,y+h), fontFace, fontScale, fontColor,thickness=2)
cv2.imshow("Face", img);
if(cv2.waitKey(1)==ord('q')):
break;
cam.release()
cv2.destroyAllWindows()
The error I get is:
resize_img = img.resize((200,200) , img)
TypeError: 'tuple' object cannot be interpreted as an integer