Yesterday I showed you how to connect and stream an Xbox LIVE vision Camera from an Ubuntu computer to the internet (or your local network). Today we’re going to go a step further and set up a piece of software called Motion to not only stream the video but it will watch for motion and capture still frames when it sees any.
This is a fairly easy process.
What we need
- Our Ubuntu/Xbox LIVE Vision cam setup from yesterday
- An internet connection
Now as with the previous walkthrough we’re going to open up a terminal window
The first command we’ll run is
sudo apt-get install motion
This will fetch and install the Motion software package from the Ubuntu software repositories.
Now that we have Motion installed we need to tweak it’s configuration files to have it stream via webpage
so we type
sudo vi /etc/motion/motion.conf
(Replace “vi” with “gedit” if you want to do this via your gui)
This opens the main motion config file for editing
We need to replace the following lines
# Image width (pixels). Valid range: Camera dependent, default: 352 width 320
# Image width (pixels). Valid range: Camera dependent, default: 352 width 640
# Image height (pixels). Valid range: Camera dependent, default: 288 height 240
# Image height (pixels). Valid range: Camera dependent, default: 288 height 480
# Quality of the jpeg images produced (default: 50) webcam_quality 50
# Quality of the jpeg images produced (default: 50) webcam_quality 80
# Restrict webcam connections to localhost only (default: on) webcam_localhost on
# Restrict webcam connections to localhost only (default: on) webcam_localhost off
Save the file ( “esc” then “:wq” in vi. Just use the menus if you used gedit)
now we can test motion to see if it’s working.
You should get output similar to the following
 Processing thread 0 - config file /etc/motion/motion.conf  Motion 3.2.9 Started  ffmpeg LIBAVCODEC_BUILD 3352064 LIBAVFORMAT_BUILD 3344896  Thread 1 is from /etc/motion/motion.conf  Thread 1 started  cap.driver: "uvcvideo"  cap.card: "Video Camera "  cap.bus_info: "0000:00:02.2"  cap.capabilities=0x04000001  - VIDEO_CAPTURE  - STREAMING  Supported palettes:  0: MJPG (MJPEG)  1: YUYV (YUV 4:2:2 (YUYV))  motion-httpd/3.2.9 running, accepting connections  motion-httpd: waiting for data on port TCP 8080  Test palette YUYV (640x480)  Using palette YUYV (640x480) bytesperlines 1280 sizeimage 614400 colorspace 00000008  found control 0x00980903, "Hue", range -180,180  "Hue", default 0, current 0  found control 0x00980910, "Gamma", range 180,250  "Gamma", default 180, current 180  found control 0x00980913, "Gain", range 0,255  "Gain", default 0, current 24  found control 0x08000000, "Backlight Compensation", range 0,1  "Backlight Compensation", default 0, current 0  found control 0x08000001, "Power Line Frequency", range 0,2  "Power Line Frequency", default 2, current 2  mmap information:  frames=4  0 length=614400  1 length=614400  2 length=614400  3 length=614400  Using V4L2  Started stream webcam server in port 8081
If you do use your web browser to go to http://your.ip.address:8081 (replace your.ip.address with the IP address of the computer Motion is installed on)
you should get a webpage with a view from your webcam. Success!
Now a couple tweaks you can make.
By default motion saves the images of motion to /tmp/motion if you want to change this folder you just need to edit the “target_dir /tmp/motion” entry in the /etc/motion/motion.conf while you’re in there you can increase the fps of the feed by changing the “webcam_maxrate 1” entry to a higher number as well if you want to run this full time you may want to run it as a daemon which means it will run in the background to do this just set the “daemon” entry in the motion.conf file to “on” instead of “off”.
If you have any questions or suggestions please feel free to leave them in the comments.