Difference between revisions of "IP Cameras"

From LinuxMCE
Jump to: navigation, search
(Using Motion to Record)
(IP Cameras and Motion Wrapper)
Line 6: Line 6:
 
IP cameras, a.k.a. "network cameras", are digital cameras that have a built-in web server.  This allows the camera to be accessed by any computer on the same network using a web browser.  Video is streamed to the web browser from the camera without additional equipment.  In a LinuxMCE system, IP cameras are easy to setup, but require some extra manipulation to get them to record.
 
IP cameras, a.k.a. "network cameras", are digital cameras that have a built-in web server.  This allows the camera to be accessed by any computer on the same network using a web browser.  Video is streamed to the web browser from the camera without additional equipment.  In a LinuxMCE system, IP cameras are easy to setup, but require some extra manipulation to get them to record.
  
==Quick Setup==
+
=IP Cameras and Motion Wrapper=
  
IP cameras can be brought online quickly with LinuxMCE by having their network settings set to DHCP.  LinuxMCE will assign the camera an IP address.
 
  
* Go into the "Surveillance Cameras" section of the LinuxMCE-admin pages and click on "Add Device". This should bring up the page as seen below:
+
IP cameras can be used under the Motion Wrapper to enable it to detect motion and alert based on that function.
  
[[Image:Adding Axis Cameras.png]]
+
==To add Motion Wrapper and IP Cameras.==
  
* Choose the camera by clicking in the "Models" window.  In the example above, "Axis IP Camera" is selected.  Click "Add Device". This will also close this window.  The original window should now display an entry for a new camera as so:
+
* Open your webadmin control panel and on the left pane at the bottom click on "Show Device Tree".
  
[[Image:Adding Axis Cameras2.png]]
+
* In the left pane Click on "core/hybrid".
  
* Insert the IP camera's MAC address in the field below the IP address.  You do not need to insert an IP address.  LinuxMCE will do this for you when it first detects the camera on the network.  If you wish, you can assign a static IP address by inserting it in the IP Address field.  Make sure the IP address is reachable by the LinuxMCE core.
+
* On the right pane near the top, click on "Create Child Device", then leave everything blank and click "Pick Device Template" button.
  
* Input the correct path to an image file of the camera.  Note:  Most IP cameras don't display videos.  Instead, they display many jpeg images at a high rate.  These jpeg images can be accessed by inputing the path to the image in a web browser, ''e.g.'' http://<ip address of camera>/axis-cgi/jpg/image.cgi for the Axis network camera.  LinuxMCE also uses these jpeg images to display "video" from the camera on orbiters by refreshing the jpeg frequently.  (See section below for configuration information.)
+
* Click the pull down box under "Device Template" and find the template labeled "Motion Wrapper", select this item and click "Pick Device Template"
  
* If you have configured an user-name and password to access the images from the camera, then enter it in the AuthUser and AuthPassword parameters.
+
* Now on the right pane, click "Create Child Device" again.  Enter your IP Cameras IP address and MAC address here, then click "Pick Device Template"
  
* In the LinuxMCE-admin page, go to the Floorplan Wizard, choose "Security Zone" from the drop-down menu, and move over each green square representing a camera to the floorplan roughly where either you have the camera or where the camera is viewing.
+
* Click the pull down box under "Device Template" and use "Generic Analog Camera", then click "Pick Device Template"
  
* Finally, do a Quick Reload Router from the Restart pageYou will also need to click "Reload & Regen All Orbiters" from the Advanced Options menu (click on the LinuxMCE icon on the lower left hand corner) of any orbiter.
+
* Now on the right window pane, scroll down to the bottom and find the field named "Configuration"This is where you put your cameras URL normally used by your web browser, to view your cameras video feed.  My examples are based on Axis based IP Cameras.
 +
<pre>
 +
netcam_url http://<you.cameras.ip.addreess>/mjpg/video.mjpg
 +
netcam_userpass username:password
 +
</pre>
 +
* Now click save at the bottom, reload your router, now on your mce interface go to "Security" -> "Generic Analog Camera" and see if it's working.
 +
 
 +
==Some tips on finding your cameras proper url.==
 +
 
 +
* Try to use ftp to connect to your camera.  The username and pass is usually whatever you set up on the web interface of the camera.  Traverse the folders to find your html documents folder.  Typically, your looking for a .jpg or .mjpg file to point the Motion Wrapper to.  For example, these are the possible links on an Axis 2100 IP Camera.
 +
<pre>
 +
/jpg/image.jpg (Works fine until the wrapper)
 +
/mjpg/video.mjpg (Works fine until the wrapper)
 +
/cgi-bin/jpg/image.cgi (I could not get this one working under the wrapper)
 +
/cgi-bin/mjpg/video.cgi (Again, could not get it to work)
 +
</pre>
 +
==For the motion detection and alerting==
 +
 
 +
* I only briefly looked at this capability before writing this article.  Feel free to add on to it, or i'll come back and post my findings after inkering with it.
  
 
==Using Motion to Record==
 
==Using Motion to Record==

Revision as of 01:15, 14 March 2008


Introduction

IP cameras, a.k.a. "network cameras", are digital cameras that have a built-in web server. This allows the camera to be accessed by any computer on the same network using a web browser. Video is streamed to the web browser from the camera without additional equipment. In a LinuxMCE system, IP cameras are easy to setup, but require some extra manipulation to get them to record.

IP Cameras and Motion Wrapper

IP cameras can be used under the Motion Wrapper to enable it to detect motion and alert based on that function.

To add Motion Wrapper and IP Cameras.

  • Open your webadmin control panel and on the left pane at the bottom click on "Show Device Tree".
  • In the left pane Click on "core/hybrid".
  • On the right pane near the top, click on "Create Child Device", then leave everything blank and click "Pick Device Template" button.
  • Click the pull down box under "Device Template" and find the template labeled "Motion Wrapper", select this item and click "Pick Device Template"
  • Now on the right pane, click "Create Child Device" again. Enter your IP Cameras IP address and MAC address here, then click "Pick Device Template"
  • Click the pull down box under "Device Template" and use "Generic Analog Camera", then click "Pick Device Template"
  • Now on the right window pane, scroll down to the bottom and find the field named "Configuration". This is where you put your cameras URL normally used by your web browser, to view your cameras video feed. My examples are based on Axis based IP Cameras.
netcam_url http://<you.cameras.ip.addreess>/mjpg/video.mjpg
netcam_userpass username:password
  • Now click save at the bottom, reload your router, now on your mce interface go to "Security" -> "Generic Analog Camera" and see if it's working.

Some tips on finding your cameras proper url.

  • Try to use ftp to connect to your camera. The username and pass is usually whatever you set up on the web interface of the camera. Traverse the folders to find your html documents folder. Typically, your looking for a .jpg or .mjpg file to point the Motion Wrapper to. For example, these are the possible links on an Axis 2100 IP Camera.
/jpg/image.jpg (Works fine until the wrapper)
/mjpg/video.mjpg (Works fine until the wrapper)
/cgi-bin/jpg/image.cgi (I could not get this one working under the wrapper)
/cgi-bin/mjpg/video.cgi (Again, could not get it to work)

For the motion detection and alerting

  • I only briefly looked at this capability before writing this article. Feel free to add on to it, or i'll come back and post my findings after inkering with it.

Using Motion to Record

[orionsune] Version 7.10 Beta 3 doesn't appear to have Motion installed by default. To do this, a simple:

$ sudo apt-get install motion

did the trick. [orionsune]

Unfortunately, the default IP camera setup under LinuxMCE will not record the camera footage. To do that, you need to use Motion. Instead of using the IP camera when you configure (delete the camera if you've already configured it as an IP camera), use a generic analog camera.

As before, insert the IP camera's MAC address in the field below the IP address. You do not need to insert an IP address. LinuxMCE will do this for you when it first detects the camera on the network. If you wish, you can assign a static IP address by inserting it in the IP Address field. Make sure the IP address is reachable by the LinuxMCE core.

Under "Path" type the path to the camera's image file. (See section below for configuration information.)

Controlled by should be set to "Motion Wrapper".

File:Surveillance Cameras.png

Now, you will need to access the LinuxMCE core by using SSH. Log in and type (without the '$' mark):

$ ls /etc/motion/

You should see at least the following files:

motion.conf
thread0.conf

[orionsune]I had to open motion.conf with my favorite text editor and remove or comment out the following line:[orionsune]

; videodevice /dev/video0

[orionsune]Otherwise the motion daemon would fail with an error about the video device, even if your IP camera is configured correctly in threadx.conf, it would still die with an error about video.[orionsune]


For each camera you have configured, there should be a "threadx.conf" file where x is replaced by the number of the camera starting with "0".

At the prompt, type:

$ nano /etc/motion/thread0.conf

This is the configuration file for the first camera. You will be greeted with a page that starts with:

videodevice /dev/video0
input 0
noise_level 32

followed by a bunch of other lines. Don't worry about those for now.

Comment out the first two lines with a hash in front and below it type:

netcam_url http://<ip_address_of_this_camera>/axis-cgi/jpg/image.cgi

So now it should look something like this but with your camera's IP address and the correct path to your camera's image file:

#videodevice /dev/video0
#input 0
netcam_url http://192.168.80.100/axis-cgi/jpg/image.cgi
input 0
noise_level 32

Hit CTL-x to save and quit. (Say yes when prompted by using the letter "y" and enter.) Unfortunately, when we reboot the orbiter or do a quick restart, this file will be overwritten. (Anyone that knows how to get this to work without better, please feel free to rewrite this section.) Therefore, we will make a backup copy by typing:

$ cp /etc/motion/thread0.conf /etc/motion/thread0.conf.backup

Do the same for any other cameras taking care that the IPs are different and the thread# is different.

[orionsune]Personally, I had to put everything that was in thread0.conf in my main motion.conf file, and comment out the video device. Otherwise my motion daemon just kept failing about error opening a video device. I simply used the thread0.conf file for my second camera, while the setting for my first camera had to be placed in motion.conf. I am assuming if you comment out the "videodevice" line in motion.conf it takes a default setting of /dev/video0 unless you specify otherwise with something like "netcam_url" as soon as I put that directive in my motion.conf file with the videodevice being commented out the whole time, it stopped looking for /dev/video0 and just took the ip cameras url as it's primary video device. Maybe an older version of motion didn't act this way? It does now.[orionsune]

Finally, you need to start motion as a daemon to have it run in the background. Type:

$ motion -D

You can also use this simple Perl program to copy over the backup files and to start motion as a daemon:

#! /usr/bin/perl
# Will copy over backup camera motion thread configurations and start motion.
# Assumes threadx.conf.backup exists.

use strict;

my $Nthread = 0;

while ( $Nthread > -1 ) {
        my $files = "/etc/motion/thread$Nthread.conf";
        if ( -e $files ) {
                print "$files exists...\n";
                `cp $files.backup $files`;
                $Nthread++;
                print "$Nthread \n";
        }
        else {
                print "$files missing or reached the end...\n";
                exit 0;
        }

}

`motion -D`;
exit 0;

If anyone knows how to set this script to run automatically on the core after a "Quick Reload Router" or reboot, please provide it here...

Available IP Cameras

Include here a list of IP security cameras that have been tested with LinuxMCE.

IP Security Cameras
Axis Network Cameras
D-Link Network Cameras