MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    MMM-Facial-Recognition won't work

    Scheduled Pinned Locked Moved Troubleshooting
    3 Posts 2 Posters 2.3k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      angie2601
      last edited by yawns

      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 facerecognition.py it says 3 there r errors like below.

      pi@raspberrypi:~/MagicMirror/modules/MMM-Facial-Recognition/facerecognition $ python facerecognition.py
      Traceback (most recent call last):
        File "facerecognition.py", line 21, in 
          import face
        File "/home/pi/MagicMirror/modules/MMM-Facial-Recognition/facerecognition/face.py", line 10, in 
          import config
        File "/home/pi/MagicMirror/modules/MMM-Facial-Recognition/facerecognition/config.py", 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 config.py in facerecognition dir…

      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]);
      
      def get(key):
          return CONFIG[key]
      
      def get_camera():
          to_node("status", "-" * 20)
          try:
              if get("useUSBCam") == False:
                  import picam
                  to_node("status", "PiCam ausgewählt...")
                  cam = picam.OpenCVCapture()
                  cam.start()
                  return cam
              else:
                  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 !!

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        Jopyth Moderator @angie2601
        last edited by

        @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.

        Helpful sticky: How to troubleshoot

        A 1 Reply Last reply Reply Quote 0
        • A Offline
          angie2601 @Jopyth
          last edited by

          @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??

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Enjoying MagicMirror? Please consider a donation!
          MagicMirror created by Michael Teeuw.
          Forum managed by Sam, technical setup by Karsten.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy