Author Topic: Security camera musings  (Read 9326 times)

jamo

  • Guru
  • ****
  • Posts: 463
    • View Profile
    • LMCE user Page
Security camera musings
« on: June 14, 2013, 03:34:48 pm »
Hi Everyone

Been quiet for a while... blasted work....

But I have been slowly tinkering with my security camera setup and thought I'd share some observations and my current thinking on this, specifically in the area of motion detection and specifically with IP cameras.

I tinkered with motion wrapper a bit and I have to say it works pretty well for simple needs - wrap your and camera with motion wrapper and voila - you have motion events which you can use to trigger LMCE commands and also automatic snapshots being recorded and even a video being created of the motion event for later review. Nice.
Shortcomings, though, are:
  • Advanced configuration: This is what you want to do if you want to eliminate most of the false events... so if you're wanting to use it like a perimiter alarm for instance. In short, motion has limited configuration options and even those are tricky because under LMCE advanced config is done at the motion wrapper level which means all your cameras shared by the same motion wrapper will have the same config. And it seems that you need only one motion wrapper device although I have not tested this yet
  • Network overhead: It's not huge, but if you've got motion detection running, you're basically sucking as many frames as you can off your cameras per second down your NIC 24/7. As you add to your number of cameras that can become a bit of a bottleneck.

An alternative to this would be to use the advanced IP camera template which, if I'm not mistaken, uses the camera's built-in motion detection alarms to trigger LMCE events rather than using your server to "watch" the cams and do motion detection (correct me if I'm wrong). I haven't tried this, and I think it does make a lot of sense and addresses many of the issues I've mentioned above. My primary concerns, though, are firstly that it relies on the camera's routines and intricacies which could make for a lot of tinkering with the various differences between different cameras' motion detection notification methods and secondly, that it is only as good as the cam's routines.

Enter zoneminder.

If you're looking for something a little more powerful this is pretty impressive. It runs on most flavours of Linux and Windows, I gather, and allows some pretty advanced motion detection configuration.

So I installed it on my LMCE server and have been running it for a while with no problems. Of course it's not *integrated* with LMCE, but runs on the same machine and shares the same web server quite happily. My plan was, after a while, to start to work on integrating it into LMCE.

However, I've just taken the next logical step... and that is to have a dedicated zoneminder server.

The reason I've done this is similar to the problems outlined with "motion". Apart from the disk and CPU overhead of zoneminder, there is always going to be constant network traffic between the CAMs and the zoneminder server as the server basically "watches" the cameras constantly, which means grabbing as many frames as it can, all the time. So, it seems to me, it makes a lot more sense to separate this out so you don't burden your LMCE server's NICs with ZM traffic. Rather have a separate ZM box just for that.

As far as integration goes, my first step would be to setup a script that allows the ZM box to fire off messages on the LMCE server for certain events. A simple option would be to configure all your cams just as plain cams (not motion-wrapped) on LMCE and then have ZM "pop them up" on your media director when motion is detected. Or fire some other event that can cause a scenario to be executed. I guess the next step would then be to write a device template for the ZM box and see it as a LinuxMCE device? Possible, I don't know.

Anyway, I think the bottom line of all this is that, in my humble opinion, zoneminder is a pretty good way to go if you want to get serious about motion detection and monitoring of CAMs and I think it makes sense to have it on a dedicated device. Having done that, it would be great to integrate it at a device level into LMCE. I think it would make a very nice partnership.

Just thought I'd share this in case anyone else is investigating this at all.

Have a good weekend, all....

James

DragonK

  • Guru
  • ****
  • Posts: 446
    • View Profile
Re: Security camera musings
« Reply #1 on: June 14, 2013, 06:38:15 pm »
Hi James,

Been a while,,

I use a Bluecherry PV-155 with analogue cameras.
No Network traffic. Motion wrapper 100% working and the cameras are less exspensive......

Karel

Just my 5c

jamo

  • Guru
  • ****
  • Posts: 463
    • View Profile
    • LMCE user Page
Re: Security camera musings
« Reply #2 on: June 18, 2013, 08:13:29 am »
Hey Karel

Hope you're well.

In many respects I think the analogue cameras are still a more practical solution than IP. I think I'm gunning for IP primarily because I think the technology will mature and ultimately replace the analogues, especially where home networks are more pervasive.

Zoneminder's work a look, though... give me a shout when you're in the neighbourhood and I'll show you my setup.

James

davegravy

  • Addicted
  • *
  • Posts: 551
    • View Profile
Re: Security camera musings
« Reply #3 on: June 18, 2013, 03:04:31 pm »
I'm following this, as I'm beginning to plan my security camera setup.

jamo

  • Guru
  • ****
  • Posts: 463
    • View Profile
    • LMCE user Page
Re: Security camera musings
« Reply #4 on: June 20, 2013, 09:21:01 am »
My current setup-

4 IP cameras (http://wiki.linuxmce.org/index.php/EasyN_FS-603A-M106_IP_Camera). These are pretty cheap no-name branders but have served me well so far as I learn the intricacies of IP cameras.

I have setup one camera to watch the gate to my property- this allows me to see who's there when the intercom bell rings and to control the opening and closing without having to peer out of a window. Currently gate open and close is via remote and/or intercom button, not connected to lmce but that will come ;-) This is useful already, though, because viewing via mobile device (phone, tablet) means when I let people come in I can watch and ensure no-one unwanted sneaks in afterward and the dogs don't run out into the road.

This was my first cam and to power it I had to put an electrical socket in the ceiling. That was no fun - mucking about in the dark with a head torch while the power was off. But it's there now. Network cable and 12v power supply cable passes through a 16mm hole drilled through the wall and all joins to the camera sockets (RJ45) and 12v connector in a neat little electrical box I mounted to the wall just above the cam. To reboot I have to get physical access to the cam or power off the circuit-breaker for the whole set of wall sockets.

After the gatecam, I decided for permiter security, rather than looking outward from the house, it makes more sense to look at the house from the outside. For a couple of reasons. Firstly, looking outward naturally looks beyond your boundaries - to the road, the neighbours etc and you aren't interested (well, maybe you are, but not for motion detection surely) in what's going on there. Secondly, unless you get a really wide angle lens, you would need hundreds of outward looking cameras to cover the area.

So I've angled the remaining cameras to try to cover all the windows and doors along the house perimeter.

We have a nice boring rectangular house so one cam can cover more or less the whole front of the house, obviously losing detail as you get further along. I have two under the eaves of the house itself looking along the wall and two mounted away from the house looking onto it- one on the garage (can't remember what Americans call a garage) and one on a telephone pole. Two of the four are powered from the mains via the 12v powersupply that comes with the cam and the other two are POE.

The POE is an absolute pleasure. I have a POE Gig switch that injects the 12v and then individual splitters at the camera end that split off the 12v at the camera side. The one under the eaves is protected from the weather so I just screwed it to a rafter and neatened the cables with cable ties. The one on the telephone pole I put in an external electrical box along with the all the other connectors. Nice and neat. Great thing about the POE as well is you can depower the camera by unplugging it at the network switch.

All 4 plug into my external network - ie between my ADSL router and my Core's external NIC. So they are firewalled from the internet by the ADSL router firewall and therefore have private IP addresses - 192.168.x.x but aren't strictly DCE devices. I use my ADSL router to assign the same IP to them every time based on MAC address so I can easily link to them as devices on LMCE or with zoneminder or just connect to them with a web browser on my home network. Also use port-forwarding through the router to provide external (internet access).

I've deleted my motion-wrapper devices for reasons above - it just adds overhead to the network and to the camera if motion is trying to suck frames from them along with zoneminder but will re-instate them as basic cameras at some stage so I can just watch them from a media director when I need to.

I have a separate zoneminder installation currently on an old hp6410b laptop running fedora 17. That is watching all 4 cameras and recording motion events. Still tweaking the settings there, hope to get to a point where I have very few "false" alarms, especially at night, so that I can ultimately use it to raise a real alarm if anything's detected. False alarm frequency at night has to be down to 1 every 2 months or fewer before you let it wake you up, in my opinion.

Viewers-
The zoneminder machine serves up a montage of screens which I watch on the laptop - because at the moment it's installed on the kitchen counter but ultimately it should be tucked away somewhere. It's not a fantastic interface but it works ok.
My cheap 7" tablet, running IP Camera Viewer. This is an android app and works really well. My Android phone running the same app.

Night vision-
These cameras provide their own IR illumination via 48 IR LEDs that come on courtesy of a built-in light sensor. They illuminate quite effectively for around 20m so you get quite a bit of detail at night, even in the dark. Unfortunately, they also seem to attrack moths and bugs which like to fly around in front of the lense and create rapid, dramatic motion events. An option would be to disable the camera's illumination and get an IR LED floodlight to illuminate the area separately. Then perhaps the moths would fly in front of that and not the lens. Some success can be had by filtering out events that trigger fewer than 2 frames - moths are very quick when they're that close... and non-ninja-trained intruders usually trigger more frames.

Challenges-
* IP Cam frame rate is definitely lower than analog cameras. Videos tend to be a bit more jerky than analog ones from what I've seen. Apparently, though, individual frames will usually be better quality so useful for court-cases etc.
* When all is ok, it works neatly but there are many minor glitches related to network issues... may be just my setup but it's there. WiFi for one thing- my router gets itself in a knot every so often (like once a day) and won't hand out new IPs it seems. So when wireless devices try to connect they can't.... annoying when you want to quickly check the cams from the tablet. Still trying to get to the bottom of this. One option is fixed addresses rather than DHCP which may help - leave DHCP for visitors who want to use the network. But I'd like to know why it's a problem first.
* Field of view of cameras is far more limited than you realise - apparently a 6mm lens is roughly the same "zoom" as your eyes but your eyes take in much much more in a scene. You can get shorter lenses which cover more but obviously you then sacrifice detail, given the same ccd size so it becomes a trade-off. Increase the ccd size and you increase your bandwidth requirement, memory and processor and storage requirement.
* Motion detection out of doors is a major challenge. I can see why all the security companies are reluctant to install outdoor detectors and link them to the armed-response units... there are so many false alarms.

PIR vs Camera-
This is mostly speculation - along with my other musings... so I'm happy for correction here by someone more knowledgeable. Essentially they're much the same thing... the PIR is just sensing in a different wavelength (invisible light) and generally at a much much lower resolution. They tend to use those fresno type lenses which is a crude wide-angle lens and their "ccd" has dramatically fewer "pixels". The advantage of all this is that it's way cheaper (lower res, simpler electronics) and they tend to "look" for a shorter distance so facing them toward the road or the neighbours is less of an issue because at that range, you'd need a very large part of the scene to change to trigger motion detection. So I guess something similar could be achieved with an outward looking cam with a wide angle lens. Then you could define motion minima that only trigger when the object is close enough to be big enough. The PIR is useful too in that the IR range doens't require illumination and usually humans are warmer than their surrounds which provides nice "human" detection. Works nicely indoors but outdoors again is a lottery. Also quite easy to mask - I've walked past all our indoor PIRs carrying a bedsheet in front of me and fooled them all by shielding my heat signature. Cams would be much more difficult to trick.
Fact is, everything struggles outdoors because the environment is so difficult to control. All systems will require some tweaking and trade offs between sensitivity and false alarms. The big plus with a camera is the video record! This gives you two things-
1. Peace of mind - if you *are* woken at 3am by an alarm, you can at least check the footage and know for sure whether it was a real threat or a false alarm. This is huge- without normal outdoor beams/passives you have no idea and feel compelled to sneak out into the garden in your boxer shorts to verify... which is completely stupid but the natural tendancy.
2. Ability to tweak the settings based on real events - you can review the footage that triggered the alarm, look at the stats of the alarm frames and adjust your settings to potentially eliminate it. Trying to tweak other sensors is a real hit and miss affair.

Hope that was useful reading for someone and not too off-topic for LMCE. Ultimately I want to integrate a lot more with events / security / automation / MD notification etc so I feel it is relevant.

James

jamo

  • Guru
  • ****
  • Posts: 463
    • View Profile
    • LMCE user Page
Re: Security camera musings
« Reply #5 on: July 23, 2013, 01:59:14 pm »
Just keeping this thread updated with latest thoughts.... anyone welcome to add / contribute.

zoneminder still running well and I'm pretty chuffed (za-speak for happy) with it. I've tried to set up basic camera viewers for my IP cams for LMCE (not as children of motion wrapper) and have not had much luck getting a signal for some reason... starting to suspect you *have* to have motion-wrapper parent to grab the frames? Not sure... I guess I could probably make them children of motion-wrapper and just turn motion off - the reason I don't want motion is that I don't want them grabbing frames when I'm not viewing them. That is zoneminder's job and I don't need any extra traffic or camera load.

The other reason I haven't pursued this too far is that the concept of grabbing individual frames via the "getframe" command (which is how I understand cameras to work under LMCE) doesn't, if you'll excuse the expression, grab me. It seems like a lot of overhead to generate an image stream... and I imagine a proper image stream would be much better.

So, what I'd like to see at the moment is -

a zoneminder machine watching the cams for motion and nicely integrated with LMCE as follows-
1. Triggering events on motion detection
2. Streaming video to a LMCE streaming video viewer
 2.1 Live camera feeds  AND
 2.2 Review of recorded events

Of course zoneminder has a web interface which allows all of the functionality in 2 via a web browser. But running a web browser (firefox) in LMCE is slow. For me at least. It takes a fair bit of time to fire up. I'd much rather have a dedicated LMCE "screen" that can pop-up as soon as it is requested or triggered and get a live view of my camera very quickly.

So zoneminder has a streaming video server which streams frames via http. It would be really cool to be able to connect some sort of LMCE screen/device wrapper/plugin to that server and view the video feed. Mmmmmm.

I've managed to do this using VLC on another linux box quite easily. You basically set up a text file called "myCAM.asf" (or whatever) with the following line in it:
Code: [Select]
http:/(my ip)/cgi-
bin/zm/nph-zms?mode=jpeg&monitor=1&scale=100&maxfps=10&buffer=1000&user=admin&password=(pw)
Or similar. Your zoneminder setup will tell you the path to the nph-zms streaming server application. Then you just run VLC with this file on the command line and it pops up a VLC client window with the video stream from your monitor. Very nice.

But how do I do the same thing in LMCE? Afaik, LMCE uses xine (not vlc) to play media. I went so far as creating the above file in my videos folder and trying to play it via the videos menu but I get some sort of (there is no media player capable of playing this file) error. Darn. I'm experimenting with command line xine on my other boxes to see if it's just some sort of setting but no luck so far. Any ideas?

I was thinking if I got this going the next step would be to setup a scenario that just fired off the appropriate LMCE commands to play the stream directly.

Is it possible to install VLC on the media director?

I realise this is complete hack and not the tight, smooth integration we want in the end but before I go building a DCE device (or at least reading the wiki on it ;-) I figure I need to have a good understanding of all the components, streaming video etc etc. So hacks for now.

Any thoughts/ contributions welcome.

James

davegravy

  • Addicted
  • *
  • Posts: 551
    • View Profile
Re:
« Reply #6 on: July 23, 2013, 02:41:50 pm »
Keep it up.   for vlc,  I recall seeing it in the list of installables within webadmin,  but never succeeded to get it to play anything. Seems it was at least supported at one time.

Sent from my HTC One using Tapatalk 4 Beta

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Security camera musings
« Reply #7 on: July 24, 2013, 12:14:25 am »
I am not using the motion wrapper but the simple camera device. works just nice, and records when I want it to record stuff, it does not do motion sensing. I have as my door camera.

sambuca created the advanced ip camera template, which does allow for motion detection, IF the camera itself has support for it. http://wiki.linuxmce.org/index.php/Advanced_IP_Camera

jamo

  • Guru
  • ****
  • Posts: 463
    • View Profile
    • LMCE user Page
Re: Security camera musings
« Reply #8 on: July 24, 2013, 07:56:15 am »
simple camera device
Thanks, possy, will have another look.... if you get a chance, can you let me know the template ID of that one?

Is yours an IP or analog camera?

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Security camera musings
« Reply #9 on: July 24, 2013, 04:29:57 pm »
I only have IP cams.

jamo

  • Guru
  • ****
  • Posts: 463
    • View Profile
    • LMCE user Page
Re: Security camera musings
« Reply #10 on: August 01, 2013, 09:58:24 pm »
So I tried using "Generic IP Camera" template to create mine but no luck - can't retrieve snapshot. Any suggestions? How do I debug?

I can access the snapshot via:
http://192.168.10.20:81/snapshot.cgi?user=xxxx&password=xxxx

So why can't lmce grab these frames? I've checked that the firewall is open on port 81. Any logs I should look at?

[Edit]
Interestingly, in the log for the device I get this error-

   Error while calling method: Cannot call class method: cmd_84
error: No such file or directory - /tmp/ip_camera_img261.png, line: 35

Which, I say, is interesting because there is no /tmp/ip_camera_img261.png.... but there is /tmp/ip_camera_img261.jpg. I wonder why it's looking for a png when there is a jpg? Any thoughts?
« Last Edit: August 01, 2013, 10:02:14 pm by jamo »