loading

Welcome!

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 http://terzo.acmesystems.it/download/webcam/mjpg-streamer.tar.gz

# tar -zxvf mjpg-streamer.tar.gz

# cd mjpg-streamer

Comment the following line in the Makefile:

PLUGINS += input_gspcav1.so

Make

# make

Copying Files

# sudo cp mjpg_streamer /usr/local/bin

# sudo cp output_http.so input_uvc.so /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: 192.168.1.2/index.html

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 "input_uvc.so -f 25 -r 640x480" -o "output_http.so -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 runWebcam.sh

Edit the file with the following contents:

#!/bin/bash
fswebcam -r 640x480 test.jpeg -S 20

rm test.jpeg

export LD_LIBRARY_PATH=/usr/local/lib

usr/local/bin/mjpg_streamer -i "input_uvc.so -f 25 -r 640x480" -o "output_http.so -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 "input_uvc.so -f 25 -r 640x480" -o "output_http.so -w /usr/local/www" & )


Exit and Save.


# chmod a+x runWebcam.sh

Test it.


# ./runWebcam.sh

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.


<p>do you have tutorial with another os? like windows? if you have it please sent to me marciarzky@gmail.com</p><p>i have many problem for connect the webcam to my pc</p>
<p>Hello, i have managed to install everything specifically but i have one last problem..</p><p>it cant see the output stream when i run this mjpg_streamer -i &quot;input_uvc.so -f 25 -r 640x480&quot; -o &quot;output_http.so -w /usr/local/www&quot;</p><p>all i see is this on mozilla firefox..</p><p>please help.. :(</p>
<p>We have the same problem GanzM!! :(<br><br></p>
<p>Man, I just made the light go blink blink. I'll have to work my way up to this one.</p>
<p>I got stuck in the second step when copying files, I can't find any output_http.so file neither an input_uvc.so file and the only one with the name mjpg-streamer is the directory so there is no case to copy the other ones isn't it? I need help!</p>
Wow!, This is a great project.... thanks for the info!.

About This Instructable

10,807views

30favorites

License:

Bio: Hello! I am a student studying Computer Science with a background in Engineering as a hobbyist. C/C++ is my strength and time is my ...
More by Nava-Juarez:Joystick Controlled Surveillance Camera Streaming USB Webcam with the Intel Galileo Gen 2 Building a Debian Linux Distribution for the Intel Galileo 
Add instructable to: