C:\ci\opencv_1512688052760\work\opencv_contrib-3.3.1\modules\face\src\lbph_faces.cpp:400: error: (-5) This LBPH model is not computed yet. Did you call the train method? in function cv::face::LBPH::predict [closed]

asked 2018-08-01 16:51:11 -0600

Hi, I get an error.

Here is My Code

import cv2 import numpy as np faceDetect=cv2.CascadeClassifier('haarcascade_frontalface_default.xml') cam=cv2.VideoCapture(0); rec=cv2.face.LBPHFaceRecognizer_create(); rec.read("recognizer/trainningData.yml") id=0 font = cv2.FONT_HERSHEY_SIMPLEX while(True): ret,img=cam.read(); gray=cv2.cvtColor(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,0,255),2) id,conf=rec.predict(gray[y:y+h,x:x+w]) cv2.putText(img,str(id),(x,y+h),font,1,255)

cv2.imshow("Face",img);
if(cv2.waitKey(1)==ord('q')):
    break;

cam.release() cv2.destroyAllWindows()

Can you help ?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-21 17:02:41.862260

Comments

can it be , you just pasted this code from somewhere, without thinking ?

(i've seen that "trainningData" typo quite often, already)

are you sure, "recognizer/trainningData.yml" contains valid data ? what did you actually train it on and how ?

berak gravatar imageberak ( 2018-08-02 00:41:48 -0600 )edit

i had get the code from this link https://github.com/AsankaD7/Face-Reco...

Abhi2244 gravatar imageAbhi2244 ( 2018-08-02 02:07:32 -0600 )edit

what do you want with a pretrained file from someone else ? that's silly.

also - blindly copy / pasting code, without ANY understanding of it.

but the answer is: your xml does not contain any lbp histograms.

berak gravatar imageberak ( 2018-08-02 02:11:41 -0600 )edit

what are you trying to achieve here ? what should your program do, in the end ?

using this class might be the wrong approach, anyway.

berak gravatar imageberak ( 2018-08-02 03:24:41 -0600 )edit