pimatic / pimatic

A home automation server and framework for the raspberry pi running on node.js
http://pimatic.org
GNU General Public License v2.0
597 stars 145 forks source link

Pimatic as a video surveillance system #187

Closed Yves911 closed 9 years ago

Yves911 commented 10 years ago

I am using pimatic together with motion on a raspberry pi. pimatic is able to start and turn off motion (thanks to ShellSwitch)

{
      "id": "Video",
      "name": "Motion",
      "class": "ShellSwitch",
      "onCommand": "/root/aactivate_alarm2.sh",
      "offCommand": "curl -s 'http://127.0.0.1:8080/0/action/quit' || echo OK",
      "getStateCommand": "pidof motion > /dev/null && echo on || echo off"
}

pimatic is able to tell me when my smartphone is away and turn on motion when i leave (thanks to ping plugin and mail plugin)

{
      "id": "my-phone",
      "name": "my smartphone",
      "class": "PingPresence",
      "host": "192.168.1.49",
      "interval": 100000,
      "retries": 60,
      "timeout": 30000
    },
{
      "id": "IphoneabsentID",
      "name": "Iphoneabsent",
      "rule": "if my smartphone is absent and its after 8am and its before 11pm then send mail subject:\"Smartphone away\" text:\"bye\" and switch on Motion",
      "active": true,
      "logging": true
    },

The only thing missing is the integration of the video stream coming from motion into a pimatic page. You can find some info about motion web stream server here http://www.lavrsen.dk/foswiki/bin/view/Motion/WebcamServer To see live videostream all you have to do is to add that

<div id="video">
    <img src="http://servername:port" />
</div>

Problem how to integrate that in pimatic?

btw : there is a huge improvement on quality and number of frames see here http://www.raspberrypi.org/forums/viewtopic.php?f=43&t=75240

sweetpi commented 10 years ago

Sounds very interesting. I'm working on an integration for the raspberry pi camera. But stopped because I wanted first make the rewrites for 0.8.0. If its finished I will add some generic webcam devices, too.

Yves911 commented 10 years ago

Yeah i saw the rpicam module, there are several advantages with motion:

disadvantages :

Yves911 commented 10 years ago

If it helps i can provide you a http (+credentials) address of a Motion Web Server

sweetpi commented 10 years ago

Thanks for the offering, but I think I don't need it. Too less time and too less programmers is the bigger problem. My first target is at the moment to get 0.8.0 ready, after that I will invest more time in implementing new things. So it probably will need some more months. Keep in mind that I'm programming all this in my limited free time and for no profit :D.

If you want to help: Learn CoffeeScript, pick a issue and start coding :). If you need help to get started with something pimatic specific, always free feel to ask.

Yves911 commented 10 years ago

Ok my proposal will stay valid for months (so if you need it later on no problem, the idea was to save you time to setup motion). Depending on the workload on my side i may try to learn CoffeeScript (but i will need a loooot of time to understand it, i know)

Yves911 commented 10 years ago

Now pimatic 0.8 is released any chance to see a pimatic-motion plugin, all motion detection and cam option could stay at motion level and pimatic could only display the video stream from motion webserver. In pimatic-motion configuration only 1 parameter is needed : http://servername:port

here is switch that i defined to control motion via builtin webserver:

 {
      "id": "Video",
      "name": "Motion",
      "class": "ShellSwitch",
      "onCommand": "/root/aactivate_alarm2.sh",
      "offCommand": "curl -s 'http://127.0.0.1:8080/0/action/quit' || echo OK",
      "getStateCommand": "pidof motion > /dev/null && echo on || echo off"
    },

and /root/aactivate_alarm2.sh

killall -q -r '.*motion.*'
cd /motion-mmal
./motion -c motion-mmalcam.conf.good > /dd_extern/tmp/motion.log 2>&1 &
echo "Alarme on"
sweetpi commented 10 years ago

You are the expert in motion, why do you don't create one?

Yves911 commented 10 years ago

I won't say that i am an expert in motion, i just can say that i can understand basic options :-). So i will try also to create the plugin for motion in addition to TFA protocol in pimatic : all 2nd half of September... Let's see how far i can contribute...

sweetpi commented 10 years ago

Would be cool. I won't have much time next weeks, too. But maybe we can get it to work in 2nd half of September.

1000io commented 9 years ago

Hi all!

Perhaps Motion has a big problem. CPU usage... I started to develop the generic camera protocol to pilight that it's working. But honestly with a motion detect integration, probably we have more options than showing webcam images in the frontend. I'm not a node developer so I can't help you with this integration at this moment but I think that (https://github.com/peterbraden/node-opencv) is a good option to motion detect...

Waiting for news!

Yves911 commented 9 years ago

I don't think that motion is too much CPU intensive on a raspberry especially with MMAL, you can look at (http://www.raspberrypi.org/forums/viewtopic.php?f=43&t=75240). I have very decent framerate combined with a very good definition. This is possible because this patch make motion using a very small image to detect motion (for example 128x96) and then display full res image (2592x1944). To my opinion what is missing for now is the option to show the motion stream into pimatic fronted, but @andig could come with something great (https://github.com/pimatic/pimatic/issues/192)

1000io commented 9 years ago

Ok sorry, because I was thinking about the possibility of recognition of faces, objects and movements that came in the OpenCV library. If you try to do that with your motion, your CPU burns :8ball:

sweetpi commented 9 years ago

Moving all Feature request to the forum, so closing this.