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

PiCam



  • We’re using PiCam for MMM-Facial-Recognition
    The camera works well with capture and training but when we start MagicMirror code the picam doesn’t start
    If anyone has any solution please reply fast we have to submit our project soon



  • Same here, I’m getting the following errors on python tools.facerecognition.py

    Remember to set the name list environment variable FACE_USERS
    Loading PiCamera
    PiCamera loaded
    Loading training data...
    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))0x6c405410 (ENOSPC)
    mmal: mmal_connection_enable: output port couldn't be enabled
    Exception in thread Thread-1:
    Traceback (most recent call last):
      File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
        self.run()
      File "/home/pi/MagicMirror/modules/MMM-Facial-Recognition-OCV3/lib/common/picam.py", line 25, in run
        with picamera.PiCamera() as camera:
      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
    
    Training data loaded!
    OpenCV Error: Assertion failed (!buf.empty() && buf.isContinuous()) in imdecode_, file /home/pi/opencv/modules/imgcodecs/src/loadsave.cpp, line 637
    Traceback (most recent call last):
      File "tools.facerecognition.py", line 45, in 
        frame = camera.read()
      File "/home/pi/MagicMirror/modules/MMM-Facial-Recognition-OCV3/lib/common/picam.py", line 55, in read
        image = cv2.imdecode(data, 1)
    cv2.error: /home/pi/opencv/modules/imgcodecs/src/loadsave.cpp:637: error: (-215) !buf.empty() && buf.isContinuous() in function imdecode_
    
    


  • After more fiddling, I get this in terminal:

    [MMM-Facial-Recognition-OCV3] Facerecognition started...
    [MMM-Facial-Recognition-OCV3] Loading training data...
    [MMM-Facial-Recognition-OCV3] Training data loaded!
    [MMM-Facial-Recognition-OCV3] --------------------
    [MMM-Facial-Recognition-OCV3] PiCam loaded...
    Whoops! There was an uncaught exception...
    { 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))0x6c513840 (ENOSPC)
    mmal: mmal_connection_enable: output port couldn't be enabled
    Exception in thread Thread-1:
    Traceback (most recent call last):
      File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
        self.run()
      File "/home/pi/MagicMirror/modules/MMM-Facial-Recognition-OCV3/lib/common/picam.py", line 25, in run
        with picamera.PiCamera() as camera:
      File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line 433, in __init__
        self._init_preview()
      File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line 513, in _init_preview
        self, self._camera.outputs[self.CAMERA_PREVIEW_PORT])
      File "/usr/lib/python2.7/dist-packages/picamera/renderers.py", line 558, in __init__
        self.renderer.inputs[0].connect(source).enable()
      File "/usr/lib/python2.7/dist-packages/picamera/mmalobj.py", line 2212, in enable
        prefix="Failed to enable connection")
      File "/usr/lib/python2.7/dist-packages/picamera/exc.py", line 184, in mmal_check
        raise PiCameraMMALError(status, prefix)
    PiCameraMMALError: Failed to enable connection: Out of resources
    
    OpenCV Error: Assertion failed (!buf.empty() && buf.isContinuous()) in imdecode_, file /home/pi/opencv/modules/imgcodecs/src/loadsave.cpp, line 637
    Traceback (most recent call last):
      File "modules/MMM-Facial-Recognition-OCV3/lib/mm/facerecognition.py", line 69, in 
        image = camera.read()
      File "/home/pi/MagicMirror/modules/MMM-Facial-Recognition-OCV3/lib/common/picam.py", line 55, in read
        image = cv2.imdecode(data, 1)
    cv2.error: /home/pi/opencv/modules/imgcodecs/src/loadsave.cpp:637: error: (-215) !buf.empty() && buf.isContinuous() in function imdecode_
    
    
        at PythonShell.parseError (/home/pi/MagicMirror/modules/MMM-Facial-Recognition-OCV3/node_modules/python-shell/index.js:190:17)
        at terminateIfNeeded (/home/pi/MagicMirror/modules/MMM-Facial-Recognition-OCV3/node_modules/python-shell/index.js:98:28)
        at ChildProcess. (/home/pi/MagicMirror/modules/MMM-Facial-Recognition-OCV3/node_modules/python-shell/index.js:88:9)
        at ChildProcess.emit (events.js:182:13)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)
      executable: 'python',
      options: null,
      script:
       'modules/MMM-Facial-Recognition-OCV3/lib/mm/facerecognition.py',
      args:
       [ '{"threshold":80,"useUSBCam":false,"trainingFile":"/home/pi/MagicMirror/modules/MMM-Facial-Recognition-OCV3/training.xml","interval":2,"logoutDelay":15,"users":["Stiofan","Gab"],"defaultClass":"default","everyoneClass":"everyone","welcomeMessage":true}' ],
      exitCode: 1 }
    MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
    If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues