Intel Edison IP Webcam

About: 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 from Pennsylvania. We won 4 out of 7 competitions within the pas...

Intro: 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

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

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

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!

Share

Recommendations

  • Tiny Home Contest

    Tiny Home Contest
  • Audio Contest 2018

    Audio Contest 2018
  • Fix It! Contest

    Fix It! Contest

10 Discussions

0
None
DhanyaN4

12 months ago

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

install ffmpeg.png
0
None
ValeG1

1 year ago

Hello, I hope you can help.

how you could get the video ip in opencv?

0
None
BenjaminC65

2 years ago

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!

0
None
kyubot

2 years ago

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

0
None
TjY1

2 years ago

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

0
None
DhruvK

3 years ago on Step 2

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

1 reply
0
None
DangerousTimDhruvK

Reply 3 years ago on Introduction

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

0
None
kc.goh.71

3 years ago on Introduction

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

0
None
lukerrs

3 years ago on Step 2

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

0
None
prombo

3 years ago on Introduction

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