BananaPro/Pi:Webcam

From BananaPro/Pi
Jump to: navigation, search

Introduction

By the term 'webcam', we mean a USB Camera which can be driven directly from the USB port on the Banana Pi. This page mainly instructs the reader on how to use USB camera in two ways: local usage & as a web camera server.


Test Items

SD card image: Raspbian for the B-Pi

USB Camera: Bluelover S11 (20RMB)


Local Usage

1. First check the USB camera has been identified by your Banana Pi using this command:

lsusb

which will give you an output something like this:

pi@bananapi ~ $ lsusb
Bus 001 Device 002: ID 1a40:0101 Terminus Technology Inc. 4-Port HUB
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
[color=Red]Bus 001 Device 003: ID 0ac8:3420 Z-Star Microelectronics Corp. Venus USB2.0 Camera[/color]
Bus 001 Device 004: ID 062a:4101 Creative Labs
 
pi@bananapi ~ $ ls /dev/video*
[color=Red]/dev/video0[/color]


2. Install mplayer:


sudo apt-get install mplayer


3. Start the program to use the USB camera to capture video:


sudo mplayer tv://


4. Here is the result:


Camera local test.png



Web Camera Server

According to our first test above, the USB camera works well on the B-Pi, and we can watch the video on a monitor connected to the Pi. But sometimes we want to use the B-Pi to play a role as an IP camera. It can be used to monitor your house from anywhere so that nobody dares break into your lovely house!!

1. Similar to the above, use the command lsusb to check that the USB camera has been identified by our Pi. Now we need to install the software. For that, we are going to be using a great little application called Motion. This will do a few things for us including accessing the USB cam, getting the images and then streaming them via a built in web server. As the name suggests it will also track and trigger events and motions that have been detected in the video frames (more on that later).


sudo apt-get install motion


2. Make sure that your B-Pi has access to internet and check its IP address:

ifconfig


3. Configure the software:


sudo nano /etc/motion/motion.conf


Here there are a few basic changes that you need to perform:


Daemon = OFF to ON
webcam_localhost = ON to OFF


You can change other settings too but it’s recommended that for stability reasons you don’t take more than 2 frames, and that you keep the default frame pixel size.


4. Start the software.

To ensure that the motion service will actually start as a daemon we need to change another configuration setting, so we enter the following:


sudo nano /etc/default/motion


Then change the value "start_motion_daemon=no" to "yes"


Finally you can start the motion service to stream the webcam images:


sudo service motion start


Then after about 30 seconds, use your PC to browse to the new web interface which should be at this URL (where 192.168.1.125 is your Banana PI's IP address)


http://192.168.1.125:8081


Notes:

1. Using Firefox browser didn't work. I tested it in other browsers, such as IE, Google Chrome, Cheetah Browser (in China it's called liebao), 360, etc. Maybe FF lacks the necessary plugin(s) for a web USB server, perhaps there were other reasons.

2. You can modify the image width and image height (default is 352 x 288) for any suitable screen. If you cannot get the desired result, it's recommended that you try to modify these parameters.


If all goes well, you can watch the frames captured by the USB camera.

Camera web sever.png


Useful Links

Motion Home Page: http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome