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-Face-Reco-DNN - All new Face Recognition

    Scheduled Pinned Locked Moved Utilities
    36 Posts 14 Posters 21.6k Views 17 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.
    • C Offline
      ChrizZz @nischi
      last edited by

      @nischi said in MMM-Face-Reco-DNN - All new Face Recognition:

      @ChrizZz
      Sound a little bit long to me, for me it works faster. But it took a while until they are startet. Do you use default settings?

      My logs file is also a bit weird:

      [MMM-Face-Reco-DNN] Users ChrizZz logged in.
      CECControl received (current, new): off on
      CECControl received (current, new): on off
      CECControl received (current, new): off on
      CECControl received (current, new): on off
      CECControl received (current, new): off on
      CECControl received (current, new): on off
      [MMM-Face-Reco-DNN] Users ChrizZz logged out.
      CECControl received (current, new): off on
      CECControl received (current, new): on off
      CECControl received (current, new): off on
      CECControl received (current, new): on off
      [MMM-Face-Reco-DNN] Users ChrizZz logged in.
      CECControl received (current, new): off on
      CECControl received (current, new): on off
      [MMM-Face-Reco-DNN] Users ChrizZz logged out.
      [MMM-Face-Reco-DNN] Users ChrizZz logged in.
      CECControl received (current, new): off on
      CECControl received (current, new): on off
      CECControl received (current, new): off on
      CECControl received (current, new): on off
      [MMM-Face-Reco-DNN] Users ChrizZz logged out.
      CECControl received (current, new): off on
      CECControl received (current, new): on off
      CECControl received (current, new): off on
      CECControl received (current, new): on off
      
      

      This is a 3min part of the logs and the 1st time I was in front of the mirror and recognized by the module this evening.

      My settings are:

      		{
      			module: 'MMM-CECControl',
          				config: {
            					  // Comport of your Raspberry Pi
            					  comport: 'RPI',
            					  // Turn the TV off if the Mirror start
             					 offOnStartup: true
          					}
      		},
      		{
          			module: 'MMM-MotionControl',
         				 config: {
           					   // Delay to turn the TV off
             						 delay: 60000,
             					 // Interval to check modules
       					       interval: 5000,
       				       // Use the module MMM-Facial-Recognition-OCV3
        				      useFacialRecognitionOCV3: false,
         				     // Use the module MMM-Face-Reco-DNN
         				     useMMMFaceRecoDNN: true,
         				     // Array where tv should be on
      				        ontime: []
      					    }
      		},
      		{
      			module: 'MMM-Face-Reco-DNN',
          				config: {
            					// Logout 15 seconds after user was not detecte anymore, if they will be detected between this 15 Seconds, they delay will start again
            					logoutDelay: 30000,
            					// How many time the recognition starts, with a RasPi 3+ it would be good every 2 seconds
            					checkInterval: 2000,
            					// Module set used for strangers and if no user is detected
            					defaultClass: 'default',
            					// Set of modules which should be shown for every user
            					everyoneClass: 'everyone',
            					// XML to recognize with haarcascae
            					cascade: 'modules/MMM-Face-Reco-DNN/tools/haarcascade_frontalface_default.xml',
            					// Pre encoded pickle with the faces
            					encodings: 'modules/MMM-Face-Reco-DNN/tools/encodings.pickle',
            					// You wanna use pi camera or usb / builtin (1 = raspi camera, 0 = other camera)
            					usePiCamera: 1,
            					// Method of face detection (dnn = deep neural network, haar = haarcascade)
            					method: 'dnn',
            					// Which face detection model to use. "hog" is less accurate but faster on CPUs. "cnn" is a more accurate deep-learning model which is GPU/CUDA accelerated (if available).
            					detectionMethod: 'hog',
            					// How fast in ms should the modules hide and show (face effect)
            					animationSpeed: 0,
            					// Path to Python to run the face recognition (null / '' means default path)
            					pythonPath: null,
            					// Should shown welcome message over alert module from MagicMirror
            					welcomeMessage: true
          					}
      		},
      
      1 Reply Last reply Reply Quote 0
      • D Offline
        dragontattoo
        last edited by

        Is it working fine??

        C 1 Reply Last reply Reply Quote 0
        • C Offline
          ChrizZz @dragontattoo
          last edited by

          @dragontattoo said in MMM-Face-Reco-DNN - All new Face Recognition:

          Is it working fine??

          Depends on how you define working fine…The face recognition is working quite good, setting it up is easy with the advice you get in this thread. For me it’s just the “slow” reaction to activate the display which is an issue. But I’m optimistic that there is a way to solve it and I have a special environment with a display which hasn’t CEC control.

          nischiN 1 Reply Last reply Reply Quote 0
          • nischiN Offline
            nischi @ChrizZz
            last edited by

            @ChrizZz
            Yes i know this issue. i’m currently working on a bugfix. will tell you if i’m done.

            1 Reply Last reply Reply Quote 2
            • I Offline
              Ivanov_d
              last edited by

              I am turning on the monitor using a PIR sensor and it is instant. Keep in mind that it also depends on your monitor, some are slower to respond - this is my second monitor, the first one was very slow to respond to any HDMI related commands.

              1 Reply Last reply Reply Quote 0
              • C Offline
                ChrizZz
                last edited by

                I have a new strange error and I think it’s just if I restart mm with “pm2 restart mm”. If I reboot my pi, everything is fine.

                SyntaxError: Unexpected token m in JSON at position 0
                    at JSON.parse (<anonymous>:null:null)
                    at PythonShell.asJson (/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:375:21)
                    at /home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:326:42
                    at Array.forEach (<anonymous>:null:null)
                    at PythonShell.receiveInternal (/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:322:15)
                    at PythonShell.receiveStderr (/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:306:21)
                    at Socket.<anonymous> (/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:109:22)
                    at Socket.emit (events.js:182:13)
                    at addChunk (_stream_readable.js:279:12)
                    at readableAddChunk (_stream_readable.js:260:13)
                    at Socket.Readable.push (_stream_readable.js:219:10)
                    at Pipe.onread (net.js:636:20)
                
                SyntaxError: Unexpected token T in JSON at position 0
                    at JSON.parse (<anonymous>:null:null)
                    at PythonShell.asJson (/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:375:21)
                    at /home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:326:42
                    at Array.forEach (<anonymous>:null:null)
                    at PythonShell.receiveInternal (/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:322:15)
                    at PythonShell.receiveStderr (/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:306:21)
                    at Socket.<anonymous> (/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:109:22)
                    at Socket.emit (events.js:182:13)
                    at addChunk (_stream_readable.js:279:12)
                    at readableAddChunk (_stream_readable.js:260:13)
                    at Socket.Readable.push (_stream_readable.js:219:10)
                    at Pipe.onread (net.js:636:20)
                
                { Error: mmal: mmal_vc_port_enable: failed to enable port vc.null_sink:in:0(OPQV): ENOSPC
                mmal: mmal_port_enable: failed to enable connected port (vc.null_sink:in:0(OPQV))0x631b2f0 (ENOSPC)
                mmal: mmal_connection_enable: output port couldn't be enabled
                Traceback (most recent call last):
                  File "modules/MMM-Face-Reco-DNN/tools/facerecognition.py", line 56, in <module>
                    vs = VideoStream(usePiCamera=True).start()
                  File "/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/tools/stream.py", line 18, in __init__
                    framerate=framerate)
                  File "/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/tools/picam.py", line 10, in __init__
                    self.camera = PiCamera()
                  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 433, in __init__
                    self._init_preview()
                  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 513, in _init_preview
                    self, self._camera.outputs[self.CAMERA_PREVIEW_PORT])
                  File "/usr/lib/python3/dist-packages/picamera/renderers.py", line 558, in __init__
                    self.renderer.inputs[0].connect(source).enable()
                  File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 2212, in enable
                    prefix="Failed to enable connection")
                  File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
                    raise PiCameraMMALError(status, prefix)
                picamera.exc.PiCameraMMALError: Failed to enable connection: Out of resources
                
                    at PythonShell.parseError (/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:268:21)
                    at terminateIfNeeded (/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:139:32)
                    at ChildProcess.<anonymous> (/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:131:13)
                    at ChildProcess.emit (events.js:182:13)
                    at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)
                
                  executable: 'python3',
                  options: null,
                  script: 'modules/MMM-Face-Reco-DNN/tools/facerecognition.py',
                  args:
                   [ '--cascade=modules/MMM-Face-Reco-DNN/tools/haarcascade_frontalface_default.xml',
                     '--encodings=modules/MMM-Face-Reco-DNN/tools/encodings.pickle',
                     '--usePiCamera=1',
                     '--method=dnn',
                     '--detectionMethod=hog',
                     '--interval=2000',
                     '--output=0' ],
                  exitCode: 1 }
                
                1 Reply Last reply Reply Quote 0
                • B Offline
                  Blauenfeldt
                  last edited by

                  I get this too, when my PI can’t connect to the camera. I know that, because if i use
                  Raspistill -o s.jpg
                  I will get an error there too. A reboot seems to fix it though. I don’t know what makes it happen, but i suspect the cable.

                  S 1 Reply Last reply Reply Quote 0
                  • S Offline
                    sdetweil @Blauenfeldt
                    last edited by

                    @Blauenfeldt the python code returns an error, but the module does not expect it, and fails.

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    1 Reply Last reply Reply Quote 0
                    • R Offline
                      rjlinden
                      last edited by

                      Will this work if the camera is rotated? If not, can you tell me where I need to change the code?

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        hANNEsLUL
                        last edited by

                        Hi,

                        when im trying to install the face_recogtnition I’m getting this error code:

                        Does anybody know how to fix this/what is causing this?
                        Sorry if it’s obvious, im a super noob with this kind of stuff

                        Cheers

                        pi@raspberrypi:~ $ pip install face_recognition
                        Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
                        Collecting face_recognition
                          Using cached https://files.pythonhosted.org/packages/1e/95/f6c9330f54ab07bfa032bf3715c12455a381083125d8880c43cbe76bb3d0/face_recognition-1.3.0-py2.py3-none-any.whl
                        Requirement already satisfied: dlib>=19.7 in ./.local/lib/python2.7/site-packages (from face_recognition) (19.19.0)
                        Collecting face-recognition-models>=0.3.0 (from face_recognition)
                          Downloading https://www.piwheels.org/simple/face-recognition-models/face_recognition_models-0.3.0-py2.py3-none-any.whl (100.6MB)
                            99% |████████████████████████████████| 100.6MB 1.7MB/s eta 0:00:01
                        Exception:
                        Traceback (most recent call last):
                          File "/usr/lib/python2.7/dist-packages/pip/_internal/cli/base_command.py", line 143, in main
                            status = self.run(options, args)
                          File "/usr/lib/python2.7/dist-packages/pip/_internal/commands/install.py", line 338, in run
                            resolver.resolve(requirement_set)
                          File "/usr/lib/python2.7/dist-packages/pip/_internal/resolve.py", line 102, in resolve
                            self._resolve_one(requirement_set, req)
                          File "/usr/lib/python2.7/dist-packages/pip/_internal/resolve.py", line 256, in _resolve_one
                            abstract_dist = self._get_abstract_dist_for(req_to_install)
                          File "/usr/lib/python2.7/dist-packages/pip/_internal/resolve.py", line 209, in _get_abstract_dist_for
                            self.require_hashes
                          File "/usr/lib/python2.7/dist-packages/pip/_internal/operations/prepare.py", line 283, in prepare_linked_requirement
                            progress_bar=self.progress_bar
                          File "/usr/lib/python2.7/dist-packages/pip/_internal/download.py", line 836, in unpack_url
                            progress_bar=progress_bar
                          File "/usr/lib/python2.7/dist-packages/pip/_internal/download.py", line 673, in unpack_http_url
                            progress_bar)
                          File "/usr/lib/python2.7/dist-packages/pip/_internal/download.py", line 897, in _download_http_url
                            _download_url(resp, link, content_file, hashes, progress_bar)
                          File "/usr/lib/python2.7/dist-packages/pip/_internal/download.py", line 617, in _download_url
                            hashes.check_against_chunks(downloaded_chunks)
                          File "/usr/lib/python2.7/dist-packages/pip/_internal/utils/hashes.py", line 48, in check_against_chunks
                            for chunk in chunks:
                          File "/usr/lib/python2.7/dist-packages/pip/_internal/download.py", line 585, in written_chunks
                            for chunk in chunks:
                          File "/usr/lib/python2.7/dist-packages/pip/_internal/utils/ui.py", line 159, in iter
                            for x in it:
                          File "/usr/lib/python2.7/dist-packages/pip/_internal/download.py", line 574, in resp_read
                            decode_content=False):
                          File "/usr/share/python-wheels/urllib3-1.24.1-py2.py3-none-any.whl/urllib3/response.py", line 494, in stream
                            data = self.read(amt=amt, decode_content=decode_content)
                          File "/usr/share/python-wheels/urllib3-1.24.1-py2.py3-none-any.whl/urllib3/response.py", line 442, in read
                            data = self._fp.read(amt)
                          File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/filewrapper.py", line 63, in read
                            self._close()
                          File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/filewrapper.py", line 50, in _close
                            self.__callback(self.__buf.getvalue())
                          File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/controller.py", line 275, in cache_response
                            self.serializer.dumps(request, response, body=body),
                          File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/serialize.py", line 87, in dumps
                            ).encode("utf8"),
                        MemoryError
                        G 1 Reply Last reply Reply Quote 0
                        • G Offline
                          gaudouy @hANNEsLUL
                          last edited by

                          @hANNEsLUL
                          Try this :

                          pip --no-cache-dir install face_recognition
                          -python setup.py install
                          
                          H 1 Reply Last reply Reply Quote 0
                          • G Offline
                            gaudouy
                            last edited by

                            What is the best camera for this module ?
                            Pi NoIR Camera V2
                            alt text
                            https://www.raspberrypi.org/products/pi-noir-camera-v2/

                            Or

                            Camera Module V2
                            alt text
                            https://www.raspberrypi.org/products/camera-module-v2/

                            Thanks for advance :)

                            1 Reply Last reply Reply Quote 0
                            • H Offline
                              hANNEsLUL @gaudouy
                              last edited by

                              @gaudouy
                              Thank you, seems like that worked.

                              But now I am getting following error when I’m trying to run “encode.py”

                              Python 3.7.3 (/usr/bin/python3)
                              >>> %Run encode.py
                              Traceback (most recent call last):
                                File "/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/tools/encode.py", line 5, in <module>
                                  from imutils import paths
                              ModuleNotFoundError: No module named 'imutils'
                              >>> 
                              

                              But when I’m installing “imutils” using “pip install imutils” I am getting no error, but following message:

                              Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
                              Requirement already satisfied: imutils in ./.local/lib/python2.7/site-packages (0.5.3)
                              

                              Any Idea how to fix that?

                              And to your best camera question for this module, I’m using the PiCamera Module v.2, but I can’t tell you how good its working, since the Face-Reco is not working yet…

                              1 Reply Last reply Reply Quote 0
                              • B Offline
                                boppersnr @nischi
                                last edited by

                                @nischi
                                First off, I love your module. Well done. Its lots of fun.

                                Question - How can I display the frame/view of the camera on the magic mirror?
                                I would like to see what the camera sees on the screen in Magic Mirror. So I can see the display and the little green boxes with the names of the faces it recognises. Do you know what I would need to do to display the camera frame with the facial recognition code running the scans/outputs on screen?

                                A nischiN 2 Replies Last reply Reply Quote 1
                                • G Offline
                                  ghiesseldorf @nischi
                                  last edited by

                                  @nischi If a user who isn’t known by Face-Reco-DNN moves in front of the camera, is a notification message generated and picked up by MMM-MotionControl? It doesn’t look like the “default” and/or “everyone” classes toggles the screen to un-blank. I was expecting that ANY motion (changes in the capture frames from the camera) would un-blank, but I’m not seeing this behavior. No log-in message gets written to the log.

                                  1 Reply Last reply Reply Quote 0
                                  • A Offline
                                    Alphons @boppersnr
                                    last edited by

                                    @boppersnr i also want to know.

                                    1 Reply Last reply Reply Quote 0
                                    • nischiN Offline
                                      nischi @boppersnr
                                      last edited by

                                      @boppersnr said in MMM-Face-Reco-DNN - All new Face Recognition:

                                      uld like to see what the camera sees on the screen in Magic Mirror. So I can see the display and the little green boxes with the names of the faces it recognises. Do you know what I would need to do to display the camera frame with the facial recognition code running the scans/outputs on screen?

                                      This feature is not implemented, sorry. Maybe create a ticket in github?

                                      1 Reply Last reply Reply Quote 0
                                      • M Offline
                                        Mattheww
                                        last edited by

                                        @nischi In my case classes doesn’t work. I was testing this at a bunch of different modules and always was the same resault, nothing change if classes was defined or not. The face recognition is working I tested it with python. But in modules MMM-Face-Reno-DNN I can’t run classes. Whats more I need to run or where I need to look for a trouble and what can I do to solve it.

                                        1 Reply Last reply Reply Quote 0
                                        • A Offline
                                          Aquamannno @nischi
                                          last edited by

                                          @nischi when I bring this up only a black screen appears with me listing my name but what about the rest of the modules in the magic mirror could be nice with a photo of the recognized precision I find only this (jimbydude / MMM-Face-Multi -User-Recognition-SMAI)
                                          is picked up by magic mirror without error and stops you who are so incredibly good please come up with a variant with photo and welcome greetings.looking forward to the changes. and on whore 1000 thanks.
                                          Sincerely an unlearned raspberry pi owns rpi4 8g hq camera.
                                          Roy Bråthe Norwar

                                          1 Reply Last reply Reply Quote 0

                                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                          With your input, this post could be even better 💗

                                          Register Login
                                          • 1
                                          • 2
                                          • 2 / 2
                                          • 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