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

MMM-Facial-Recognition



  • hello everyone,
    First of all,thank you very much for face recognition on smart mirror @paviro
    but ı stuck somewhere
    ı did all the steps but ı’m using raspberry pi camera and magic mirror does not turn on when I start
    but in the capture and train part is running smoothly
    what should ı do
    I’m waiting for your help



  • I hope you are talking about capture part and train part in MMM-Facial-recognition-Tools. It works fine but in mmm-facial recognition folder there is a config .py file which created the problem throwing config=jsonl.oads(sys arg…) // I do not remmeber.
    I just figured out few hours ago.
    TRy this code

    #!/usr/bin/python

    coding: utf8

    “”"MMM-Facial-Recognition - MagicMirror Module
    Face Recognition script config
    The MIT License (MIT)

    Copyright © 2016 Paul-Vincent Roll (MIT License)
    Based on work by Tony DiCola (Copyright 2013) (MIT License)
    “”"
    import inspect
    import os
    import json
    import sys
    import platform

    def to_node(type, message):
    print(json.dumps({type: message}))
    sys.stdout.flush()

    _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: http://docs.opencv.org/modules/objdetect/doc/cascade_classification.html

    HAAR_FACES = path_to_file + ‘/haarcascade_frontalface.xml’
    HAAR_SCALE_FACTOR = 1.3
    HAAR_MIN_NEIGHBORS = 4
    HAAR_MIN_SIZE = (30, 30)

    #CONFIG = json.loads(sys.argv[1]);
    CONFIG={

        "recognitionAlgorithm": 1,
        
        "lbphThreshold": 50,
        "fisherThreshold": 250,
        "eigenThreshold": 3000,
        
        "useUSBCam": False,
        
        "trainingFile": '/home/pi/MagicMirror/modules/MMM-Facial-Recognition/training.xml',
        
        "interval": 2,
        
        "logoutDelay": 15,
        
        "users": ['user1'],
        
        "defaultClass": "default",
        
        "everyoneClass": "everyone",
        
        "welcomeMessage": True
    

    }

    def get(key):
    return CONFIG[key]

    def get_camera():
    to_node(“status”, “-” * 20)
    try:
    if get(“useUSBCam”) == False:
    #import picam
    from imutils.video import VideoStream
    to_node(“status”, “PiCam Enabled…”)
    vs = VideoStream(usePiCamera=True,resolution=(640,480)).start()
    #cam = picam.OpenCVCapture()
    #cam.start()
    return vs
    else:
    raise Exception
    except Exception:
    import webcam
    to_node(“status”, “Webcam ausgewählt…”)
    return webcam.OpenCVCapture(device_id=0)
    to_node(“status”, “-” * 20)

    replace the config.py code with above code.
    I was able to fix the error with this. Hope it helps!



  • @anandprabhat567 canu edit this and change the marks before and after to the backtic char (left of the 1 key), need three before and after