MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord
    MagicMirror² v2.20.0 is available! For more information about this release, check out this topic.

    MMM-Facial-Recognition won't work

    Troubleshooting
    2
    3
    2020
    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
      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
        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
          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 Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy