Introduction: Streaming USB Webcam With the Intel Galileo Gen 2

About: I help ambitious entrepreneurs start, build, and grow their online business.


Today we will learn how to stream a USB webcam with the Intel Galileo Gen 2.

We will need the use of "apt-get" so a Debian Linux Build is needed on your Galileo.

Follow my Instructable for Building a Debian Linux Distribution for the Intel Galileo

Compatible Devices Check

The Drivers we will be using are the UVC video drivers.

The USB video device class (also USB video class or UVC) is a USB device class that describes devices capable of streaming video like webcams, digital camcorders, analog video converters, and still-image cameras.

This link here holds a List of Compatible UVC Devices

Once you have your Debian Build SD Card and you've checked that your webcam is compatible then we are ready to move forward!

Step 1: Prerequisites

Install libjpeg-dev and libv4l-dev

Run the following commands:

# apt-get install libjpeg-dev

# apt-get install libv4l-dev

Create a soft link to /usr/include/linux/videodev2.h

# ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h

Setup Directories

# cd /home

# mkdir Downloads

# cd Downloads

Setting up a local server

# apt-get install apache2 php5 libapache2-mod-php5

Step 2: Installing Mjpg_streamer and Fswebcam

Enter the following Commands to download and install mjpg_streamer:

# wget

# tar -zxvf mjpg-streamer.tar.gz

# cd mjpg-streamer

Comment the following line in the Makefile:



# make

Copying Files

# sudo cp mjpg_streamer /usr/local/bin

# sudo cp /usr/local/lib/

# cp -R www /usr/local/www

Installing fswebcam

# apt-get install fswebcam

Step 3: Testing the Webcam

Plug in your webcam and type:

# dmesg

Depending on your Webcam, you'll see an input device of some sort. Mine reads:

[ 12.721488] input: UVC Camera (046d:0825) as /devices/pci0000:00/0000:00:14.3/usb2/2-1/2-1:1.0/input/input2

Change Directory to our public server:

# cd /var/www

Test your server by typing <IP-Address>/index.html in your browser

For Example:

And you should see a page with a header "It Works!

Now we will test the webcam by capturing a jpeg image and sharing it on our server so we can see it from the browser.

# fswebcam -r 640x480 test.jpeg -S 20

// The -S 20 Parameter Skips 20 Frames. Useful because some cameras will capture a black image. Downsides is it delays in seconds. Feel free to play around with the parameter.

Once the picture is taken successfully, navigate to <IP-Address>/test.jpeg

And you should see a picture of whatever was in front of your camera!

Step 4: Streaming Your Webcam

We are now ready to stream the webcam!

Run the following commands:

# cd /

# export LD_LIBRARY_PATH=/usr/local/lib

# mjpg_streamer -i " -f 25 -r 640x480" -o " -w /usr/local/www"

In your browser type in <IP-Address>:8080/stream_simple.html

Congratulations you have are successfully streaming your webcam!

Step 5: Wrapping Up

I would recommend creating a script that sets up and starts the camera instead of typing many commands each time you want to start streaming.

# cd /home

# nano

Edit the file with the following contents:

fswebcam -r 640x480 test.jpeg -S 20

rm test.jpeg

export LD_LIBRARY_PATH=/usr/local/lib

usr/local/bin/mjpg_streamer -i " -f 25 -r 640x480" -o " -w /usr/local/www"

This script will capture a test image, remove it, set path environment for mjpg_streamer and run it

If you would like to run it in the background, add a '&' after the last command

(mjpg_streamer -i " -f 25 -r 640x480" -o " -w /usr/local/www" & )

Exit and Save.

# chmod a+x

Test it.

# ./

Check out this video of a project I came up with myself that uses this tutorial:

Joystick Controlled Surveillance Camera

Goodluck! and Thank you for reading my instructable.