Read the statement by Michael Teeuw here.
Motion Detector
-
Thanks for the quick help. I also found the line in motiondetector.js a bit strange (why the semicolon within the parenthesis…) but as I don’t know JS or details about the code, I couldn’t judge.
I still have the same effect (blank screen) but the new error message is
Jul 17 23:16:55 me startMagicMirror.sh[445]: ** Message: console message: [native code] @0: Starting module: motiondetector Jul 17 23:16:55 me startMagicMirror.sh[445]: ** Message: console message: http://localhost:8080/modules/motiondetector//diff-cam-engine.js @81: TypeError: undefined is not an object (evaluating '(navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia).call')Maybe all these things give empty? As a workaround I surrounded the function by
function requestWebcam() { var self = this; method = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia); if ( !! method ) { .... } }Now at least the other modules load successfully.
However, the modules don’t get deactivated after some minutes :-/ I assume that one of these navigator methods is needed for the motiondetector to work? If I look at https://developer.mozilla.org/en/docs/Web/API/Navigator/getUserMedia they seem anyway outdated? How would the user grand permission in a headless setup? Does somebody know if they are supported by the Midori browser? -
@Hawking As far as I know electron exposes the audio and video access, but in midori you probably need to allow the access manually
-
Hi, I’m a total noob to all this, but have recently started a project to build a magic mirror. I’ve got MagicMirror setup, and have the modules I want working. Now I’d like to use the motiondetector module, but although it appears to run without any error, the monitor itself is not turning off.
I’ve tested the camera module and that is working, and I can see an image / record video etc. I’ve also tested running the tvservice commands directly and both of these work as expected:
/opt/vc/bin/tvservice -o
/opt/vc/bin/tvservice --preferred && sudo chvt 6 && sudo chvt 7Only change I have made is to the timeout (30000 so I’m not waiting for too long before the screen should turn off).
My config.js has the following entry for motiondetector:
/* Magic Mirror Config Sample * * By Michael Teeuw http://michaelteeuw.nl * MIT Licensed. * * For more information how you can configurate this file * See https://github.com/MichMich/MagicMirror#configuration * */ var config = { port: 8080, ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1","192.168.7.4"], // Set [] to allow all IP addresses // or add a specific IPv4 of 192.168.1.5 : // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.1.5"], // or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format : // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"], language: "en", timeFormat: 24, units: "metric", modules: [ { module: "alert", }, { module: "updatenotification", position: "top_bar" }, { module: "clock", position: "top_left" }, { module: "calendar", header: "UK Holidays", position: "top_left", config: { calendars: [ { symbol: "calendar-check-o ", url: "webcal://www.gov.uk/bank-holidays/england-and-wales.ics" } ] } }, { module: "currentweather", position: "top_right", config: { location: "London", locationID: "xxxxxxx", //ID from http://www.openweathermap.org/help/city_list.txt appid: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } }, { module: "weatherforecast", position: "top_right", header: "Weather Forecast", config: { location: "London", locationID: "xxxxxxx", //ID from http://www.openweathermap.org/help/city_list.txt appid: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } }, { module: "newsfeed", position: "bottom_bar", config: { feeds: [ { title: "BBC News", url: "http://feeds.bbci.co.uk/news/rss.xml?edition=uk" }, { title: "BBC London", url: "http://feeds.bbci.co.uk/news/england/london/rss.xml" }, ], showSourceTitle: true, showPublishDate: true } }, { module: 'MMM-UKNationalRail', position: 'top_left', header: 'Departures', //Optional - delete this line to turn OFF the header completely config: { stationCode: 'xxx', // CRS code for station app_id: 'xxxxxxx', // TransportAPI App ID app_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // TransportAPI App Key maxResults: 5, //Optional - Maximum results to display. showOrigin: false //Optional - Show the origin of the train in the table } }, { module: 'MMM-Tube-Status', position: 'top_left', header: 'Tube Status', config: { show_all: true } }, { module: 'MMM-UKLiveBusStopInfo', position: 'top_left', header: 'Departures', //Optional - delete this line to turn OFF the header completely config: { atcocode: 'xxxxxxxxxx', // ATCO code for specific bus stop app_id: 'xxxxxxx', // TransportAPI App ID app_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // TransportAPI App Key limit: 5, // Optional - Maximum results to display. nextBuses: 'yes', // Optional - Use expensive RealTime info from NextBuses showRealTime: true, // Optional - show realtime departure info showDelay: true // Optional - show delay in minutes based on Real Time info vs Time table } }, { module: 'MMM-SystemStats', position: 'bottom_right', // This can be any of the regions. classes: 'small dimmed', // Add your own styling. Optional. config: { updateInterval: 10000, animationSpeed: 0, align: 'left', // align labels //header: 'System Stats', // This is optional }, }, { module: "MMM-ip", position: "bottom_right" }, { module: 'MMM-Remote-Control' // uncomment the following line to show the URL of the remote control on the mirror // , position: 'bottom_left' // you can hide this module afterwards from the remote control itself }, { module: 'motiondetector' }, ] }; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") {module.exports = config;}Weird thing is, if I try to have a config section in the config.js with the timeout, and restart MagicMirror, I get an error that the config.js is corrupt. But if I remove the config part, MagicMirror loads without error. MM log below:
0|mm | Connecting socket for: MMM-ip 0|mm | Starting module helper: MMM-ip 0|mm | Connecting socket for: MMM-Remote-Control 0|mm | Starting node helper for: MMM-Remote-Control 0|mm | Connecting socket for: motiondetector 0|mm | Sockets connected & modules started ... 0|mm | monitor on: true 0|mm | monitor :state 0x120006 [DVI DMT (82) RGB full 16:9], 1920x1080 @ 60.00Hz, progressive 0|mm | 0|mm | Launching application. 0|mm | Create new calendar fetcher for url: http://www.gov.uk/bank-holidays/england-and-wales.ics - Interval: 300000 0|mm | Create new news fetcher for url: http://feeds.bbci.co.uk/news/rss.xml?edition=uk - Interval: 300000 0|mm | Create new news fetcher for url: http://feeds.bbci.co.uk/news/england/london/rss.xml - Interval: 300000 0|mm | monitor :state 0x120006 [DVI DMT (82) RGB full 16:9], 1920x1080 @ 60.00Hz, progressive 0|mm |Any ideas on what could be the problem?
Thanks…
-
@strawberry-3.141
Thanks for your help. Unfortunately I don’t find any information about media access or how to activate it in the Midori browser…@mongo116
I cant’ help you why the motiondetector does not turn off your screen (it also does not work in my case). However, how does the config.js with the additional time-out section that results in an error look like? At least in my case a section like{ module: 'motiondetector', config: { timeout: 5*60*1000 } },gave no complaints about errors in the config file (for a complete config-file see my post above).
-
@Hawking Thank you, that works. Monitor is still not turning off, but that’s one issue off the list :)
-
Just to add to this, I have checked that the camera is working and motion is detected by testing with https://github.com/pageauc/motion-track. All appears to be working as expected. No motion is detected unless I move in front of the camera.
-
@mongo116 maybe the value that gets returned is different than the value set in the module, so he always tries to activate the monitor?
-
I’ve got the motion detection now working - had to add bcm2835-v4l2 to \etc\modules - restarted and screen now turns off after defined period and on when motion is detected. This is really great, and I’m nearly there - but… Now when the motiondetector is running, the RPi3 temp just goes up and up and up, until it eventually crashes/freezes and I have to pull the power as RPi is completely unresponsive. If I remove motiondetector from MagicMirror, temperature stays stable and no crashing. Is there something I can change in the config to sort out this performance issue?
-
@mongo116 it looks like https://github.com/alexyak/motiondetector/blob/master/diff-cam-engine.js#L37 it creates 10 images per second and compares it to the previous which is probably the intensive part
-
@strawberry-3.141 Thanks for that. I’ve amended this slightly so will keep an eye on it. Might also have a look at putting on some heatsinks to see if that helps.
One (hopefully!) final question. When the monitor is turned off, is there a way to ‘freeze’ the other modules, so they stop running for the duration that the monitor is off? This would hopefully help with performance, in that the other modules are no longer running.
-
@mongo116 every module has a
suspendandresumefunction, but nearly none module that I’m aware of has implemented stopping intervals and fetching data in there. so calling those functions wouldn’t make a difference then just hiding it on the display.Furthermore I doubt that it would really make a difference if you’re not using another cpu intensive task like voice recognition …
-
sorry for my noob-Question but is there an setup or a explaination how to use the three .js files from alexeyak on github? normaly there is an readme-file.
-
@reaper81 I had the following in my config.js:
{ module: 'motiondetector', config: { timeout: 5*60*1000 } },You will need to ensure that the 3 files are located in the modules/motiondetector folder.
I ended up using a different method for motion detection though, as tvservice kept stopping working.
-
So after far too many months, I’ve finally gotten my mirror put together. Everything is working great, except for this module (sometimes). After a reboot everything works at least once, meaning that the monitor will turn off when no motion is detected and turn on once motion is detected. Sometimes, it will work correctly for an entire day. Others, it will work once and then the monitor will not turn back on until I reboot the pi. After the monitor refuses to wake up, I receive the following in the pm2 logs when it does detect motion.
0|mm | monitor :state 0x7ee68dbc [HDMI unknown AR x38128 HDCP], 2129038664x4287062190 @ 45744.00Hz, interlaced 0|mm | monitor :state 0x7ee8bdbc [HDMI unknown AR x13552 HDCP], 2129182024x4287062190 @ 21168.00Hz, interlaced 0|mm | monitor has been deactivated 0|mm | monitor :state 0x7ebe5dbc [HDMI unknown AR x25840 HDCP], 2126404936x4287062190 @ 33456.00Hz, interlaced 0|mm | monitor :state 0x7e9afdbc [HDMI unknown AR x13552 HDCP], 2124086600x4287062190 @ 21168.00Hz, interlaced 0|mm | monitor has been deactivated 0|mm | monitor :state 0x7e8dadbc [HDMI unknown AR x21744 HDCP], 2123214152x4287062190 @ 29360.00Hz, interlaced 0|mm | monitor :state 0x7efdcdbc [HDMI unknown AR x54512 HDCP], 2130562376x4287062190 @ 62128.00Hz, interlaced```Does anyone have any thoughts on how to prevent this from happening? Is there a better place to look at logs other than pm2 to see exactly what is happening. It is very odd to me that it works for different amounts of time after each reboot.
For what it’s worth, when the screen stops waking up, I can navigate to rasperrybi.local:8080 in a browser and all of the modules are up and running.
Any thoughts or comments are appreciated.
-
@jdahli1
I don’t know this error, therefore the following two comments might be totally wrong:The motion detector uses
/opt/vc/bin/tvservice --preferred && sudo chvt 6 && sudo chvt 7to switch the monitor on. What happens if you execute this command manually while the observed problem occurs (I assume you can still login to the PI?). Then you might know weather it is a problem of the motion detection (and MMM) or if it is a more general problem. Maybe you even get additional error messages that help you to identify the problem
- Do you know the HDMI-settings in /boot/config.txt ?
Maybe it is worth to play around withhdmi_force_hotplug,hdmi_drive,hdmi_groupandhdmi_mode. See the file and here https://raspberrypi.stackexchange.com/tags/config.txt/info for more information. Maybe the “AR” in your error stands for “aspect ratio”, this could be set explicitly be these parameters.
If somebody got this module to work on a Raspberry Pi Zero (using the Midori browser) I would be highly interested in how it was done!
- Do you know the HDMI-settings in /boot/config.txt ?
-
@Hawking Thank you for the reply. Running that command does not appear to do anything. I let it sit for a minute and the command never completes, nor does the screen come on. It will sit until I ctrl + c. I will start to mess with the hdmi settings and see if that makes any difference.
-
@jdahli1
Can you just execute/opt/vc/bin/tvservice --preferredto see if it is tvservice or chvt that does not respond?Here https://news.screenly.io/how-to-automatically-turn-off-and-on-your-monitor-from-your-raspberry-pi-5f259f40cae5 also problems with turning the screen back on using tvservice are mentioned. Maybe the other methods mentioned in the article are worth a try. If they work you can simply change the commands used in
~/MagicMirror/modules/motiondetector/node_helper.js -
@Hawking So running that command has the same result - nothing happens until I ctrl + c. I have been messing with the hdmi_* commands, but no luck so far.
-
Can I use the Pi-Camera for Motion Detection and Face-Recognition at the same time or have I to use seperate cameras for each module?
-
@reaper81 said in Motion Detector:
Can I use the Pi-Camera for Motion Detection and Face-Recognition at the same time or have I to use seperate cameras for each module?
This uses a pir-sensor
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