Rasp Pi as web cam server

Anything to do with the Raspberry Pi
fryslan76
Posts: 290
Joined: Dec 18th, 2012, 4:52 pm
Location: Netherlands

Re: Rasp Pi as web cam server

Post by fryslan76 »

Hi Moki,

Which version of the PI are you using? Because the A version is a bit to limited for this is my experience. Also an important factor is the camera you are using and which output it supports. Since this determines the amount of CPU power the streamer needs to "convert" the data.

Regards,

Fryslan
User avatar
Moki
Posts: 119
Joined: Oct 21st, 2014, 2:19 am
Location: The Netherlands

Re: Rasp Pi as web cam server

Post by Moki »

I started with the B version... (and after some water damage <>< ), am now using (multiple, as in client/server setup) B+

Have tested the Raspberry Pi B+ with 4 Logitech C525 webcam streams (max 2, without USB powered hub), it slows down (40-45% CPU)... but still keeps on streaming (guess about 15 fps).
a_shorething
Posts: 289
Joined: Sep 10th, 2013, 5:26 pm
Location: New Jersey Shore

Re: Rasp Pi as web cam server

Post by a_shorething »

I can't believe I missed this post from WAAY back. I actually just got this exact webcam and was going to try streaming (because the pi cam is pretty slow).

Moki, can you help me out here? I think I got it all set up except for the index.html. Is that file supposed to exist already? If not, can I get a copy of it from somewhere else? If I try typing all of that I'm sure to fudge it up.

(also, I added 'sudo' to the beginning of a few commands here, my default permissions wouldn't work for it, so I wanted to let anyone reading this in the future they may have to add that.
Moki wrote:Just build a new PI, with 2 Logitech C525 webcams.

This is how I did it:

Code: Select all

sudo apt-get install libjpeg62-dev
sudo apt-get install cmake
sudo apt-get install apache2
sudo apt-get install subversion

git clone https://github.com/jacksonliam/mjpg-streamer.git

cd mjpg-streamer/
cd mjpg-streamer-experimental/

make
make install

cd\
sudo cp /usr/local/www/javascript_simple.html /var/www

export LD_LIBRARY_PATH=/usr/local/lib
mjpg_streamer -b -i "input_uvc.so -n -f 25 -r 640x480 -d /dev/video0" -o "output_http.so -n -w /var/www -p 8080"
mjpg_streamer -b -i "input_uvc.so -n -f 25 -r 640x480 -d /dev/video1" -o "output_http.so -n -w /var/www -p 8081"
This is where I got lost... Is this file supposed to exist already? This is a lot to type in, and I'm likely to mess it up. Can I copy it from somewhere else and update?

Is this code and set of instructions still accurate? Would you do it differently today now that you've been doing this for a while?

edit /var/www/index.html (Replace <PI_IP_ADRESS> with your Pi's IP.)

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <title>Moki ROV</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet" href="style.css" type="text/css" />
    <!--[if IE 6]>
    <link rel="stylesheet" href="fix.css" type="text/css" />
    <![endif]-->
  </head>

  <body>
<iframe frameborder="0" scrolling="no" width="640" height="480"
   src="http://<PI_IP_ADRESS>:8080/javascript_simple.html" name="imgbox" id="imgbox">
   <p>iframes are not supported by your browser.</p>
</iframe>
<iframe frameborder="0" scrolling="no" width="640" height="480"
   src="http://<PI_IP_ADRESS>:8081/javascript_simple.html" name="imgbox" id="imgbox">
   <p>iframes are not supported by your browser.</p>
</iframe>

  </body>
</html>
Open your webbrowser, go to: http://<PI_IP_ADRESS>
User avatar
Moki
Posts: 119
Joined: Oct 21st, 2014, 2:19 am
Location: The Netherlands

Re: Rasp Pi as web cam server

Post by Moki »

Wait... What....
You are typing the code, instead of copy/paste?

You may want to find a terminal program, like "putty". And start using that <><

And i wouldn't change it, there is no need. All it does, is put the webcam stream into an iframe
perfo
Posts: 151
Joined: Jan 27th, 2015, 12:05 am

Re: Rasp Pi as web cam server

Post by perfo »

I used a Pi Cam with the PI a year or so ago and streamed that to a VLC front end. It can't have been that difficult as I did it :)

Using the PI cam rather than a USB cam seemed to get much better resolution and frame rates for less CPU.
I can try and remember what I did if you need me too ?
fryslan76
Posts: 290
Joined: Dec 18th, 2012, 4:52 pm
Location: Netherlands

Re: Rasp Pi as web cam server

Post by fryslan76 »

There is a package for the pi cam in combination with uv4l which also has the option for a webserver. No hassle to install and almost no CPU usage.
http://www.linux-projects.org/modules/s ... e&artid=15 the man page of the business stuff.
a_shorething
Posts: 289
Joined: Sep 10th, 2013, 5:26 pm
Location: New Jersey Shore

Re: Rasp Pi as web cam server

Post by a_shorething »

Moki wrote:Wait... What....
You are typing the code, instead of copy/paste?

You may want to find a terminal program, like "putty". And start using that <><

And i wouldn't change it, there is no need. All it does, is put the webcam stream into an iframe
I'm using putty, but forgot there was a 'front end' on Raspberry Pi. :) (usually boot to command prompt).

Thanks, I'll check it out.
a_shorething
Posts: 289
Joined: Sep 10th, 2013, 5:26 pm
Location: New Jersey Shore

Re: Rasp Pi as web cam server

Post by a_shorething »

perfo wrote:I used a Pi Cam with the PI a year or so ago and streamed that to a VLC front end. It can't have been that difficult as I did it :)

Using the PI cam rather than a USB cam seemed to get much better resolution and frame rates for less CPU.
I can try and remember what I did if you need me too ?
That would be cool. My first preference would be to use the pi cam, but the setup I'm using has a noticable lag and I want to use it to navigate so I was thinking USB (and low res) for navigation and then activate the pi cam to record to the SD card when there is something record.
fryslan76 wrote:There is a package for the pi cam in combination with uv4l which also has the option for a webserver. No hassle to install and almost no CPU usage.
http://www.linux-projects.org/modules/s ... e&artid=15 the man page of the business stuff.
Thanks, I'll check that out too!
perfo
Posts: 151
Joined: Jan 27th, 2015, 12:05 am

Re: Rasp Pi as web cam server

Post by perfo »

There was a lag with the PI cam but it was pretty minuscule. If you waved your hand in front of it you may just notice the screen is behind a little but I seem to remember it was pretty good...
a_shorething
Posts: 289
Joined: Sep 10th, 2013, 5:26 pm
Location: New Jersey Shore

Re: Rasp Pi as web cam server

Post by a_shorething »

Moki wrote:Wait... What....
You are typing the code, instead of copy/paste?

You may want to find a terminal program, like "putty". And start using that <><

And i wouldn't change it, there is no need. All it does, is put the webcam stream into an iframe
I'm sorry, can you help out a Raspinoob (as opposed to user of NOOB on Raspberry Pi).

How would I go about getting that file onto my Pi.

When I use Putty to log into my Pi, it's in the command prompt and I don't use the GUI at all (and don't know how to start it).
Post Reply