talkeasy
Posts: 38
Joined: Sun Nov 04, 2012 10:57 pm

Re: RPi Cam Web Interface

Tue Jan 14, 2014 3:04 pm

@jbeale

Yep, that worked a treat - thanks for the suggestion.
In your case you want to send "ro 180" into the pipe at startup to set the 180 degree rotation. So I think you could add

Code: Select all

echo 'ro 180' > /var/www/FIFO
@silvanmelchior
Thanks for your excellent work on this - I have been looking for such a plug and play solution since the camera came out.
The stability does remain an issue, though. Frequent network freeze ups probably due to the other s/w I am running on the pi - namely Heyu for home automation. I am thinking it might be due to power limitation issues, but so far been unable to resolve by testing against various power adaptors.

Great stuff - thanks again!

yvonnezoe
Posts: 127
Joined: Thu Feb 14, 2013 2:10 am
Contact: Website

Re: RPi Cam Web Interface

Tue Jan 14, 2014 4:39 pm

jbeale wrote:
yvonnezoe wrote:I just wanted to ask if I have to rewrite my SD card before I try this out because I've previously installed motion and openCV (which both of them doesnt work very well for me :( ). Will all these crash when put together? Also, I will be expecting to install CherryPy server, so my web app will start when I start CherryPy. I hope to include a camera output window (from RPi camera) in the web app but I'm confused how all these can be put together to work? :cry:
You should not have to rewrite the SD card, but that is the most foolproof way to get things working. When you say motion and openCV are not working well for you, I wonder if there is some configuration wrong on your setup. At the very least I recommend un-installing whatever is not working, before installing trying out new software. You would not want two different versions of motion running at the same time, for example.
Thank you for your reply! :D Unfortunately i find it too much for me to uninstall them (and i don't recall which are the files that I modified) so I rewrite my SD card with the back up image (luckily i backed up!) and follow through the steps given in the tutorial. It works very well. :) I'm so happy! Now I am going to try to write my own web app for this. Hopefully the CherryPy web server will not clash with this? :?
Just started my Raspberry Pi journey >> http://yvonnezoe.wordpress.com

User avatar
jbeale
Posts: 3709
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: RPi Cam Web Interface

Tue Jan 14, 2014 5:03 pm

I'm not familiar with CherryPy, but in general you can run more than one webserver on the same machine. However they must use different ports. The standard webserver port is 80 and the apache2 server installed by Rpi Camera Web Interface uses that port. So you if also want to run a different webserver at the same time, you'd have to set it up on another port, for example port 8080 so your web URL might look like http://myIPaddress:8080/index.html

You can also investigate whether you can use just one webserver instead of two, to do whatever it is you want to do. That seems more efficient, but that's up to you.

HeikoG
Posts: 12
Joined: Wed Oct 16, 2013 11:53 am

Re: RPi Cam Web Interface

Tue Jan 14, 2014 6:21 pm

Take care of your Apache2 error.log:

[Tue Jan 14 17:49:17 2014] [error] [client 192.168.1.xxx] PHP Notice: Use of undefined constant Y - assumed 'Y' in /var/www/preview.php on line 38, referer: http://192.168.1.116/index.html

bigatl22
Posts: 10
Joined: Wed Jan 15, 2014 3:49 am

Re: RPi Cam Web Interface

Wed Jan 15, 2014 3:51 am

How do I change the save location. I looked in the motion.conf file but it doesn't show the default location where things are saved (/var/www/filename). Someone please help me!

User avatar
jbeale
Posts: 3709
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: RPi Cam Web Interface

Wed Jan 15, 2014 5:31 am

bigatl22 wrote:How do I change the save location. I looked in the motion.conf file but it doesn't show the default location where things are saved (/var/www/filename). Someone please help me!
In the standard install of "RPi Cam Web Interface" the 'motion' program does not directly save anything. It only triggers another program called 'raspimjpeg', by sending commands into a named pipe /var/www/FIFO and in turn that program saves stills and video as requested. The save locations of the still images '-if' and video '-vf' are passed to RaspiMJPEG on the command line when it is invoked at bootup from /etc/rc.local

Code: Select all

raspimjpeg -pa -w 512 -h 288 -d 1 -q 25 -of /dev/shm/mjpeg/cam.jpg -cf /var/www/FIFO -sf /var/www/status_mjpeg.txt -vf /var/www/media/video_%04d_%04d%02d%02d_%02d%02d%02d.mp4 -if /var/www/media/image_%04d_%04d%02d%02d_%02d%02d%02d.jpg -p -ic $image -vc $video > /dev/null &

dqpi
Posts: 33
Joined: Fri May 24, 2013 12:22 pm

Re: RPi Cam Web Interface

Wed Jan 15, 2014 1:07 pm

Installed and it is working without any problem, great work!

Is there a way I can delay the video steam I see in the web browser? (say 30 seconds?)

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: RPi Cam Web Interface

Wed Jan 15, 2014 4:44 pm

For who's interested:
I slightly changed the RPi Cam files to try and make them more phone-friendly. The idea is to use the camera with a battery and a WiFi access point on location. With the phone you can easily frame the picture. You could for instance place it somewhere and wait for animals to show up or get nearby while you're sitting at a distance so as not to disturb the animals. This is just a quick edit for starters and to see how it handles. Any ideas please let mo know.

The changes:
- Black background with white text
- Image is scaled to 100% width on phones and tablets (does not work in Chrome on Windows as yet, don't know why)
- Clicking (tapping) the image records an image

I made copies of the files and renamed them so the originals are still usable. To make it work create the following files in /var/www and copy the contents into them:

Index2.html

Code: Select all

<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
  <head>
    <title>RPi Cam Control</title>
    <link rel="stylesheet" href="rpicam.css" type="text/css" />
	<script src="script.js"></script>
  </head>
  <body onload="setTimeout('init();', 100);">
    <center>
      <div id='webcam'><img id="mjpeg_dest" onclick="send_cmd('im')"></div>
      <input id="video_button" type="button">
      <input id="image_button" type="button">
      <input id="md_button" type="button">
      <input id="halt_button" type="button">
      <p><a href="preview2.php">Download Videos and Images</a></p>
      <h2>Settings</h2>
      <table border=1 width=100%>
        <tr>
          <td>Sharpness (-100...100), default 0:</td>
          <td><input type="text" size=4 id="sharpness"><input type="button" value="OK" onclick="send_cmd('sh ' + document.getElementById('sharpness').value)"></td>
        </tr>
        <tr>
          <td>Contrast (-100...100), default 0:</td>
          <td><input type="text" size=4 id="contrast"><input type="button" value="OK" onclick="send_cmd('co ' + document.getElementById('contrast').value)"></td>
        </tr>
        <tr>
          <td>Brightness (0...100), default 50:</td>
          <td><input type="text" size=4 id="brightness"><input type="button" value="OK" onclick="send_cmd('br ' + document.getElementById('brightness').value)"></td>
        </tr>
        <tr>
          <td>Saturation (-100...100), default 0:</td>
          <td><input type="text" size=4 id="saturation"><input type="button" value="OK" onclick="send_cmd('sa ' + document.getElementById('saturation').value)"></td>
        </tr>
        <tr>
          <td>ISO (100...800), default 0:</td>
          <td><input type="text" size=4 id="iso"><input type="button" value="OK" onclick="send_cmd('is ' + document.getElementById('iso').value)"></td>
        </tr>
        <tr>
          <td>Video Stabilisation</td>
          <td><input type="button" value="ON" onclick="send_cmd('vs 1')"><input type="button" value="OFF" onclick="send_cmd('vs 0')"></td>
        </tr>
        <tr>
          <td>Exposure Compensation (-10...10), default 0:</td>
          <td><input type="text" size=4 id="comp"><input type="button" value="OK" onclick="send_cmd('ec ' + document.getElementById('comp').value)"></td>
        </tr>
        <tr>
          <td>Exposure Mode, default 'auto':</td>
          <td>
            <select onclick="send_cmd('em ' + this.value)">
              <option value="auto">Select option...</option>
              <option value="off">Off</option>
              <option value="auto">Auto</option>
              <option value="night">Night</option>
              <option value="nightpreview">Nightpreview</option>
              <option value="backlight">Backlight</option>
              <option value="spotlight">Spotlight</option>
              <option value="sports">Sports</option>
              <option value="snow">Snow</option>
              <option value="beach">Beach</option>
              <!--<option value="verylong">Verylong</option>--> <!-- crashes cam-module -->
              <option value="fixedfps">Fixedfps</option>
            </select>
          </td>
        </tr>
        <tr>
          <td>White Balance, default 'auto':</td>
          <td>
            <select onclick="send_cmd('wb ' + this.value)">
              <option value="auto">Select option...</option>
              <option value="off">Off</option>
              <option value="auto">Auto</option>
              <option value="sun">Sun</option>
              <option value="cloudy">Cloudy</option>
              <option value="shade">Shade</option>
              <option value="tungsten">Tungsten</option>
              <option value="fluorescent">Fluorescent</option>
              <option value="incandescent">Incandescent</option>
              <option value="flash">Flash</option>
              <option value="horizon">Horizon</option>
            </select>
          </td>
        </tr>
        <tr>
          <td>Rotation, default 0:</td>
          <td>
            <select onclick="send_cmd('ro ' + this.value)">
              <option value="0">Select option...</option>
              <option value="0">0</option>
              <option value="90">90</option>
              <option value="180">180</option>
              <option value="270">270</option>
            </select>
          </td>
        </tr>
        <tr>
          <td>Image quality (0...100), default 85:</td>
          <td><input type="text" size=4 id="quality"><input type="button" value="OK" onclick="send_cmd('qu ' + document.getElementById('quality').value)"></td>
        </tr>
        <tr>
          <td>Video bitrate (0...25000000), default 17000000:</td>
          <td><input type="text" size=10 id="bitrate"><input type="button" value="OK" onclick="send_cmd('bi ' + document.getElementById('bitrate').value)"></td>
        </tr>
      </table>
    </center>
  </body>
</html>
rpicam.css

Code: Select all

body
{
/* background-image:
url('bigg.gif');
*/
    background-image: url(img.jpg);
    background-position: center top;
    background-size: 100% auto;

	background-color: #000000;
	background-repeat: no-repeat;
	background-attachment: fixed;

	font-family: "Verdana";
	font-size: 8pt;
	color: #dddddd;
}
a:link {color:#dddddd;}      /* unvisited link */
a:visited {color:#dddddd;}  /* visited link */


webcam {
    max-width: 100%;
    max-height: 97%;
}
preview2.php

Code: Select all

<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
  <head>
    <title>RPi Cam Download</title>
	<link rel="stylesheet" href="rpicam.css" type="text/css" />
  </head>
  <body>
    <p><a href="index2.html">Back</a></p>
    <?php
      if(isset($_GET["delete"])) {
        unlink("media/" . $_GET["delete"]);
      }
      else if(isset($_GET["file"])) {
        echo "<h1>Preview</h1>";
        if(substr($_GET["file"], -3) == "jpg") echo "<img src='media/" . $_GET["file"] . "' width='480' height='360'>";
        else echo "<video width='640' height='360' controls><source src='media/" . $_GET["file"] . "' type='video/mp4'>Your browser does not support the video tag.</video>";
        echo "<p><input type='button' value='Download' onclick='window.open(\"download.php?file=" . $_GET["file"] . "\", \"_blank\");'> ";
        echo "<input type='button' value='Delete' onclick='window.location=\"preview2.php?delete=" . $_GET["file"] . "\";'></p>";
      }
    ?>
    <h1>Files</h1>
    <?php
      $files = scandir("media");
      if(count($files) == 2) echo "<p>No videos/images saved</p>";
      foreach($files as $file) {
        if(($file != '.') && ($file != '..'))
          echo "<p><a href='preview2.php?file=$file'>$file</a></p>";
      }
    ?>
  </body>
</html>
Last edited by poing on Sun Jan 19, 2014 11:02 am, edited 1 time in total.

charliebarnwell
Posts: 1
Joined: Wed Jan 15, 2014 4:56 pm

Re: RPi Cam Web Interface

Wed Jan 15, 2014 5:01 pm

Fantastic, works straight out of the box - I have it hooked up to my spotting scope for bird watching......Thanks :D

Maxfli
Posts: 3
Joined: Wed Jan 15, 2014 6:38 pm

Re: RPi Cam Web Interface

Wed Jan 15, 2014 7:00 pm

I am a little new to this raspberry pi thing. I have installed once on my old version of Raspbian. Followed the instructions and it didn't work. So I downloaded the latest Raspbian dated 1-7-2014. The upgrade and install was much smoother and it still is not showing video browsing the IP address. Once I login to the pi should i see the Camera red light kick on automatically. I have be able to issue a stop and start command using this:

Code: Select all

"./RPi_Cam_Browser_Control_Installer.sh start".
I get a started message back! When I browse the IP 192.168.1.230 do i need to include the Index.html in the url. (hadn't tried that). I had this camera all working using motion from a previous thread a few months ago so I am pretty sure the camera is working.
Please let me know you thoughts.
Thanks

Maxfli
Posts: 3
Joined: Wed Jan 15, 2014 6:38 pm

Re: RPi Cam Web Interface

Wed Jan 15, 2014 7:57 pm

Should I have installed per thread RaspiMJPEG as a prerequisite to this thread??

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: RPi Cam Web Interface

Wed Jan 15, 2014 9:04 pm

no

Maxfli
Posts: 3
Joined: Wed Jan 15, 2014 6:38 pm

Re: RPi Cam Web Interface

Thu Jan 16, 2014 1:07 am

Nevermind I got it going.

tbr
Posts: 23
Joined: Mon Jul 23, 2012 9:12 pm

Re: RPi Cam Web Interface

Thu Jan 16, 2014 4:00 pm

First of all thank you for this excellent piece of software, it's just what I needed.
Secondly I have a feature request, how about timelapse integration? Many moons ago I created a few timelapse movies on my pi using a usb camera and motion so I can't imagine it being too difficult to integrate into the existing webpage? (easy for a non-programmer like myself to say I know)

p.s what about dropbox integration using Dropbox Uploader? Just a thought.

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: RPi Cam Web Interface

Thu Jan 16, 2014 4:01 pm

Hmmm... Over a period of 48 hours the banding came slowly back and in the end Motion refused to work any more; somehow there's something not stable. Re-flashed the card and made a copy of it with the fresh RPi Cam Web Interface install so I can maybe check differences when things go bad again.

baptsk
Posts: 1
Joined: Sat Jan 18, 2014 5:04 am

Re: RPi Cam Web Interface

Sat Jan 18, 2014 7:14 am

Hi,really impressive project!
I'm trying to realize an "automatic" exposure switch between auto and night mode, in order to set night mode when the image is too dark and come back to auto when the image is bright enough.

I have write a little bash script (using imagemagick) which does the job but not so well :

Code: Select all

wget http://127.0.0.1/cmd_pipe.php?cmd=em%20auto #  I set the exposure on auto. I didn't get how to use the FIFO file in order to change the exposure mode (I have try "echo 'em auto' > /var/www/FIFO" without success).

sudo rm /var/www/media/image*.jpg # Remove all the images in order to have only one image to test
echo 'im' > /var/www/FIFO # take a picture

sleep 2 #Waiting for the picture

image_stat="$(convert /var/www/media/image*.jpg -colorspace hsb  -resize 1x1  txt:-)" # using imagemagick to transform the picture into a pixel and get some informations about this pixel

tx_lum="$(echo "$image_stat" | tail -n 1 | sed -r 's/.*hsb\([^,]+,[^,]+,([^.%]+).*$/\1/gm')" #Put the brightness value in the tx_lum variable

if [ $tx_lum -lt 5 ] #Compare the  brightness value to an arbitrary threshold
then
wget http://127.0.0.1/cmd_pipe.php?cmd=em%20night # if the brightness is lower than the treshold we switch to night exposure
fi

rm cmd_pipe.php?cmd* # removing the files generate during the script
sudo rm /var/www/media/image*.jpg

I am quite a noob in scripting (and a real noob in development generally speaking), so this script can be improved in many ways.

I have two improvement ideas :

First is it possible to use the FIFO file to set the exposure mode? (I'm sure it's a stupid question but after trying and trying I can't succeed in)

Second is it possible to get the current value of the exposure?

Thanks!

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: RPi Cam Web Interface

Sat Jan 18, 2014 4:32 pm

Two videos made through motion, the first directly after a fresh flash of the SD card and the install of RPi Cam:
http://www.youtube.com/watch?v=3RM0bsbo ... e=youtu.be

The second after two hours running, it has heavy banding while nothing changed in the mean time:
http://www.youtube.com/watch?v=Q6sJ9S41 ... e=youtu.be

User avatar
jbeale
Posts: 3709
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: RPi Cam Web Interface

Sat Jan 18, 2014 4:47 pm

poing wrote:Two videos made through motion, the first directly after a fresh flash of the SD card and the install of RPi Cam:
http://www.youtube.com/watch?v=3RM0bsbo ... e=youtu.be
The second after two hours running, it has heavy banding while nothing changed in the mean time:
http://www.youtube.com/watch?v=Q6sJ9S41 ... e=youtu.be

My theory is that you have a marginal power supply and it starts oscillating after a while, causing interference that affects the camera image. Have you tried another supply?

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: RPi Cam Web Interface

Sat Jan 18, 2014 4:59 pm

Good point, I'll try with different power when it's light again in the morning.

elronno
Posts: 11
Joined: Sat Nov 09, 2013 10:36 am
Location: Europe
Contact: Website

Re: RPi Cam Web Interface

Sat Jan 18, 2014 8:36 pm

@poing: the contents of the index2.html are missing. The code shown is for the download page.

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: RPi Cam Web Interface

Sat Jan 18, 2014 9:29 pm

elronno wrote:@poing: the contents of the index2.html are missing. The code shown is for the download page.
Ooops, and I re flashed the card so the file is gone, no backup. But I can easily redo it. Hang on...

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: RPi Cam Web Interface

Sun Jan 19, 2014 11:03 am

I redid index2.html and repaired the code above, so it should work now. Also simplified it a bit so 'script2.js' is not longer necessary. And... I made a backup :oops:

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: RPi Cam Web Interface

Mon Jan 20, 2014 11:53 am

I tested with a battery that has a 2A output and the result was the same. Then a changed to a model A with the same power supply as before, same camera, same SD card and all is well 18 hours later. So it's definitely my model B that has issues. Strange, because I used it since the camera board came out with no troubles.

GarethD
Posts: 21
Joined: Wed Aug 15, 2012 8:58 pm

Re: RPi Cam Web Interface

Mon Jan 20, 2014 2:44 pm

Check your CPU temp, I have my pi and camera in a dummy camera box that's not well ventillated and have noticed high CPU temperatures only since the v4l2 driver became available.

Phenom55
Posts: 43
Joined: Fri Jan 03, 2014 2:54 pm

Re: RPi Cam Web Interface

Mon Jan 20, 2014 3:22 pm

Sorry if I missed it, but can this be used for live streaming to a smartphone?

Return to “Camera board”