MagicMirror² v2.5.0 is available! For more information about this release, check out this topic.

MMM-Facial-Recognition-Tools error



  • Hello everyone,

    I have been trying for weeks to get the facial recognition to work with my magic mirror. I have searched this forum and google but I can’t quite seem to find an answer to my problem. Here is the error I get when I’m trying to test it:

    [‘Angel’]
    Using FACE_ALGORITM: 1
    Loading training data…
    Training data loaded!
    Cropping…
    Crop: [[ 30 30 31 …, 148 143 136]
    [ 30 32 32 …, 145 143 136]
    [ 32 32 31 …, 144 144 135]
    …,
    [238 206 164 …, 200 206 179]
    [240 227 184 …, 199 210 181]
    [240 240 206 …, 199 212 193]]
    OpenCV Error: Bad argument (This LBPH model is not computed yet. Did you call the train method?) in predict, file /home/pi/opencv_contrib-3.3.0/modules/face/src/lbph_faces.cpp, line 396
    Traceback (most recent call last):
    File “facerecognition.py”, line 83, in
    label, confidence = model.predict(crop)
    cv2.error: /home/pi/opencv_contrib-3.3.0/modules/face/src/lbph_faces.cpp:396: error: (-5) This LBPH model is not computed yet. Did you call the train method? in function predict

    I have trained the LBPH model multiple times using .jpg’s as well as using the camera on my own face. This is what I’m running:

    • Raspberry PI 3
    • Raspberry pi cam
    • OpenCV-3.3.0
    • Python 2.7 (I also have Python 3 installed)
    • Electron 1.7.9
    • Node 8.9.1
    • npm 5.6.0

    If anyone has any idea how I can better troubleshoot this error through logs or any other means, please let me know. I’m so close to being up and running but I can’t seem to make any real progress on this one. Thanks.



  • @acabrera2012 SOLVED!

    I changed “model.save(config.TRAINING_FILE)” to “model.write(config.TRAINING_FILE)” in train.py