opencv error file cannot be opened for reading cv::face::FaceRecognizer::read windows

raghav kharbanda picture raghav kharbanda · Feb 7, 2018 · Viewed 7.1k times · Source

I have been trying to run a django application (attendance system with face recognition).
I'm using python with opencv3.2 and after installing both opencv-python and opencv-contrib-python using pip on anaconda framework, i still get error like this

opencv error file cannot be opened for reading 
cv::face::FaceRecognizer::read".
file c:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp line 61.

Answer

Chamila Maddumage picture Chamila Maddumage · Aug 27, 2018

I had the the same problem. Actually problem happens here.

recognizer = cv2.face.LBPHFaceRecognizer_create()
recognizer.read("recognizers/face-trainner.yml")//path should be correct

There is a path in the second line of the above code snippet. You should give the correct path for the training model and this works for me.