Motion/OpenCV/ONVIF

4,004 views
Skip to first unread message

Karel Goderis

unread,
Jun 4, 2014, 6:45:38 AM6/4/14
to ope...@googlegroups.com
Will, Ben, and anyone else involved in the IP Camera integration into OH,

Cfr the subject, have you guys have made progress since late 2013? me too i need a better IP camera integration, not only for showing video streams (quid the RTSP protocol proxy problem?), but also to control the camera. I have a bunch of Mobotix hanging around as well as 2n.cz IP vario door intercoms that I would like to integrate. The latter can be controlled via http but can also report back statuses via outgoing http calls, or via some non-SOAP compatible XML.

In that context, did anyone ever look at support for ONVIF into OH?

Regards
Karel


Ben Jones

unread,
Jun 4, 2014, 7:50:48 AM6/4/14
to ope...@googlegroups.com
Hi Karel,

Will has been very busy and he is the OpenCV expert so things have stalled a bit recently. 

I have just spent the last couple of days playing around with Motion and so far have been pretty impressed. I have a Raspberry Pi with a camera module attached in my garage, a cheap Foscam FI8910W in my living room, and a Dahua HFW2100 over my front door. I have managed to get them all configured using Motion (the Dahua is detecting motion using snapshots since I can't work out the URL for a direct stream - other than RTSP).

Even in snapshot mode Motion seems pretty good at detecting motion. I have a mask for the entry cam to stop activity on the road/footpath tripping the detection algorithm and it seems to be working well. 

I have configured some openHAB items to arm/disarm the camera motion detectors;

Switch  Camera_EntryArmed   "Entry Armed"   { http=">[ON:GET:http://MOTION:8080/1/detection/start] >[OFF:GET:http://MOTION:8080/1/detection/pause]" }

where '1' is the Motion thread.

Then I have a motion item;

Switch  Camera_EntryMotion    "Entry Motion"

Which is set/unset by Motion by hooking into the on_event_start/end events;

# Command to be executed when an event starts. (default: none)
# An event starts at first motion detected after a period of no motion defined by event_gap
on_event_start curl http://OPENHAB:8080/rest/items/Camera_EntryMotion/state -d ON -X PUT -H Content-Type:text/plain

# Command to be executed when an event ends after a period of no motion
# (default: none). The period of no motion is defined by option event_gap.
on_event_end curl http://OPENHAB:8080/rest/items/Camera_EntryMotion/state -d OFF -X PUT -H Content-Type:text/plain

So now I can arm/disarm the cameras in openHAB rules, i.e. when I leave/arrive home. I can send notifications (via MQTT and mqttwarn) when the cameras are tripped. Motion automatically saves a short video and snapshots to a location of your choice when movement is detected, which you can configure to be sent as an email I believe.

The bit I have been working on tonight is integrating with XBMC, so that when motion is detected at the front door, the camera feed is displayed in a nice little popup on all my XBMC instances for 15s (http://forum.xbmc.org/showthread.php?tid=182540). This is very cool!

I have managed to get a camera feed showing in my Android/iOS clients using the WebView widget, but as soon as I access openHAB remotely these streams don't work. Snapshot views using the Image widget work fine remotely.

Pretty happy with Motion so far - does just about everything I think I need currently. Definitely worth a try.

Karel Goderis

unread,
Jun 5, 2014, 8:56:45 AM6/5/14
to ope...@googlegroups.com
Ben

Doing some research I came across

https://github.com/bytedeco/javacv : a java wrapper lib for openCV
http://webcam-capture.sarxos.pl : a more general (web)cam java library

sarxos uses the javacv lib. It looks nifty, and we could envision a more general webcam binding that offers all the motion detection stuff (and many other features) to the OH runtime.

I am by no means a video/codec expert, but it all look "do-able" to me

K

--
You received this message because you are subscribed to the Google Groups "openhab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/d/optout.

Ben Jones

unread,
Jun 5, 2014, 4:03:12 PM6/5/14
to ope...@googlegroups.com
Those libraries look very interesting Karel. I believe a general 'motion detection' binding for openHAB would be very useful but unfortunately I don't have the time to start on this. For me, after a few days using motion I am finding it is doing most of what I need. It is very good at motion detection (as you would hope!), and is pretty easy to integrate into openHAB using the HTTP binding and the REST API.

The only issue is my Dahua camera doesn't have an http feed (that I can find), only a snapshot and a RTSP feed. Motion can't handle RTSP yet (there is a dev branch that does apparently) so I am stuck using snapshots which isn't really ideal since you only get a couple of shots a second. Aside from that I am very impressed with the software, and how easy it is to use. Albeit with no GUI and purely text config file based.

Keep us posted if you decide to dive into the javacv stuff. The facial recognition stuff looks very cool!

Amos Kittelson

unread,
Jul 15, 2014, 6:58:59 PM7/15/14
to ope...@googlegroups.com
I looked into controlling a ONVIF compatible PTZ camera many moons ago and ended up doing a lot of wiresharking and writing some device specific middleware to control the movement. ONVIF is incredibly complicated and based on my searches no open source ONVIF implementation exists. How I wish one did!

benwill...@gmail.com

unread,
Oct 12, 2014, 8:32:02 AM10/12/14
to ope...@googlegroups.com
I'm looking for an onvif Binding for openhab, but still doing experiments with my new camera.
@Amos: I just found an open source onvif client on sourceforge: http://sourceforge.net/projects/onvifdm/
for Linux this one may be usefull: http://sourceforge.net/projects/onvifcpplib/
Reply all
Reply to author
Forward
0 new messages