3 Ocak 2013 Perşembe

278. Monitoring your office with a webcam and zoneminder on debian

To contact us Click HERE
Update: so this worked fine with my thinkpad sl410 camera, but I'm having a lot of trouble getting an image off of my usb Pixio cam (Z-Star Microelectronics Corp. USB 1.1 Webcam) with "Got signal 11 (Segmentation fault), crashing" and "'zmc -d /dev/video0' exited abnormally, exit status 11". Zoneminder feels annoyingly temperamental at times. Anyway, I ended up hacking together a poor but functional solution by using a shell script and streamer to save stills every few seconds, then letting zoneminder analyse and capture. Setting up two Airlink 101 AIC250W was remarkably easy though (although I remember having a lot of trouble in the past). I've also experimented with motion,  and although I'm having issues with the image colours it's working very well.

Original post
While I figured that the head of school might have a universal key allowing access to all the offices in the department (the cleaners do), finding out that he had used it to open my office for a trivial purpose has ticked me off.

While you may not have an expectation of privacy at your company office, I certainly do when it comes to my department office.

So I'm not too happy about that, and while monitoring my office will not prevent future breaches of privacy, it will at least ease some of the paranoia if it turns out that my office doesn't routinely get entered.

This post only deals with a locally attached webcam -- I struggled with remote wifi-connected webcams a few years ago with little luck.
sudo apt-get install zoneminder
sudo apt-get install v4l-conf v4l2ucpsudo cp /etc/zm/apache.conf /etc/apache2/sites-enabled/zm.confsudo service apache2 restart

Figure out what video devices you have:
ls /dev/video* 
/dev/video0
and make sure www-data can access them
sudo adduser www-data video

You can now navigate to http://localhost/zm
Click on 'add monitor'

These settings are fine.

Note: these settings did NOT work. Keep reading the post...

Setting up the camera seemed deceptively easy -- everything went fine, except actually getting an image.

note the red colour for the video device. No good.

Looking at the log I was getting
Failed to set video format: Invalid argument
'zmc -d /dev/video0' exited abnormally, exit status 255


which is when I googled and found this post: http://rainbow.chard.org/2012/04/24/using-zoneminder-with-a-cheap-cctv-camera/

Basically, getting the settings absolutely right matters!
v4l-info

which told me
video capture    VIDIOC_ENUM_FMT(0,VIDEO_CAPTURE) index                   : 0 type                    : VIDEO_CAPTURE flags                   : 0 description             : "YUV 4:2:2 (YUYV)" pixelformat             : 0x56595559 [YUYV]    VIDIOC_ENUM_FMT(1,VIDEO_CAPTURE) index                   : 1 type                    : VIDEO_CAPTURE flags                   : 1 description             : "MJPEG" pixelformat             : 0x47504a4d [MJPG]    VIDIOC_G_FMT(VIDEO_CAPTURE) type                    : VIDEO_CAPTURE fmt.pix.width           : 1600 fmt.pix.height          : 1200 fmt.pix.pixelformat     : 0x47504a4d [MJPG] fmt.pix.field           : NONE fmt.pix.bytesperline    : 0 fmt.pix.sizeimage       : 5760000 fmt.pix.colorspace      : unknown fmt.pix.priv            : 0
so changed my settings to
It took a bit of trial and error

Next, I was receiving
Got unexpected memory map file size 49153524, expected 230401524
and this post helped me:
http://jared-oberhaus-tech-notes.blogspot.com.au/2011/12/im-trying-to-capture-video-from-device.html

Our old friend shmmax eh? Apparently I had about 32 mb set up (!) on my laptop, so I changed it to 671088640 (640 mb)
sudo sysctl -w kernel.shmmax=671088640

See this post for how to make it permanent.

Anyway, once all is well you will hopefully see something like this (note the colours -- the /dev/ is a nice orange, although the log is still an unhappy red)
Now we can actually do things. Click on the name of your device (here: laptop) and you should get something like

You can now click on Zones in the main menu and add one (takes a little bit of trial and error, but you'll get there). To get motion detection, and thus get ZM to save things, change the mode from Monitor to e.g. modec

Your files will  be found under /usr/share/zoneminder/events but you can change that using the setting menu which you can access in the top right corner in the main window.

So that's pretty much it. There are a couple of settings you might want to fiddle with:
You might want to set up ffmpeg to allow for generation of video fles


So I got fed up with one of my cameras not working together with zoneminder. As a temporary fix I set zoneminder to use 'file' instead of 'local' or 'remote'. So now zoneminder looks at ~/webcam/current.jpg.
In that directory, a script is running (you need to install streamer):

#!/bin/bashwhile truedo streamer -c /dev/video0 -b 24 -s 640x480 -o current.jpeg -q 2> /dev/null        sleep 1done

Also, I created a directory and symmlinked it to /usr/share/events to prevent my root partition from filling up:
mkdir zm/chown www-data zm/sudo rm /usr/share/zoneminder/events -rfsudo ln -s /home/me/webcam/zm /usr/share/zoneminder/events

Hiç yorum yok:

Yorum Gönder