Read the statement by Michael Teeuw here.
[MMM-Motion-Detection] Motion Detection through PiCam or USB Webcam
-
Description
With this module your mirror will only turn on when it detects motion through the Raspberry Pi’s PiCam or a USB webcam. It also emits
motion-detected
andmotion-stopped
notifications that other modules can use.This was ported from Paviro’s MMM-Facial-Recognition module mostly to get the python code for camera usage and OpenCV support. Thanks Paviro!
Download
[card:dmcinnes/MMM-Motion-Detection]
-
I can’t seem to get this to initialize. I can capture images with my picam and show the preview in python, but I get this every time I start MM with this plugin:
0|MagicMir | [MMM-Motion-Detection] Motion Detection started... 0|MagicMir | [MMM-Motion-Detection] -------------------- 0|MagicMir | [MMM-Motion-Detection] PiCam starting... 0|MagicMir | [MMM-Motion-Detection] Camera Failed to Initialize! Shutting Down. 0|MagicMir | Whoops! There was an uncaught exception... 0|MagicMir | { Error: process exited with code 1 0|MagicMir | at terminateIfNeeded (/home/pi/MagicMirror/modules/MMM-Motion-Detection/node_modules/python-shell/index.js:100:23) 0|MagicMir | at ChildProcess. (/home/pi/MagicMirror/modules/MMM-Motion-Detection/node_modules/python-shell/index.js:88:9) 0|MagicMir | at emitTwo (events.js:106:13) 0|MagicMir | at ChildProcess.emit (events.js:191:7) 0|MagicMir | at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12) 0|MagicMir | executable: 'python', 0|MagicMir | options: null, 0|MagicMir | script: 'modules/MMM-Motion-Detection/motiondetection/motiondetection.py', 0|MagicMir | args: [ '{"useUSBCam":false,"interval":8,"motionStopDelay":120,"detectionThreshold":1000,"turnOffDisplay":true}' ], 0|MagicMir | exitCode: 1 }
-
@jasonarends Have you tested your Pi camera to make sure it is properly connected and the Pi is aware of the camera? Have you enabled the camera via the Pi configuration interface?
-
Yes, this works:
raspistill -o cam.jpg
I see the preview on the monitor and the file gets saved.
I added some additional debugging to the python code in this module and it is giving me a Null back when it does the .read() instead of an array. I’m not sure what’s different unless it has to do with the python-shell not working right or something in the picam.py code with the buffers.
If I manually call the function in Python in the same way this code does, and it gives me back an array and works fine:
pi@pi-3-mm:~/MagicMirror/modules/MMM-Motion-Detection/motiondetection $ python Python 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170124] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import picam >>> cam = picam.OpenCVCapture() >>> cam.start() >>> cam.read() array([[[ 24, 31, 58], [ 22, 29, 56], [ 21, 28, 55], ..., [ 12, 15, 23], [ 12, 15, 23], [ 12, 15, 23]], [[ 22, 29, 56], [ 23, 30, 57], [ 21, 28, 55], ..., [ 13, 16, 24], [ 12, 15, 23], [ 12, 15, 23]], [[ 23, 30, 57], [ 24, 31, 58], [ 21, 28, 55], ..., [ 14, 16, 24], [ 13, 16, 24], [ 12, 15, 23]], ..., [[131, 145, 173], [129, 143, 171], [128, 142, 170], ..., [ 25, 31, 72], [ 21, 27, 68], [ 27, 33, 74]], [[129, 143, 171], [129, 143, 171], [129, 143, 171], ..., [ 28, 34, 75], [ 23, 31, 71], [ 24, 32, 72]], [[129, 143, 171], [130, 144, 172], [130, 144, 172], ..., [ 31, 37, 78], [ 25, 33, 73], [ 21, 29, 69]]], dtype=uint8)
-
@jasonarends try to use the default interval of 1, there may be some initialization issues with larger intervals.
-
Hi,
I use your module. Thank you for building this.
But I have some tipps, that i will write down. Maybe the will help others.At first after install your module, it power off my monitor, but didn´t power on after that. I see only a black page. So after i changed the order to activate and deactivete from “tvservice” to “vcgencmd display power 1” my monitor power of but didn´t power on again, but now it was really off. After that I delete at the node-helper.js some lines, that will test if the monitor was active.
Thats it, now everythings works fine.
BUt is it possible that your module don´t work together with Paviro’s MMM-Facial-Recognition module?? I use it and have several users. But now the detection of faces didn´t work.
Maybe you can help me.
Greets gismo
-
@gismo2006 unfortunately since the module was forked from the facial recognition one and uses the same underlying library for camera control, you will not be able to use both at the same time.
-
Hi,
im trying to get it running, but for any reason it does not work for me.
I checked the functionallity of the Picam with a test shot and it works fine.
The command vcgencmd display_power 0/1 works here pretty smoth so i changed it also in node_helper.js , but it still does not turn off/on.any ideas?
thanks in advance. -
Hello,
I’m trying to complete the setup, but I’m facing this error: ValueError: need more than 3 values to unpack. I have a Logitech 1080 HD USB Webcam and Raspberry Pi 3. How can I fix this? I checked the topics here on forum, but there’s no solution so far.
Raspberry Pi face recognition project steps by Jasper Zuyderwijk guide to write my paper for me
-
I have had Genius WebCam 480p, old one, but i really loved it. For streams it wasn’t good, that’s why I changed it and now i can stream my playing online slots.io