• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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.

Facial Recognition - customize your mirror for every user!

Scheduled Pinned Locked Moved Troubleshooting
215 Posts 55 Posters 426.9k Views 57 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.
  • F Offline
    FuX
    last edited by FuX May 7, 2017, 8:14 PM May 7, 2017, 8:13 PM

    Hey

    When i run npm start in “/home/pi/MagicMirror” i am struck at below message:

    pi@raspberrypi:~/MagicMirror $ npm start
    
    > magicmirror@2.1.1 start /home/pi/MagicMirror
    > sh run-start.sh
    
    Starting MagicMirror: v2.1.1
    Loading config ...
    Loading module helpers ...
    Initializing new module helper ...
    Module helper loaded: MMM-Facial-Recognition
    No helper found for module: alert.
    Initializing new module helper ...
    Module helper loaded: updatenotification
    No helper found for module: clock.
    No helper found for module: compliments.
    No helper found for module: currentweather.
    No helper found for module: weatherforecast.
    Initializing new module helper ...
    Module helper loaded: newsfeed
    All module helpers loaded.
    Starting server on port 8080 ...
    Starting server op port 8080 ...
    Server started ...
    Connecting socket for: MMM-Facial-Recognition
    Staring module helper: MMM-Facial-Recognition
    Connecting socket for: updatenotification
    Connecting socket for: newsfeed
    Starting module: newsfeed
    Sockets connected & modules started ...
    Launching application.
    Create new news fetcher for url: http://www.20min.ch/rss/rss.tmpl?type=channel&get=4 - Interval: 300000
    [MMM-Facial-Recognition] Facerecognition started...
    [MMM-Facial-Recognition] Loading training data...
    [MMM-Facial-Recognition] ALGORITHM: LBPH
    [MMM-Facial-Recognition] Training data loaded!
    [MMM-Facial-Recognition] --------------------
    [MMM-Facial-Recognition] PiCam ausgewählt...
    
    /* Magic Mirror Config Sample
     *
     * By Michael Teeuw http://michaelteeuw.nl
     * MIT Licensed.
     */
    
    var config = {
    	port: 8080,
    	ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], // Set [] to allow all IP addresses.
    
    	language: "en",
    	timeFormat: 24,
    	units: "metric",
    
    	modules: [
    		{
    			module: "MMM-Facial-Recognition",
    			classes: "default everyone",
    			config: {
    				recognitionAlgorithm: 1,
    				lbphThreshold: 50,
    				fisherThreshold: 250,
    				eigenThreshold: 3000,
    				useUSBCam: false,
    				trainingFile: "modules/MMM-Facial-Recognition/training.xml",
    				interval: 2,
    				logoutDelay: 15,
    				users: ["Stefan"],
    				defaultClass: "default",
    				everyoneClass: "everyone",
    				welcomeMessage: true
    			}
    		},
    	]
    
    };
    
    /*************** DO NOT EDIT THE LINE BELOW ***************/
    if (typeof module !== "undefined") {module.exports = config;}
    

    python facerecongnition.py also not work:

    pi@raspberrypi:~/MagicMirror/modules/MMM-Facial-Recognition-Tools $ python facerecognition.py
    ['Stefan']
    Using FACE_ALGORITM: 1
    Loading training data...
    Training data loaded!
    Strong:Stefan
    No windowing system, writing face.jpg image
    Traceback (most recent call last):
      File "facerecognition.py", line 153, in 
        clean_shutdown()
    TypeError: clean_shutdown() takes exactly 2 arguments (0 given)
    
    
    1 Reply Last reply Reply Quote 0
    • J Offline
      j.e.f.f Project Sponsor Module Developer
      last edited by j.e.f.f May 9, 2017, 1:44 PM May 8, 2017, 3:57 PM

      So I’ve managed to get this working with a Logitech C170 USB webcam, and I’m pretty stoked!

      I have a few questions:

      • Facial recognition is generally pretty slow… I need to stand in front of the camera for about 10 seconds before I am recognized. Is this normal or a bi-product of the fact that this is a fairly low quality camera… e.g.: if I were to upgrade say to the C920 instead, should I expect better performance? I’ve left the polling setting in config.js at the default 2 seconds – if the recognition were to happen this fast I’d be pretty happy!

      • There is a reference earlier in the thread that the capture resolution can be increased by modifying the module code. Where do I modify this? The c170 can capture natively at 640x480, so I’d like to experiment with capturing both the training images and the real-time facial recognition at this resolution, in an effort to see if I can get better confidence numbers. I’m currently seeing high 40s to mid 50s confidence. At the default threshold of 50, I am often not recognized, but it works more frequently if I increase the threshold to 60. (Training is based on about 50 images all captured from the c170 in representative lighting.) EDIT: one day later and I’m now often seeing confidence in the high 60’s so I needed to increase the threshold to 70.

      • I’d like to experiment with the other recognition algorithms, but I can only get LBPH to work. If I try to use Fisher or Eigen I get an error that the training data has not yet been computed. Training.xml was generated using the appropriate algorithm, and config.js was set to the matching algorithm.

      • With MMM-Facial-Recognition-Tools module, I’m having the same issue as the previous post where I get an error when trying to run tests using facerecognition.py (same error as above). So I need to do my tests with the actual MMM-Facial-Recognition module running on MagicMirror, which as you can imagine is fairly time consuming. Anyone have any insight on getting the test script working?

      For context, I’m opting for a webcam instead of the picam because webcams generally look nicer. I’ve spent HOURS scouring the web for a picam enclosure that didn’t look like a high school engineering project, without finding a single one. The closest I could find is this one by Adafruit but it has two problems:

      • I don’t like that the cover is clear – I don’t want to see the electronics
      • I don’t like how it routes the ribbon cable

      This first point is easily remedied with a can of spray paint, but the second is a little harder to deal with. If anyone has found a nice sleek enclosure for the picam, please share a link!

      Secondly, I like that webcams generally also have a microphone built-in, so that I can also use it for voice control. I REALLY wish I could use this one but I contacted their support and they told me it wouldn’t work at all with the Raspberry Pi. Too bad… was hoping the 4-microphone array would really with not having to yell at my mirror to get it to hear me and I like how sleek it is. Would look quite unassuming sitting on top of my mirror.

      Thanks for the help
      -Jeff

      J 1 Reply Last reply May 9, 2017, 3:06 PM Reply Quote 0
      • J Offline
        j.e.f.f Project Sponsor Module Developer @j.e.f.f
        last edited by May 9, 2017, 3:06 PM

        Also one more thought: I’m thinking of turning the camera 90 degrees so that it takes a vertical image – better chance of capturing faces of people of different heights that – thinking myself as a tall adult vs my kids, 9 and 6 years old. I’m thinking a 2:3 image (or 9:16 in the case of an HD cam) would really work well here to turn a wide FoV to a “tall” FoV – perfect for people standing right in front of the mirror… If I just turn the camera 90 degrees, and use it to train and capture in that orientation, will the facial recognition algorithms work as-is (i.e.: Can they recognize a face turned sideways) or would the module need to be changed to rotate the capture first before feeding into the algorithm?

        1 Reply Last reply Reply Quote 0
        • R Offline
          reaper81
          last edited by Jun 5, 2017, 11:51 AM

          I have read all posts in this thread. Is there realy no answer why the facerecognation in the testtool is so much better than in the MM-Module?

          1 Reply Last reply Reply Quote 0
          • J Offline
            j.e.f.f Project Sponsor Module Developer @paviro
            last edited by Jun 7, 2017, 4:22 AM

            @paviro I had a hard time getting this to play nicely with modules that show and hide themselves. I created a pull-request that addresses this:

            https://github.com/paviro/MMM-Facial-Recognition/pull/48

            Basically I added a lockString config option to each show and hide command, and when combined with another module that also uses a lockString the particular module is only visible when both have removed their respective lock strings.

            See here for details about visibility locking:
            https://github.com/MichMich/MagicMirror/tree/develop/modules

            cheers!

            1 Reply Last reply Reply Quote 0
            • R Offline
              reaper81
              last edited by Jun 11, 2017, 10:30 AM

              hello everyone,

              after update to the new version of the FR-Module i get this error-Massage while starting the MM.

              Starting MagicMirror: v2.1.1
              Loading config …
              Loading module helpers …
              No helper found for module: alert.
              WARNING! Could not load config file. Starting with default configuration. Error found: Error: Cannot find module ‘node_helper’
              Loading module helpers …
              No helper found for module: alert.
              App threw an error during load
              Error: Cannot find module ‘node_helper’
              at Module._resolveFilename (module.js:470:15)
              at Function.Module._resolveFilename (/home/pi/MagicMirror/node_modules/electron/dist/resources/electron.asar/common/reset-search-paths.js:35:12)
              at Function.Module._load (module.js:418:25)
              at Module.require (module.js:498:17)
              at require (internal/module.js:20:19)
              at Object. (/home/pi/MagicMirror/modules/default/updatenotification/node_helper.js:6:18)
              at Object. (/home/pi/MagicMirror/modules/default/updatenotification/node_helper.js:89:3)
              at Module._compile (module.js:571:32)
              at Object.Module._extensions…js (module.js:580:10)
              at Module.load (module.js:488:32)
              …

              Can anybody help me?

              1 Reply Last reply Reply Quote 0
              • J Offline
                j.e.f.f Project Sponsor Module Developer
                last edited by Jun 15, 2017, 7:04 PM

                @paviro I’ve switched to using the Pi cam for facial recognition, and my confidence numbers have improved significantly, but it still takes a good 5 seconds of standing absolutely still looking right at the camera to get it to work. I’ve trained the model with about 40 images of myself standing at various distances from the camera, sometimes looking right at it, other times staring blankly ahead (as if I were looking in the mirror).

                Is 5 seconds the best I can hope for, or does it work faster for others? I have the frequency configured to interval : 1 although I don’t see much difference between 1 and 2 (or anything smaller than 1).

                1 Reply Last reply Reply Quote 0
                • L Offline
                  lepetitnicolas
                  last edited by lepetitnicolas Jun 15, 2017, 8:35 PM Jun 15, 2017, 8:30 PM

                  hello,
                  After a few months of sleep, I wake up my mirror
                  i’ve just update the raspberry and the MagicMirror to the last version
                  also this module (facial recognition) to see if it works better
                  but when i try to make the training.xml with train.py, i’ve this error :

                  Reading training images...
                  --------------------
                  Assign label 1 to Gael
                  Assign label 2 to lepetitnicolas
                  --------------------
                  
                  OpenCV Error: Assertion failed (ssize.area() > 0) in resize, file /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/imgproc/src/imgwarp.cpp, line 1834
                  Traceback (most recent call last):
                    File "train.py", line 98, in 
                      faces.append(prepare_image(filename))
                    File "train.py", line 56, in prepare_image
                      return face.resize(cv2.imread(filename, cv2.IMREAD_GRAYSCALE))
                    File "/home/pi/MagicMirror/modules/MMM-Facial-Recognition-Tools/lib/face.py", line 100, in resize
                      interpolation=cv2.INTER_LANCZOS4)
                  cv2.error: /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/imgproc/src/imgwarp.cpp:1834: error: (-215) ssize.area() > 0 in function resize
                  

                  anyone could help me ?
                  Thanks

                  N 1 Reply Last reply Jun 18, 2017, 12:48 AM Reply Quote 0
                  • N Offline
                    nuckinfutz @lepetitnicolas
                    last edited by Jun 18, 2017, 12:48 AM

                    @lepetitnicolas Just saw this but here is the fix

                    cd home/pi/MagicMirror/modules/MMM-Facial-Recognition-Tools
                    sudo pip install future --upgrade

                    L 1 Reply Last reply Jun 19, 2017, 7:24 PM Reply Quote 0
                    • E Offline
                      EdChamberlain
                      last edited by Jun 19, 2017, 9:59 AM

                      This may not be an appropriate place but is there a good resource / tutorial for setting up / configuring the modules for the mirror? I’m specifically interested in facial recognition and the calendars - so far I only have the basic mirror installed.

                      1 Reply Last reply Reply Quote 0
                      • 1
                      • 2
                      • 16
                      • 17
                      • 18
                      • 19
                      • 20
                      • 21
                      • 22
                      • 18 / 22
                      • 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