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

MMM-Facial-Recognition won't work

  • Firstly I really appreciate you for making this nice module!
    MMM-Facial-Recognition-Tools-master works perfectly and I get training.xml file ! also i placed it at the right place.
    However, MMM-Facial-Recognition module doesn’t work…
    everytime I try python it says 3 there r errors like below.

    pi@raspberrypi:~/MagicMirror/modules/MMM-Facial-Recognition/facerecognition $ python
    Traceback (most recent call last):
      File "", line 21, in 
        import face
      File "/home/pi/MagicMirror/modules/MMM-Facial-Recognition/facerecognition/", line 10, in 
        import config
      File "/home/pi/MagicMirror/modules/MMM-Facial-Recognition/facerecognition/", line 38, in 
        CONFIG = json.loads(sys.argv[1]);
    IndexError: list index out of range

    I dont get this part -> CONFIG = json.loads(sys.argv[1]);
    and why it cant import face, config.?
    Below is my in facerecognition dir…

    import inspect
    import os
    import json
    import sys
    import platform
    def to_node(type, message):
        print(json.dumps({type: message}))
    _platform = platform.uname()[4]
    path_to_file = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
    # Size (in pixels) to resize images for training and prediction.
    # Don't change this unless you also change the size of the training images.
    FACE_WIDTH = 92
    FACE_HEIGHT = 112
    # Face detection cascade classifier configuration.
    # You don't need to modify this unless you know what you're doing.
    # See:
    HAAR_FACES = path_to_file + '/haarcascade_frontalface.xml'
    HAAR_MIN_SIZE = (30, 30)
    CONFIG = json.loads(sys.argv[1]);
    def get(key):
        return CONFIG[key]
    def get_camera():
        to_node("status", "-" * 20)
            if get("useUSBCam") == False:
                import picam
                to_node("status", "PiCam ausgewählt...")
                cam = picam.OpenCVCapture()
                return cam
                raise Exception
        except Exception:
            import webcam
            to_node("status", "Webcam ausgewählt...")
            return webcam.OpenCVCapture(device_id=0)
        to_node("status", "-" * 20)

    Thanks for reading this and your help !!

  • Moderator

    @angie2601 It expects the config file as an argument on the command line. Are you supposed to call the script manually? The module should call the python script with the appropriate parameters.

  • @Jopyth tnx!! I manged to fix it! Thanks alot 🙂 but I want it to be working face recognition regardless of typing ‘npm start’ everytime. Do you have some ideas??

Log in to reply