Difference between revisions of "IP Cameras"

From LinuxMCE
Jump to: navigation, search
m (moved categories)
 
(26 intermediate revisions by 11 users not shown)
Line 1: Line 1:
[[Category: Hardware]]
+
[[Category:IP Cameras| IP Cameras]]
[[Category: Cameras]]
+
{| align="right"
[[Category: Tutorials]]
+
  | __TOC__
 +
  |}
  
==Introduction==
+
See [[Monitor surveillance cameras]]
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 can be brought online quickly with LinuxMCE by having their network settings set to DHCP. LinuxMCE will assign the camera an IP address.
+
==Introduction==
 +
An IP camera, also called network camera, is a digital camera that has a built-in web server capable of serving streams of images that appear as live video. <br>
 +
Once connected to a network, the images from the camera can be accessed by any computer on the same network using a common web browser, without the need for additional equipment. The live video is streamed from the camera to the web browser. <br>
  
* 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:
+
LinuxMCE can tap into an IP video stream and make the videos available throughout the system. <br>
  
[[Image:Adding Axis Cameras.png]]
+
IP cameras can be easily incorporated in a LinuxMCE system. In this article, you will get all the instructions necessary for you to do add, configure, and troubleshoot 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:
+
{{p}}
  
[[Image:Adding Axis Cameras2.png]]
+
==IP Cameras and Motion Wrapper==
  
* 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.
+
IP cameras can be used under the Motion Wrapper to enable it to detect motion and send alerts.
  
* 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.)
 
  
* 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.
+
=== To add Motion Wrapper and IP Cameras ===
  
* 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.
+
==== Add the Motion Wrapper interface to the system ====
 +
LinuxMCE includes the device [[motion|Motion Wrapper]], which is a wrapper for the open source project [http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome Motion]. The [[motion|Motion Wrapper]] serves as the interface between LinuxMCE  and Motion. <br>
  
* Finally, do a Quick Reload Router from the Restart page.  You 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.
 
  
==Using Motion to Record==
+
To add the Motion Wrapper as a device:
  
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.
+
# Open your [[LinuxMCE Admin Website|webadmin]] control panel
 +
# Under Wizard: Devices > Interfaces
 +
# At the bottom of the page, click on '''Add device''' <br>  - ''Device Category'': '''Surveillance Video Interfaces''' (NOT Surveillance Cameras, that is in the pripherals category)<br>  - Click the pull down box under ''Device Template'' and find and select the template labeled '''Motion Wrapper'''.
 +
# Click on '''Pick device template'''. This creates the Interface device and displays it on the configuration page.
 +
# Under "Action" on the right side, click on '''Advanced'''.
  
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.
+
This installs the device Motion Wrapper in LinuxMCE. Once installed, the procedure does not need to be repeated and child devices can be added at will.
  
Under "Path" type the path to the camera's image file. (See section below for configuration information.)
+
;Note: You can also replace steps 1&2 with <br>on the left pane at the bottom click on '''Show Device Tree'''<pre> My Devices > CORE > Create Child Device > Pick device template</pre>There is no step 5 when using this method. You can start creating the child device.
  
Controlled by should be set to "Motion Wrapper".
+
{{p}}
  
[[Image:Surveillance Cameras.png]]
+
==== Add the IP camera ====
  
Now, you will need to access the LinuxMCE core by using SSHLog in and type (without the '$' mark):
+
===== Add the IP camera as a Generic Analog Camera to the Motion Wrapper =====
 +
# Now on the right pane, click '''Create Child Device''' again.   
 +
# Enter your IP Cameras IP address and MAC address here,
 +
# click '''Pick Device Template'''
 +
# Click the pull down box under ''Device Template'' and use '''Generic Analog Camera''',
 +
# 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.<pre>netcam_url http://<you.cameras.ip.addreess>/mjpg/video.mjpg</pre><pre>netcam_userpass username:password</pre>
 +
# Now click '''save''' at the bottom
 +
# RESTART your router
  
<pre>
+
Now on your LMCE interface, go to "Security" -> "Generic Analog Camera" and see if it's working.
$ ls /etc/motion/
+
</pre>
+
  
You should see at least the following files:
+
{{p}}
  
<pre>
+
===== Adding IP Cameras as a Generic Motion IP camera under Motion Wrapper =====
motion.conf
+
# From '''[[LinuxMCE Admin Website]]-->Advanced-->Configuration-->[[Devices]]''' Open '''CORE''' and then Click on '''Motion_Wrapper'''
thread0.conf
+
# From the top right frame press '''Create Child Device'''
</pre>
+
## Enter a description (or leave blank for default one), fill in the '''IP Address''' with your IP Camera's IP, and the '''MAC''' field with your IP Camera's MAC address.
 +
## Press '''Pick Device Template'''.  
 +
## In the "Device Template ***" section, select the template '''Generic Motion IP camera'''
 +
## Click '''Pick device template'''. This opens the camera's configuration page
 +
### In "Device Info", select the "Room" where your IP Cam is located
 +
### Scroll down to the '''Device data''' section.
 +
#### '''Path''' : set the path to your IP Camera current snapshot, it has to be a '''jpg''' or '''mjpg''' file
 +
#### "Protocol" : set the protocol to '''http''' or '''ftp''', default is http
 +
#### "TCP Port" : set the port on which your IP CAM it's feeding the images
 +
#### "Username" : set the username required to access your IP Cam
 +
#### "Password" : set the password required to access your IP Cam
 +
#### "Noise" : noise level for motion detection, default to 32
 +
### Click '''Save'''
 +
## Scroll up to the top menu and, on the left, select '''Wizard > Restart'''
 +
### Click on '''[[quick reload router|Quick Reload Router]]'''
 +
### Wait for the router to reload
 +
## Now scroll up to the top menu and, on the right, select '''Security > View cameras'''
 +
### Select the check box for the camera
 +
### Click '''Preview checked cameras'''
 +
# For the corresponding button to show, regenerate your orbiters.
  
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".
+
{{p}}
  
At the prompt, type:
+
== Adding Axis IP cameras to Motion ==
 +
To get all the features offered by Motion (motion detection,recording,etc...), you need to run your IP Camera under motion.
 +
Your camera can be auto detected, and device generated for it, but it might NOT be under Motion as parent. This is the case for the Axis camera.
  
<pre>
+
Here is a quick and not so clean workaround for adding an IP camera device under Motion:
$ nano /etc/motion/thread0.conf
+
</pre>
+
  
This is the configuration file for the first camera.  You will be greeted with a page that starts with:
+
# Add Generic Analog Camera #66 Device
 +
# Change Configuraton field to add data for IP camera
  
<pre>
+
Example for Axis camera :
videodevice /dev/video0
+
input 0
+
noise_level 32
+
</pre>
+
  
followed by a bunch of other lines. Don't worry about those for now.
+
  netcam_url  http://192.168.0.90/axis-cgi/jpg/image.cgi?resolution=640x480
 +
netcam_userpass username:password   
  
Comment out the first two lines with a hash in front and below it type:
+
Omit the last one if you don't have a access password specified.
  
<pre>
+
{{p}}
netcam_url http://<ip_address_of_this_camera>/axis-cgi/jpg/image.cgi
+
</pre>
+
  
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:
+
== Tips on finding your camera's URL ==
 
+
<pre>
+
#videodevice /dev/video0
+
#input 0
+
netcam_url http://192.168.80.100/axis-cgi/jpg/image.cgi
+
input 0
+
noise_level 32
+
</pre>
+
  
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:
+
# 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<br>Typically, you're 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>
 
<pre>
$ cp /etc/motion/thread0.conf /etc/motion/thread0.conf.backup
+
/jpg/image.jpg (Works fine using the wrapper)
 +
/mjpg/video.mjpg (Works fine using 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>
 
</pre>
 +
{{p}}
  
Do the same for any other cameras taking care that the IPs are different and the thread# is different.
+
== Installing an "external" network camera ==
  
Finally, you need to start motion as a daemon to have it run in the background. Type:
+
This section describes how to install an IP camera as a [[Motion]] device.
  
<pre>
+
<span style="color:red">'''''Note: These instructions are for when the camera is plugged into a router on the external network, as opposed to a switch on the internal network. Not ideal, but it is sometimes necessary due to [http://forum.linuxmce.org/index.php?topic=10134.0 this aforementioned problem].'''''</span>
$ motion -D
+
</pre>
+
  
You can also use this simple Perl program to copy over the backup files and to start motion as a daemon:
+
# Install motion wrapper (if it is not installed already). <br>In web admin (type "192.168.80.1" in a browser of your choice), click '''Show devices tree''' (very bottom of left-hand pane)<br>click on '''CORE''' and then '''Create Child Device'''. <br>Then press the '''Pick device template''' button, which will open a new window. <br>Under "''Device Template''", select '''Motion Wrapper''' and press the '''Pick device template''' button.
 +
# Plug your camera into the external router. In your router admin page (accessed via 192.168.1.1 in my case) find out what IP was assigned. Type this IP into your browser and have a look through the options. Set the username and password. I also set a static IP just in case it tries to change itself. I also specified the camera's IP on my router so that no other device could take it (belt and braces).
 +
# In LMCE web admin ("192.168.80.1" into a browser), go to '''Wizard''' -> '''Devices''' -> '''Surveillance Cameras'''. <br>Click the '''Add Device''' button at the bottom of the page. This will open a new window.
 +
# In the window that just opened, pick '''Generic Motion IP Camera''' from the drop-down menu in the ''Device Template'' section. <br>Press the '''Pick device template''' button.
 +
# Find the new camera in '''Wizard''' -> '''Devices''' -> '''Surveillance Cameras'''. Change the description to something more obvious if you so wish and select a room.
 +
# Change the '''Path''' field to match your camera's URL as indicated in the previous section. In my case, I used "http://192.168.1.XXX/videostream.cgi?user=XXXXX&pwd=XXXXXX". <br>Do not forget to replace the Xs with the IP, username and password. <br>Add "80" to the '''TCP Port''' field. Press '''Save'''.
 +
# Press the '''Advanced''' button. Check the IP and MAC address in the "Device Info" section. If it's not the same as the MAC and IP you saw in the camera's utility, change it. Click '''Save'''.
 +
# Do a '''Reload & Regen''', and that should be it.
  
<pre>
+
This camera can now be used as a motion sensor and/or for recording movement (recordings are stored in "/home/cameras/XX" where XX is the device number of the camera, and last for 5 days I believe). A scenario will hopefully be automatically generated.
#! /usr/bin/perl
+
# Will copy over backup camera motion thread configurations and start motion.
+
# Assumes threadx.conf.backup exists.
+
  
use strict;
+
Repeat the above procedure for any additional cameras.
  
my $Nthread = 0;
+
;Note: The old issue of Motion dying after reloading/restarting the Core has been fixed. It is no longer necessary to restarted it manually by doing a "<code>sudo /etc/init.d/motion restart</code>". This issue has been reported http://svn.linuxmce.org/trac.cgi/ticket/904 & http://svn.linuxmce.org/trac.cgi/ticket/715 You can read about the resolution there if you'd like to. {{p}}Very occasionally I have found that the scenarios sometimes require a little bit of tinkering. If there is no image displayed when you click on the scenario, look in Wizard -> Scenarios -> Security scenarios, select the scenario in question, select "Advanced Wizard" in the "Edit scenario using wizard" section, and just check that the number in the "#2 PK_Device (int)" field corresponds with the camera's Device #; if it does not, change it. Reload & Regen.''
  
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;
 
        }
 
  
}
+
{{p}}
  
`motion -D`;
+
== LinuxMCE compatible IP Cameras ==
exit 0;
+
 
+
</pre>
+
  
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...
+
For a list of IP security cameras that have been tested with LinuxMCE, see:
  
==Available IP Cameras==
+
* See articles in the [[:Category:Cameras|Camera Category]]
  
Include here a list of IP security cameras that have been tested with LinuxMCE.
+
{{p}}
{| class="wikitable" width="300" style="text-align:center; background:#efefef; width:75%; border:1px solid black"
+
|+ IP Security Cameras
+
|-
+
| [[Axis Network Cameras]]
+
|-
+
| [[D-Link]]
+
|}
+

Latest revision as of 08:21, 23 October 2012

See Monitor surveillance cameras


Introduction

An IP camera, also called network camera, is a digital camera that has a built-in web server capable of serving streams of images that appear as live video.
Once connected to a network, the images from the camera can be accessed by any computer on the same network using a common web browser, without the need for additional equipment. The live video is streamed from the camera to the web browser.

LinuxMCE can tap into an IP video stream and make the videos available throughout the system.

IP cameras can be easily incorporated in a LinuxMCE system. In this article, you will get all the instructions necessary for you to do add, configure, and troubleshoot IP cameras.



IP Cameras and Motion Wrapper

IP cameras can be used under the Motion Wrapper to enable it to detect motion and send alerts.


To add Motion Wrapper and IP Cameras

Add the Motion Wrapper interface to the system

LinuxMCE includes the device Motion Wrapper, which is a wrapper for the open source project Motion. The Motion Wrapper serves as the interface between LinuxMCE and Motion.


To add the Motion Wrapper as a device:

  1. Open your webadmin control panel
  2. Under Wizard: Devices > Interfaces
  3. At the bottom of the page, click on Add device
    - Device Category: Surveillance Video Interfaces (NOT Surveillance Cameras, that is in the pripherals category)
    - Click the pull down box under Device Template and find and select the template labeled Motion Wrapper.
  4. Click on Pick device template. This creates the Interface device and displays it on the configuration page.
  5. Under "Action" on the right side, click on Advanced.

This installs the device Motion Wrapper in LinuxMCE. Once installed, the procedure does not need to be repeated and child devices can be added at will.

Note
You can also replace steps 1&2 with
on the left pane at the bottom click on Show Device Tree
	My Devices > CORE > Create Child Device > Pick device template
There is no step 5 when using this method. You can start creating the child device.



Add the IP camera

Add the IP camera as a Generic Analog Camera to the Motion Wrapper
  1. Now on the right pane, click Create Child Device again.
  2. Enter your IP Cameras IP address and MAC address here,
  3. click Pick Device Template
  4. Click the pull down box under Device Template and use Generic Analog Camera,
  5. click Pick Device Template
  6. 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
  7. Now click save at the bottom
  8. RESTART your router

Now on your LMCE interface, go to "Security" -> "Generic Analog Camera" and see if it's working.



Adding IP Cameras as a Generic Motion IP camera under Motion Wrapper
  1. From LinuxMCE Admin Website-->Advanced-->Configuration-->Devices Open CORE and then Click on Motion_Wrapper
  2. From the top right frame press Create Child Device
    1. Enter a description (or leave blank for default one), fill in the IP Address with your IP Camera's IP, and the MAC field with your IP Camera's MAC address.
    2. Press Pick Device Template.
    3. In the "Device Template ***" section, select the template Generic Motion IP camera
    4. Click Pick device template. This opens the camera's configuration page
      1. In "Device Info", select the "Room" where your IP Cam is located
      2. Scroll down to the Device data section.
        1. Path : set the path to your IP Camera current snapshot, it has to be a jpg or mjpg file
        2. "Protocol" : set the protocol to http or ftp, default is http
        3. "TCP Port" : set the port on which your IP CAM it's feeding the images
        4. "Username" : set the username required to access your IP Cam
        5. "Password" : set the password required to access your IP Cam
        6. "Noise" : noise level for motion detection, default to 32
      3. Click Save
    5. Scroll up to the top menu and, on the left, select Wizard > Restart
      1. Click on Quick Reload Router
      2. Wait for the router to reload
    6. Now scroll up to the top menu and, on the right, select Security > View cameras
      1. Select the check box for the camera
      2. Click Preview checked cameras
  3. For the corresponding button to show, regenerate your orbiters.



Adding Axis IP cameras to Motion

To get all the features offered by Motion (motion detection,recording,etc...), you need to run your IP Camera under motion. Your camera can be auto detected, and device generated for it, but it might NOT be under Motion as parent. This is the case for the Axis camera.

Here is a quick and not so clean workaround for adding an IP camera device under Motion:

  1. Add Generic Analog Camera #66 Device
  2. Change Configuraton field to add data for IP camera

Example for Axis camera :

netcam_url  http://192.168.0.90/axis-cgi/jpg/image.cgi?resolution=640x480
netcam_userpass username:password    

Omit the last one if you don't have a access password specified.



Tips on finding your camera's URL

  1. 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.
  2. Traverse the folders to find your html documents folder.
    Typically, you're 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 using the wrapper)
/mjpg/video.mjpg (Works fine using 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)



Installing an "external" network camera

This section describes how to install an IP camera as a Motion device.

Note: These instructions are for when the camera is plugged into a router on the external network, as opposed to a switch on the internal network. Not ideal, but it is sometimes necessary due to this aforementioned problem.

  1. Install motion wrapper (if it is not installed already).
    In web admin (type "192.168.80.1" in a browser of your choice), click Show devices tree (very bottom of left-hand pane)
    click on CORE and then Create Child Device.
    Then press the Pick device template button, which will open a new window.
    Under "Device Template", select Motion Wrapper and press the Pick device template button.
  2. Plug your camera into the external router. In your router admin page (accessed via 192.168.1.1 in my case) find out what IP was assigned. Type this IP into your browser and have a look through the options. Set the username and password. I also set a static IP just in case it tries to change itself. I also specified the camera's IP on my router so that no other device could take it (belt and braces).
  3. In LMCE web admin ("192.168.80.1" into a browser), go to Wizard -> Devices -> Surveillance Cameras.
    Click the Add Device button at the bottom of the page. This will open a new window.
  4. In the window that just opened, pick Generic Motion IP Camera from the drop-down menu in the Device Template section.
    Press the Pick device template button.
  5. Find the new camera in Wizard -> Devices -> Surveillance Cameras. Change the description to something more obvious if you so wish and select a room.
  6. Change the Path field to match your camera's URL as indicated in the previous section. In my case, I used "http://192.168.1.XXX/videostream.cgi?user=XXXXX&pwd=XXXXXX".
    Do not forget to replace the Xs with the IP, username and password.
    Add "80" to the TCP Port field. Press Save.
  7. Press the Advanced button. Check the IP and MAC address in the "Device Info" section. If it's not the same as the MAC and IP you saw in the camera's utility, change it. Click Save.
  8. Do a Reload & Regen, and that should be it.

This camera can now be used as a motion sensor and/or for recording movement (recordings are stored in "/home/cameras/XX" where XX is the device number of the camera, and last for 5 days I believe). A scenario will hopefully be automatically generated.

Repeat the above procedure for any additional cameras.

Note
The old issue of Motion dying after reloading/restarting the Core has been fixed. It is no longer necessary to restarted it manually by doing a "sudo /etc/init.d/motion restart". This issue has been reported http://svn.linuxmce.org/trac.cgi/ticket/904 & http://svn.linuxmce.org/trac.cgi/ticket/715 You can read about the resolution there if you'd like to.

Very occasionally I have found that the scenarios sometimes require a little bit of tinkering. If there is no image displayed when you click on the scenario, look in Wizard -> Scenarios -> Security scenarios, select the scenario in question, select "Advanced Wizard" in the "Edit scenario using wizard" section, and just check that the number in the "#2 PK_Device (int)" field corresponds with the camera's Device #; if it does not, change it. Reload & Regen.




LinuxMCE compatible IP Cameras

For a list of IP security cameras that have been tested with LinuxMCE, see: