Outils pour utilisateurs

Outils du site


issue52:linuxlab

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

N'avez-vous pas une envie énorme de posséder 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 l'avoir ! ZoneMinder est 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 le 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 son fonctionnement en installant une application comme « Cheese ». Si la webcam fonctionne avec Cheese, alors il y a de grandes chances qu'elle fonctionne 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 la 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 contrôlée dans une fenêtre de navigateur. On a besoin de MySQL, puisque ZoneMinder enregistre la plupart de ses activations et ce genre de choses 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 capable 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-même dans « Options » (sous l'onglet « User ») et, sous l'onglet « System », d'activer 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 rencontré mon premier obstacle. 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 » (à distance) 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 automatiquement avec la caméra qu'il détecte, comme le fait Cheese. L'astuce est d'utiliser mjpg-stream pour diriger le flux vidéo de la caméra vers ZoneMinder. Ainsi, ZoneMinder la reconnaît 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 comme étant valide (pour Ubuntu/apt-get), mais j'ai trouvé une version corrigée qui fonctionne. Vous devez donc 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 sur le fichier téléchargé ou ouvrez-le dans Gdebi et laissez-le s'installer. Pour lancer MJPG, ouvrons un terminal et saisissons : mjpg_streamer -i “input_uvc.so -r 320×240 -f 6” -o “output_http.so -p 8080” -b

Ici, nous disons à 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, cliquez 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 parlant à votre caméra. Ceci veut dire que nous verrons simplement la caméra, sans, pour l'instant, enregistrer ou détecter les mouvements. Cliquez l'onglet « Source » et entrez 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

Enfin, cliquez sur 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 « image-to-browser » par défaut de JPG à MPG. C'est fait dans l'onglet Options > « Images ». Voilà, nous sommes prêts.

Maintenant, de retour sur l'écran principal de ZoneMinder, vous devriez retrouver votre « monitor » - ou surveillant - (votre caméra) dans la liste. Sous le titre de « Name » devrait apparaître le nom de votre caméra (si vous lui en avez donné un), sur lequel vous pouvez cliquer pour voir ce que votre caméra envoie comme 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 n'est guère l'idéal, 640×480 à 30 fps serait bien, mais dans certaines distrib. ZoneMinder a un problème de mémoire partagée qui soit ê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 et en saisissant : 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 saisissez : mjpg_streamer -i “input_uvc.so -r 640×480 -f 30” -o “output_http.so -p 8080” -b

pour paramétrer la 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 le paramétrage de votre caméra pour rendre la résolution à 640 de large sur 480 de haut, sauvegardez, retournez, et vérifiez ce 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 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.

Pour corriger cela, nous devons éditer le fichier sysctl.conf en saisissant : sudo gedit /etc/sysctl.conf

et sous la ligne qui dit #kernel.printk il faut mettre : kernel.shmall=268435456 kernel.shmmax=268435456

et enregistrez-le. Vous pouvez fermer votre éditeur de texte ; nous n'en aurons plus besoin. Pour utiliser ce nouveau fichier sysctl.conf, nous devons retourner au terminal et faire : sudo sysctl -p

qui vous montrera les choses que nous venons juste de taper. Tout va bien.

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.

Entrez à nouveau l'adresse de ZoneMinder dans votre navigateur et vous remarquerez peut-être que votre source « localhost » est en rouge. Si c'est le cas, cliquez dessus, puis cliquez sur « Save »; cela devrait le corriger et le texte devrait revenir à l'orange. Cliquez sur votre caméra (sous « Name ») et elle devrait fonctionner !

Dans la prochaine partie du tutoriel, nous activerons quelques capacités de détection de mouvement et aussi nous lirons quelques enregistrements.

issue52/linuxlab.txt · Dernière modification : 2011/10/03 21:38 de fredphil91