Introduction: Intel Edison IP Webcam

Picture of Intel Edison IP Webcam

Who else loves 3D printing? Those of you who do, you must agree with me in that you hate finding your printer finished but it came off the bed half way. Buying an IP webcam is not an option, because you don't want to spend $150 on a camera. The only real option is to do it like any other hacker: make your own! There are so many single-board computers that we all have and love including Raspberry Pi, Beaglebone and now the Intel Edison. These computers really are computers, in that they run a full operating system, Linux. In this Instructable, I will be guiding you in setting up a webcam server on an Intel Edison. These steps may or may not work on other boards like the RPi or Beaglebone.

Before I get started, I must say that this is not entirely my work. I found a guide on Github and followed the process there. I hit snags, so my twist is showing you how I got around them. If you want to skip over my instructions and go straight for the original tutorial, you may do so here.

Also, I want to thank Intel and Instructables for being awesome by selecting me along with 249 others to receive a Dev Kit. That was very surprising to me, and I am very grateful for it. Thank you!

Step 1: Getting Ready

Picture of Getting Ready

Most other Intel Edison tutorials and projects use the Edison in "device" mode. This project will have the Edison in control mode, which lets the board control the USB. To turn the Edison to control mode, flip the switch beside the USBs toward the large USB and power ports. Power up your Edison with a center-positive 7-15v power supply.

Note: before going any farther, you need to make sure your webcam is UVC-compatible which is supported by the program we use, ffmpeg. To find a list of supported cameras, go to this link here. Mine is a Logitech C600.

If you don't know so already, make a note of the name of your Edison, along with its password.

Step 2: Install the Packages

Package Manager

You need to configure your opkg repository to include the following lines:

    src/gz all http://repo.opkg.net/edison/repo/all
    src/gz edison http://repo.opkg.net/edison/repo/allsrc/gz src/gz core2-32 http://repo.opkg.net/edison/repo/allsrc/gz

Do so by typing:

    vi /etc/opkg/base-feeds.conf

Using vi as a text editor is different. If you need help, check out this page.

After that's done, browse to the edi-cam directory:

    cd /edi-cam

Now type:

    cp /etc/opkg/base-feeds.conf /etc/opkg

And finally update opkg:

    opkg update

Install Git

Type:

    opkg install git

Clone the repository:

    git clone https://github.com/drejkim/edi-cam.git

Install the UVC driver

Install the driver:

    opkg install kernel-module-uvcvideo

Make sure the webcam is seen

Unplug the webcam and plug it back in. Type the following and see the output:

    dmesg -c

Near the end it should look close to this (this example came from the Github notes):

    [   92.910838] hub 2-0:1.0: USB hub found
    [   92.910899] hub 2-0:1.0: 1 port detected
    [   92.957888] pmic_ccsm pmic_ccsm: USB VBUS Detected. Notifying OTG driver
    [   93.210150] usb 1-1: new high-speed USB device number 2 using dwc3-host
    [   93.329961] usb 1-1: New USB device found, idVendor=041e, idProduct=4095
    [   93.329992] usb 1-1: New USB device strings: Mfr=3, Product=1, SerialNumber=2
    [   93.330014] usb 1-1: Product: Live! Cam Sync HD VF0770
    [   93.330033] usb 1-1: Manufacturer: Creative Technology Ltd.
    [   93.330052] usb 1-1: SerialNumber: 2014090439994
    [   93.339634] uvcvideo: Found UVC 1.00 device Live! Cam Sync HD VF0770 (041e:4095)
    [   93.352641] input: Live! Cam Sync HD VF0770 as /devices/pci0000:00/0000:00:11.0/dwc3-host.2/usb1/1-1/1-1:1.0/input/input3

If you don't see anything close to this, your webcam may not be supported by UVC.

See if the device node was created:

    ls -l /dev/video0
    

And it should look similar to the following:

    crw-rw----    1 root     video      81,   0 Dec 20 21:23 /dev/video0

Install ffmpeg

You will need to change a setting in the install_ffmpeg.sh script. Look for:

    FNAME=ffmpeg-2.4.3-32bit-static.tar.xz

and change it to:

    FNAME=ffmpeg-2.5.1-32bit-static.tar.xz

Do the same in do_ffmpeg.sh.

Navigate to the bin folder within edi-cam and type:

    ./install_ffmpeg.sh

Install Node.js

Browse to web/server by typing:

    cd /edi-cam/web/server

and install Node.js by typing:

    npm install

Step 3: Run the Server

You need to modify the variable wsUrl in /web/client/index.html:

    vi /edi-cam/web/client

And change the following code:

    // CHANGE THIS TO THE APPROPRIATE WS ADDRESS

    var wsUrl = 'ws://myedison.local:8084/';

by replacing "myedison" with the name of your Edison.


Start the server and convert the video with ffmpeg

You will need to enter 2 commands into one line. This is because you need to run a command after starting the server, but the server locks out SSH commands.

cd to the root directory:

    cd /

and type the following:

    node /edi-cam/web/server/server.js | ./edi-cam/bin/do_ffmpeg.sh

Now your server should be running, and you can move on to the next step!

Step 4: Connect to the Web Server

Picture of Connect to the Web Server

Now that the hard part is finished, you can start viewing whatever is in front of your camera! Remember when you changed "myedison" to the name of your Edison? You need to first be on the same network as your Edison, then go to "http://myedison.local:8082" where myedison is changed like before. What should pop up is a blank webpage with a single box in the center. It may take a bit to load, but that box will turn into the live feed! My latency (lag) is very slight, which is surprising because my router is upstairs. Anyway, now all you need to do it put the Edison where you want it, face the camera at what you wish, and plug in your Edison. Once it boots up, connect to it via SSH and run the following 2 commands:

    cd /
    node /edi-cam/web/server/server.js | ./edi-cam/bin/do_ffmpeg.sh

And you can now view your webcam feed whenever you'd like!

Step 5: Mounting It

Picture of Mounting It

As I said in the beginning, I did this to spy on my 3D printer. My printer rests in my basement where it's cold and not very welcoming. I try to stay out of my basement as much as I can, which is a problem because I am constantly 3D printing. With over 700 hours on my printer, I've had quite a few hiccups costing many more hours. For large prints, I would check every 30 minutes to see if something went wrong so I can save the disappointment and even more plastic.

There's my reason to hack. What is yours? I'd love to see what others can do with this! Thanks!

Comments

DhanyaN4 (author)2017-09-27

Could i know how i can change the ffmpeg script and save it so that i can add it to puTTY

ValeG1 (author)2016-10-18

Hello, I hope you can help.

how you could get the video ip in opencv?

BenH191 (author)2016-08-21

Hello All,

I am attempting to make this work with an Inland ProHT camera and an Intel Edison. I am able to get the live stream to work in a browser for roughly 1-2 minutes before the feed freezes. Any idea as to why this would be occurring?

Thank you!

BenH191 made it! (author)BenH1912016-08-22

I solved 2 minute timeout by doing the following:

1. Go to your SSH tool (I'm using putty).

2. Type "cd" and hit enter.

3. Type "cd edi-cam/web/server" and hit enter.

4. Type "vi server.js" and hit enter.

5. Scroll down to the section shown in the attached image. ("http.createServer(function (req, res) {....").

6. Add "res.connection.setTimeout(0);" after the "req.on('data...'") function.

7. Hit "Esc key" and type ":w" then hit enter.

8. Now type ":x".

9. Now try opening your server and see if the feed freezes and times out at 2 minutes. If not you successfully completed this!

Note: If you do not have edi-cam installed or do not have node.js installed you will have issues with these instructions.

ankit.pitroda (author)2016-07-08

hello,

Always i m getting this error.

Tired of soving this

please give me the solution.

The error is like this:

Collected errors:

* opkg_download: Failed to download http://iotdk.intel.com/repos/3.5/intelgalactic/op... wget returned 8.

please tell me asap

thank you

BenjaminC65 (author)2016-04-24

Recently built this with the most recent version of Yocto. There was no need to modify the opkg base-feeds and update. In fact, it burned me when I did. Just go straight to the 'install git' step if you have the latest image.

Additionally, if you plan to use this to view the ip cam in an Andriod app, as I did, then you will need to modify the wsURL even further by including the actual IP address of the edison. While edison.local works fine on desktop browsers, it doesn't work for chrome android browser, or the webView class in Java. So, essentially replace the 'myedison.local' part of that variable with the actual IP. Al least, this was my solution...

I hope this comment will save someone the time it took me to figure it out!

kyubot (author)2016-02-17

I was able to get video streaming as described in your tutorial. Thanks!

However I want to embed the streaming video on other web page on different port. How can I make this happen?

I tried to embed following script in my index.html but not working as expected.

<div>

<!--

The canvas size specified here is the "initial" internal resolution. jsmpeg will

change this internal resolution to whatever the source provides. The size the

canvas is displayed on the website is dictated by the CSS style.

-->

<canvas id="canvas-video" width="320" height="240"></canvas>

</div>

<script src="/jsmpg.js"></script>

<script type="text/javascript">

// CHANGE THIS TO THE APPROPRIATE WS ADDRESS

var wsUrl = 'ws://lidaredison.local:8084/';

// Show loading notice

var canvas = document.getElementById('canvas-video');

var ctx = canvas.getContext('2d');

ctx.fillStyle = '#333';

ctx.fillText('Loading...', canvas.width/2-30, canvas.height/3);

// Start the player

var client = new WebSocket(wsUrl);

var player = new jsmpeg(client, { canvas:canvas });

</script>

Thanks,

Howe

TjY1 (author)2015-11-03

You need to modify the variable wsUrl in /web/client/index.html:


    vi /edi-cam/web/client

And change the following code:


    // CHANGE THIS TO THE APPROPRIATE WS ADDRESS

    var wsUrl = 'ws://myedison.local:8084/';


by replacing "myedison" with the name of your Edison.


I don't know how to do this part, please help

DhruvK (author)2015-05-10

Don't use below command to install uvcvideo driver as of now with new kernel ww05-15 yocto image , uvcvideo driver is inbuilt. So if you will install those drivers again by below command then you are going to do something wrong. So just plug in your camera with Edison and you're good to go. Other steps are necessary.

opkg install kernel-module-uvcvideo

DangerousTim (author)DhruvK2015-06-04

DO you mean release2 of the edison image? Even if its already there, wouldnt opkg just cancel the install or upgrade it?

kc.goh.71 (author)2015-04-17

The package repo stated in Step 2 is no longer valid, I've changed to below and working now:

src/gz
all http://repo.opkg.net/edison/repo/all

src/gzedison
http://repo.opkg.net/edison/repo/edison

src/gz
core2-32 http://repo.opkg.net/edison/repo/core2-32

lukerrs (author)2015-04-09

Hi, thank you for this! Where do I get the install_ffmpeg.sh script? It is not in my bin folder.

prombo (author)2015-03-03

Great project! It helped me learn how to use a webam with Edison. For my printer, though, I use Octopi - https://github.com/guysoft/OctoPi

About This Instructable

37,717views

53favorites

License:

Bio: I am a nerd. I enjoy building robots, programming, and 3D printing/designing. I am on a FIRST Tech Challenge team, team 4433 Smokin' Motors ... More »
More by Frowney001:Intro to Intel XDK IoT Edition using a Temperature Display"Factory" Reset your Intel Edison/Troubleshooting Connection ProblemsIntel Edison IP Webcam
Add instructable to: