Outils pour utilisateurs

Outils du site


issue52:linuxlab

Ceci est une ancienne révision du document !


ZoneMinder WebCam CCTV Part 1 by Ronnie Tucker Don’t you just wish you could have your own CCTV system? It could help look after your car, your house, even your baby. Well, you can! ZoneMinder is a piece of software which - when hooked to a camera - will allow you to monitor, record, and even motion-detect for security, and all recorded to your PC. Not only that, but it can email you with a screenshot of the recording when a camera has detected motion. In this example, I’m using my Logitech C310 HD webcam. It’s automatically detected in most Ubuntu-based distros, and you can check that it’s working by installing an application such as ‘Cheese’. If the webcam is working in Cheese, then there’s a good chance it will work in ZoneMinder.

Zoneminder : télévision en circuit fermé au moyen de webcams

1ere Partie

Par Ronnie Tucker

Est-ce qu'il ne vous arrive pas d'avoir envie d'avoir votre propre système de surveillance en circuit fermé ? Il pourrait vous aider à surveiller votre voiture, votre maison et même votre bébé. Eh bien, vous pouvez ! ZoneMinder est un bout de logiciel qui, lorsqu'on lui branche une caméra, vous permettra de surveiller, enregistrer et même détecter les mouvements pour la sécurité, et tout çà est enregistré sur votre PC. Mais pas seulement, il peut vous envoyer par e-mail une photo lors de la détection du mouvement par une caméra.

Dans cet exemple, j'utilise ma webcam Logitech C310 HD. Elle est détectée automatiquement dans la plupart des distrib. basées sur Ubuntu, et vous pouvez vérifier que çà marche en installant une application comme 'Cheese'. Si la webcam fonctionne avec Cheese, alors il y a de grande chances qu'elle marche avec ZoneMinder.

So, with my webcam plugged in and working in Cheese, it’s time to install ZoneMinder: sudo apt-get install zoneminder apache2 php5-mysql libapache2-mod-php5 mysql-server ffmpeg You’ll notice that we’re installing Apache and MySQL. Apache is installed because it’s possible to control ZoneMinder via the Internet. The whole of ZoneMinder is controlled in a browser window. MySQL is needed as ZoneMinder saves most of its activations and such-like in a MySQL database. Next, we need to get Apache talking nicely to ZoneMinder: sudo ln -s /etc/zm/apache.conf /etc/apache2/conf.d/zoneminder.conf With that done, we need to restart Apache with: sudo apache2ctl restart Now you should be able to get into ZoneMinder by going to your browser and pointing it to: http://localhost/zm/

Donc avec ma webcam branchée et fonctionnant avec Cheese, installons ZoneMinder: sudo apt-get install zoneminder apache2 php5-mysql libapache2-mod-php5 mysql-server ffmpeg

Vous remarquerez que nous installons Apache et MysSQL. Apache est installé car il est possible de contrôler ZoneMinder via Internet. La totalité de ZoneMinder est controlé par un navigateur. On a besoin de MySQL car ZoneMinder enregistre la plupart de ses activations et autres choses similaires dans une base de données MySQL.

Ensuite, nous devons faire discuter Apache avec ZoneMinder: sudo ln -s /etc/zm/apache.conf /etc/apache2/conf.d/zoneminder.conf

Une fois ceci fait, nous devons redémarrer Apache: sudo apache2ctl restart

Maintenant vous devriez être capables d'aller dans ZoneMinder au moyen de votre navigateur par : http://localhost/zm/

[zm01] For reasons of security, I’d recommend that you create an admin account for yourself in ‘Options’ (under the ‘User’ tab), and, in the ‘System’ tab, turn on user authentication so that should anyone load up your browser/bookmark, they won’t have admin access to your CCTV system! This is where I hit my first major hurdle. My webcam is local. As in, it’s sitting in the same room as me as I tinker with ZoneMinder. The other alternative is ‘remote’ which means the camera is not in the same room as me. No matter what I did, I could not get my camera to work with ZoneMinder. One major flaw with ZoneMinder is that it doesn’t just autodetect a camera and work, like Cheese does. The trick is to use mjpg-stream to stream the video from the camera to ZoneMinder. Thus, ZoneMinder now recognises it as a remote camera. This is when I hit my second major problem. The .deb package for mjpg-stream is no longer recognised as being valid (in the eyes of Ubuntu/apt-get), but I did manage to find a patched version which does work. So, you need to download MJPG from: http://goo.gl/nFhNC

[zm01]

Pour des raisons de sécurité,je vous recommanderais de créer un compte administrateur pour vous dans 'Options' (sous l'onglet 'User'), et, dans l'onglet 'System' activez l'authentification des utilisateurs pour que quiconque accèderait à votre navigateur ou marque-page, ne puisse avoir accès à votre système de télé en circuit fermé !

C'est là que j'ai dû franchir ma première haie. Ma webcam est branchée en local. C'est à dire placée dans la même pièce que moi lorsque je bricole avec ZoneMinder. L'alternative est 'remote' qui signifie que la caméra n'est pas dans la même pièce que moi. Peu importe ce que je faisais, je ne pouvais pas faire marcher ma caméra avec ZoneMinder. Une des principales faiblesses de ZoneMinder est qu'il ne travaille pas directement avec la caméra qu'il détecte, comme le fait Cheese. L'astuce est d'utiliser mjpg-stream pour diriger le flux video de la caméra vers ZoneMinder. Ainsi, ZoneMinder la reconnait comme une caméra à distance. C'est là que j'ai eu mon deuxième problème majeur. Le paquet .deb pour mjpg-stream n'est plus reconnu valide (pour Ubuntu/apt-get), mais j'ai trouvé une version corrigée qui marche. Donc vous devez télécharger MJPG sur http://goo.gl/nFhNC.

Double click the downloaded file, or open it in Gdebi, and let it install. To run MJPG we open a terminal and do: mjpg_streamer -i “input_uvc.so -r 320×240 -f 6” -o “output_http.so -p 8080” -b What we’re doing here is telling the camera to stream the video at 320 x 240 resolution, at six frames per second, via http to port 8080. Now we can configure ZoneMinder. First click the ‘Add New Monitor’ button, and, in the pop up window, click the ‘General’ tab. From the drop-down menu beside ‘Source Type,’ choose ‘Remote,’ and, for the moment, we’ll leave ‘Function’ as ‘Monitor’ - you can, if you wish, give your camera a meaningful name. This means we’ll just be viewing the camera, not recording or doing any fancy motion-detection yet. Click the ‘Source’ tab, and in here we enter the screen width and height as 320 and 240 respectively, and the port as 8080. The hostname is localhost, and ‘Remote Host Path’ is (and don’t forget the question mark at the start!): ?action=stream And, finally, click the ‘Save’ button.

Double cliquez le fichier téléchargé, ou ouvrez le dans Gdebi et laissez le s'installer. Pour lancer MJPG, ouvrons un terminal et tapons: mjpg_streamer -i “input_uvc.so -r 320×240 -f 6” -o “output_http.so -p 8080” -b

Ce que nous faisons ici est de dire à la caméra d'envoyer la vidéo avec une résolution de 320×240, à 6 images par seconde, par http sur le port 8080. Maintenant nous pouvons configurer ZoneMinder.

Cliquez d'abord sur le bouton 'Add New Monitor', et, dans la fenêtre qui s'affiche, cliques l'onglet 'General'. Dans le menu déroulant à côté de 'Source Type', choisissez 'Remote' et pour l'instant on laissera 'Function' à la valeur 'Monitor'; vous pouvez, si vous le souhaitez, donner un nom significatif à votre caméra. Ceci veut dire que nous verrons simplement la caméra, sans enregistrer ou détecter les mouvements pour l'instant. Cliquez l'onglet 'Source' et entrons la largeur et la hauteur de l'écran, respectivement 320 et 240, et le port 8080. Le nom du serveur est localhost et le 'Remote Host Path' (ne pas oublier le point d'interrogation au début!) est : ?action=stream

Et enfin cliquez le bouton 'Save'

[zm02 and 03] Before we can see anything in ZoneMinder, we need to change its default image-to-browser setting from JPG to MPG. This is done in the Options > ‘Images’ tab. Now we’re ready to go. Now, back in the ZoneMinder main screen, you should have your monitor (aka: camera) listed. Below the header of ‘Name’ should be your camera name (if you gave it a name) which you can click to see what your camera is streaming.

[zm02 and 03]

Avant de pouvoir voir quelque chose dans ZoneMinder, nous devons modifier son paramétrage par défaut image-to-browser de JPG par MPG. C'est fait dans l'onglet 'Options > Images'. Nous sommes maintenant prêts.

Maintenant, de retour sur l'écran de ZoneMinder, vous devriez avoir affiché votre superviseur (votre caméra). Sous le titre de 'Name' devrait apparaitre le nom de votre caméra (si vous lui en avez donné un) sur lequel vous pouvez cliquer pour voir que votre caméra envoie des images.

[zm04] Now, the next problem. Our settings of 320×240 at 6fps is hardly ideal, 640×480 at 30fps would be nice, but in some distros ZoneMinder has a shared memory problem which needs to be fixed before we can bump up the resolution. To prove it’s a ZoneMinder problem, we can test the camera output by going to the browser and entering: http://localhost:8080/?action=stream and you’ll see your camera at 320×240 at 6fps. Close the tab/window in your browser and kill MJPG from a terminal with: killall mjpg_streamer

Passons au problème suivant. Notre paramétrage de 320×240 à 6 fps est rarement idéal, 640×480 à 30 fps serait super, mais dans certaines distrib. ZoneMinder a un problème de mémoire partagée qui nécessite d'être corrigé avant de pouvoir faire grimper la résolution.

Pour prouver que c'est un problème de ZoneMinder, nous pouvons tester la sortie de la caméra en allant dans le navigateur : http://localhost:8080/?action=stream

et vous verrez votre caméra à 320×240 avec 6 fps. Fermez l'onglet ou la fenêtre de votre navigateur et tuez MJPG dans un terminal : killall mjpg_streamer

then enter: mjpg_streamer -i “input_uvc.so -r 640×480 -f 30” -o “output_http.so -p 8080” -b to set your camera at 640×480 at 30fps. Go back to your browser and do: http://localhost:8080/?action=stream and your camera will indeed be in 640 x 480 and displaying 30 frames per second. Go back in to ZoneMinder and edit your camera settings to make the resolution 640 wide and 480 high, save it, go back, and check what your camera is streaming. You’ll probably see nothing. If you see something then you’re doing better than I did! If you see nothing, read on.

puis entrez: mjpg_streamer -i “input_uvc.so -r 640×480 -f 30” -o “output_http.so -p 8080” -b

pour mettre ta caméra à 640×480 avec 30 fps. Retournez dans votre navigateur et faites: http://localhost:8080/?action=stream

et votre caméra sera réellement en 640×480 et affichera 30 images par secondes.

Retournez dans ZoneMinder et éditez votre paramétrage de caméra pour rendre la résolution à 640 de large sur 480 de haut, sauvegardez, revenez, et vérifiez que votre caméra diffuse. Vous ne verrez probablement rien. Si vous voyez quelque chose c'est que vous avez fait mieux que moi! Si vous ne voyez rien, continuez à lire.

to do

To fix things, we need to edit the sysctl.conf file by doing: sudo gedit /etc/sysctl.conf and below the line that says #kernel.printk we want to put: kernel.shmall=268435456 kernel.shmmax=268435456 and save it. You can close your text editor too; we shouldn’t need it again. To use that new sysctl.conf file, we need to head over to the terminal again and do: sudo sysctl -p which will show you the stuff we just typed in. All good.

Get ZoneMinder in your browser again and you might notice that your source ‘localhost’ is in red. If it is, click it, then click ‘Save’; that should fix it, and the text should go back to being orange. Click your camera (under ‘Name’) and it should work! In the next part of this tutorial we’ll enable some simple motion-detect capabilities, and also play back some recordings.

issue52/linuxlab.1317397536.txt.gz · Dernière modification : 2011/09/30 17:45 de frangi