elohab
Posts: 6
Joined: Sat Apr 12, 2014 1:18 am

Re: RPi Cam Web Interface

Fri Apr 25, 2014 10:45 am

Hi,
I am using web interface with my Pi Noir camera but i could not manage to record videos at the same exposure with the web
preview. Startup exposure setting is night and looking good at the web preview but when i start recording exposure setting
changes and records at that exposure. The video looks very dark in that way. Also exposure mode does not come back to
night after i stop the recording. So interface users, can you please share with me the results whether exposure mode changes
when you start recording? Thanks.

jarrah31
Posts: 125
Joined: Wed Oct 10, 2012 10:16 am

Re: RPi Cam Web Interface

Fri Apr 25, 2014 10:57 am

jarrah31 wrote:
elohab wrote:Hi,
I am using web interface with my Pi Noir camera but i could not manage to record videos at the same exposure with the web
preview. Startup exposure setting is night and looking good at the web preview but when i start recording exposure setting
changes and records at that exposure. The video looks very dark in that way. Also exposure mode does not come back to
night after i stop the recording. So interface users, can you please share with me the results whether exposure mode changes
when you strart recording? Thanks.
I'll try this tonight and let you know.
I've noticed that the exposure definitely becomes darker after pressing record, but for me when I stop it goes back to Night mode and looks ok again...

jarrah31
Posts: 125
Joined: Wed Oct 10, 2012 10:16 am

Re: RPi Cam Web Interface

Fri Apr 25, 2014 11:10 am

B0SC0 wrote:jarrah31,

Yes, I installed and it ran with no errors.


:?
Ok let's try something without the website buttons.

Looking at the code Silvan wrote, I've figured out that we can manually pass servo positions to /var/www/FIFO_pipan as this is what the webpage does.

Try running the following to see if it moves pipan. If it doesn't then there's some issue with the way pipan.js interacts with pipan.php.

Code: Select all

echo 'servo 150 150' > /var/www/FIFO_pipan
For me, this command moves my pipan to the 150 x 150 position. Changing to 150 160 for example alters the camera tilt.

The next stage is to try passing commands into pipan.php via a browser, which in turn then sends the values to FIFO_pipan.

Code: Select all

http://<ip address>/pipan.php?pan=130&tilt=130
Do either of these methods work for you?

elohab
Posts: 6
Joined: Sat Apr 12, 2014 1:18 am

Re: RPi Cam Web Interface

Fri Apr 25, 2014 1:34 pm

jarrah31 wrote:
jarrah31 wrote:
elohab wrote:Hi,
I am using web interface with my Pi Noir camera but i could not manage to record videos at the same exposure with the web
preview. Startup exposure setting is night and looking good at the web preview but when i start recording exposure setting
changes and records at that exposure. The video looks very dark in that way. Also exposure mode does not come back to
night after i stop the recording. So interface users, can you please share with me the results whether exposure mode changes
when you strart recording? Thanks.
I'll try this tonight and let you know.
I've noticed that the exposure definitely becomes darker after pressing record, but for me when I stop it goes back to Night mode and looks ok again...
Thanks jarrah31 for your reply. I think raspimjpeg doesn't read config file /etc/raspimjpeg completely while recording video or something like that. Strangely i can record images at the same exposure with the preview. This is an issue silvanmelchior must look into.

idahospud
Posts: 4
Joined: Fri Apr 18, 2014 8:51 pm

Re: RPi Cam Web Interface

Fri Apr 25, 2014 1:49 pm

I do not wish to intrude on the conversation, but I am having the same problem controlling the pip an servos. When I do as you suggest, the camera servos do not move.
Neither "echo 'servo 150 150' > /var/www/FIFO_pipan" nor "http://<ip address>/pipan.php?pan=130&tilt=130" move the camera position.

I can move the position with this python program adapted from the samples that came with Pi Pan.

import time
import os, sys
import pipan
import sys


print "pan/tilt control"
print pipan.__file__

p = pipan.PiPan()

p.neutral_pan()
p.neutral_tilt()

x = 148
y = 140
p.do_tilt (int(y))
p.do_pan (int(x))

while True:
try:
x += int(raw_input ("Negative moves right---Enter + or - x"))
except ValueError:
print "Please enter a valid number "
continue

try:
y += int(raw_input ("Negative moves higher---Enter + or - y: "))
except ValueError:
print "Not valid number "

print "Using: x = ", x, "y = ", y

if int(x) > 0 and int(x) < 200:
p.do_pan (int(x))
if int(y) > 0 and int(y) <220:
p.do_tilt (int(y))

idahospud
Posts: 4
Joined: Fri Apr 18, 2014 8:51 pm

Re: RPi Cam Web Interface

Fri Apr 25, 2014 1:55 pm

Oops, I missed the last line of my python program:
# Control the camera position
#

import time
import os, sys
import pipan
import sys


print "pan/tilt control"
print pipan.__file__

p = pipan.PiPan()

p.neutral_pan()
p.neutral_tilt()

x = 148
y = 140
p.do_tilt (int(y))
p.do_pan (int(x))

while True:
try:
x += int(raw_input ("Negative moves right---Enter + or - x"))
except ValueError:
print "Please enter a valid number "
continue

try:
y += int(raw_input ("Negative moves higher---Enter + or - y: "))
except ValueError:
print "Not valid number "

print "Using: x = ", x, "y = ", y

if int(x) > 0 and int(x) < 200:
p.do_pan (int(x))
if int(y) > 0 and int(y) <220:
p.do_tilt (int(y))

B0SC0
Posts: 22
Joined: Tue Jun 04, 2013 3:46 pm

Re: RPi Cam Web Interface

Fri Apr 25, 2014 7:08 pm

jarrah31 wrote:
B0SC0 wrote:jarrah31,

:?
Ok let's try something without the website buttons.

Do either of these methods work for you?
The first method worked.

The second did not. Just takes me to a blank page.( without the<>)(with <>) says server not found.

Maeffjus
Posts: 4
Joined: Thu Jan 17, 2013 7:56 pm

Re: RPi Cam Web Interface

Sat Apr 26, 2014 12:39 am

Great piece of software!
There is only one thing what would make it really perfect for me - no honestly tree things:

1. The option to save the images elswhere, as the PI has a very limitied amount of space, it would be totaly perfect to save the pictures on a network share. As I use a Windows server, it would be great to have some point where you put in the UNC path and some credentials.
2. Save the settings after a reboot. As the PI might experiences some power-outage and reboots immediately, it would be great that if I flip the picture (what is necessary for me) and start timelapse mode, this would continue after a power-break.
3. A timer-based timelapse (huh?) Quite easy, my plan is to record images outside of my house and line them up in a nice timelapse - so I can see how plants grow, snow falls, whatever happens... But as I do it outside in "nature", there is more or less no artificial light source. And I really don't want to install one. But it doesn't make any sense to take pictures at night. So for this I'd really like to give it a start and stop time (morning - evening) when it starts timelapsing and stops it.

I would even pay some bucks for someone who can code this for me - I'm really a noob and I'm pretty good with MS Windows Server environments - but not with any kind of coding - and linux is also on the outer edge of my knowledge.

Regards,
Maeffjus

jarrah31
Posts: 125
Joined: Wed Oct 10, 2012 10:16 am

Re: RPi Cam Web Interface

Sat Apr 26, 2014 9:31 am

idahospud wrote:I do not wish to intrude on the conversation, but I am having the same problem controlling the pip an servos. When I do as you suggest, the camera servos do not move.
Neither "echo 'servo 150 150' > /var/www/FIFO_pipan" nor "http://<ip address>/pipan.php?pan=130&tilt=130" move the camera position.
In this case there might be something wrong with the file FIFO_pipan. Can you check the permissions and ownership are the same as this below?

Code: Select all

$ ls -al /var/www/FIFO_pipan
prw-rw-rw- 1 root root 0 Apr 26 09:23 FIFO_pipan
If it's not the same, delete it and recreate the file:

Code: Select all

sudo rm /var/www/FIFO_pipan p
sudo mknod /var/www/FIFO_pipan p
sudo chmod 666 /var/www/FIFO_pipan
And then try this command again:

Code: Select all

echo 'servo 150 150' > /var/www/FIFO_pipan

jarrah31
Posts: 125
Joined: Wed Oct 10, 2012 10:16 am

Re: RPi Cam Web Interface

Sat Apr 26, 2014 9:49 am

B0SC0 wrote: The first method worked.

The second did not. Just takes me to a blank page.( without the<>)(with <>) says server not found.
Hmm, to check php is working, do you have any issues if you click the "Download Videos and Images" link?
If ok with that then double check the pipan.php file looks the same as below. Also check if there's any extra carriage returns after each line as I've seen hidden formatting issues occur when copying code from a web page in the past.
One way to be sure is copy the contents of pipan.php to notepad first, then copy from notepad into the text editor on your pi.

Code: Select all

[email protected] /var/www $ ls -al /var/www/pipan.php
-rw-r--r-- 1 www-data www-data 854 Apr 21 19:38 /var/www/pipan.php
[email protected] /var/www $ cat /var/www/pipan.php
<?php

  //
  // settings
  //
  $min_pan = 60;
  $max_pan = 190;
  $min_tilt = 120;
  $max_tilt = 220;


  //
  // code
  //
  if(isset($_GET["pan"])) {
    if(is_numeric($_GET["pan"])) {
      if(is_numeric($_GET["tilt"])) {
        $pan = round($min_pan + (($max_pan - $min_pan)/200*$_GET["pan"]));
        $tilt = round($min_tilt + (($max_tilt - $min_tilt)/200*$_GET["tilt"]));
        $pipe = fopen("FIFO_pipan","w");
        fwrite($pipe, "servo $pan $tilt ");
        fclose($pipe);
      }
    }
  }

  if(isset($_GET["red"])) {
    if(is_numeric($_GET["red"])) {
      if(is_numeric($_GET["green"])) {
        if(is_numeric($_GET["blue"])) {
          $pipe = fopen("FIFO_pipan","w");
          fwrite($pipe, "led " . $_GET["red"] . " " . $_GET["green"] . " " . $_GET["blue"] . " ");
          fclose($pipe);
        }
      }
    }
  }

?>
If it still doesn't work then I'm not quite sure what else it could be. FIFO_pipan is working which is promising, it's just the link between pipan.php and the FIFO pipe.
Basically pipan.php just sends the pan and tilt values it receives via a URL to FIFO using these two lines:

Code: Select all

$pipe = fopen("FIFO_pipan","w");
        fwrite($pipe, "servo $pan $tilt ");
Which is similar to the manual echo command:

Code: Select all

echo 'servo 150 150' > /var/www/FIFO_pipan
URL example:

Code: Select all

http://192.168.0.5/pipan.php?pan=130&tilt=130

jarrah31
Posts: 125
Joined: Wed Oct 10, 2012 10:16 am

Re: RPi Cam Web Interface

Sat Apr 26, 2014 9:55 am

Maeffjus wrote:Great piece of software!
There is only one thing what would make it really perfect for me - no honestly tree things:

1. The option to save the images elswhere, as the PI has a very limitied amount of space, it would be totaly perfect to save the pictures on a network share. As I use a Windows server, it would be great to have some point where you put in the UNC path and some credentials.
2. Save the settings after a reboot. As the PI might experiences some power-outage and reboots immediately, it would be great that if I flip the picture (what is necessary for me) and start timelapse mode, this would continue after a power-break.
3. A timer-based timelapse (huh?) Quite easy, my plan is to record images outside of my house and line them up in a nice timelapse - so I can see how plants grow, snow falls, whatever happens... But as I do it outside in "nature", there is more or less no artificial light source. And I really don't want to install one. But it doesn't make any sense to take pictures at night. So for this I'd really like to give it a start and stop time (morning - evening) when it starts timelapsing and stops it.

I would even pay some bucks for someone who can code this for me - I'm really a noob and I'm pretty good with MS Windows Server environments - but not with any kind of coding - and linux is also on the outer edge of my knowledge.

Regards,
Maeffjus
1. You can map a network share to /var/www/media using the guides found here: http://elinux.org/RPi-Cam-Web-Interface ... her_folder
2. You should be able to use the config file (/etc/raspimjpeg) to make reboot persistent changes. See http://elinux.org/RPi-Cam-Web-Interface#The_Config_File. However I can't see a way to make time-lapse continue after a reboot in the config file though...
3. Yes this would be handy, unfortunately I don't have the programming skills to make a schedule either.

kaiser03
Posts: 4
Joined: Sat Apr 26, 2014 5:08 am

Re: RPi Cam Web Interface

Sat Apr 26, 2014 4:29 pm

Hello, I am new to this forum and new to the Rasberry pi.
I followed your great guide and was able to set up the RPI webcam and used port forwarding to remote access the cam outside my home network.
However, I have come across a few issues:
1. I followed the instruction to create a .htaccess file and entered a username and password. However, the username and password option does not show up when accessing the website remotely - for example through my smartphone on LTE.

2. The RPI Cam interface randomly freezes at times - I typically have to reboot the PI and restart the browser to get it to work again.

Any help appreciated.

RK

Maeffjus
Posts: 4
Joined: Thu Jan 17, 2013 7:56 pm

Re: RPi Cam Web Interface

Sat Apr 26, 2014 5:59 pm

Would it not be possible to use the system clock for doing this, so just, if the time you entered is on right now, it takes pictures?
Thanks for your help anyway!

kaiser03
Posts: 4
Joined: Sat Apr 26, 2014 5:08 am

Re: RPi Cam Web Interface

Sat Apr 26, 2014 6:44 pm

Hello, thanks for this post. I followed your guide below and everything works except the security. When I remote access the RPi through a browser such as Firefox or Chrome, it does not prompt for a Username or Password.
Thanks for your help.

RK




Next to add some basic security you can use a thing called an .htaccess file:-

Create a file called .htaccess in the directory that you need to protect

For the whole website use:-

sudo nano /var/www/.htaccess

Paste the following text into nano

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /usr/local/.htpasswd
AuthGroupFile /dev/null
Require valid-user


And Save....
-----------------------------

AuthUserFile: This line designates the server path to the .htpasswd file.

AuthGroupFile: This line can be used to convey the location of the .htgroup. As we have not created such a file, we can leave /dev/null in place.

AuthName: This is text that will be displayed at the password prompt. You can put anything here.

AuthType: This refers to the type of authentication that will be used to the check the passwords. The passwords are checked via HTTP and the keyword Basic should not be changed.

Require valid-user: This line represents one of two possibilities. “Require valid-user” tells the .htaccess file that there are several people who should be able to log into the password protected area. The other option is to use the phrase “require user username” to indicate the specific permitted person.

-----------------------------

Create a .htpasswd file in the location shown in AuthUserFile

sudo htpasswd -c /usr/local/.htpasswd PiCam <PiCam is the username you can use your own>

Enter a Password when promted.

To change the password:-

sudo htpasswd /usr/local/.htpasswd PiCam

To add a new user:-

sudo htpasswd -c /usr/local/.htpasswd PiCam_New

The contents of the .htpasswd file will look something like this......

PiCam:lsjhfvldhbvkjewbvkjebvkjeb

-----------------------------

Change the default site file to enable the use of .htaccess

sudo nano /etc/apache2/sites-enabled/000-default

Look for:-

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

Change:- AllowOverride None

to:- AllowOverride All

And Save...

-----------------------------

Again, if you plan on using motion detection you will also need to alter the motion.conf file with the password details

sudo nano /etc/motion/motion.conf

Find the line:-
; netcam_userpass value

and replace with:-
netcam_userpass user:pass (username and password specified above)

Restart Apache....

sudo /etc/init.d/apache2 restart

Now when you go to the website you should be asked for a username password......

I would also google some key phrases used here so you can get a better understanding on what is being done.

B0SC0
Posts: 22
Joined: Tue Jun 04, 2013 3:46 pm

Re: RPi Cam Web Interface

Sat Apr 26, 2014 9:10 pm

One way to be sure is copy the contents of pipan.php to notepad first, then copy from notepad into the text editor on your pi.
I have edited this many times and many ways.

What finally worked was adding some blank lines not shown here and making sure it was 854 bytes.

Yay! Success. :D

Pan n' tilt works, along with everything else.

The only problem I am having now is taking photos. I can get about one or two but the next one is

0bytes and greys out all the buttons except the pan-pi buttons.

I have to do a stop and start on the RPi to get it working again.

I will look at the other files to see if I can figure things out.

I do appreciate it very much that you stuck with me to get the pan n' tilt working.

jarrah31
Posts: 125
Joined: Wed Oct 10, 2012 10:16 am

Re: RPi Cam Web Interface

Sun Apr 27, 2014 10:16 am

B0SC0 wrote:
The only problem I am having now is taking photos. I can get about one or two but the next one is

0bytes and greys out all the buttons except the pan-pi buttons.
Ah yes I had something similar - have you changed the image resolution in /etc/raspimjpeg?

Code: Select all

#
# Image Options
#
image_width 2592
image_height 1944
I tried reducing the resolution here, but it would only let me take one image with the next being 0 bytes. Returning to the default values above fixed this for me.

Glad pipan now works, odd that you had to add a few empty lines! :)

jarrah31
Posts: 125
Joined: Wed Oct 10, 2012 10:16 am

Re: RPi Cam Web Interface

Sun Apr 27, 2014 11:00 am

kaiser03 wrote: 1. I followed the instruction to create a .htaccess file and entered a username and password. However, the username and password option does not show up when accessing the website remotely - for example through my smartphone on LTE.
I can only think some part of the instructions were accidentally missed because this has worked flawlessly on 3 RPi Cam Web Interfaces that I've set up. I'm asked for a password on mobiles and all the main browsers (Chrome, IE, Firefox, Safari).

I'd suggest going through each step again (not the easiest of instructions to follow I must admit) and if it still doesn't work then I'm not sure what it could be. Maybe try installing from fresh again?

Regarding the random freezes, I have 3 cams running constantly without issue, though I don't enable motion. Could be a power issue if you're not using motion either?

0lly
Posts: 77
Joined: Sun Mar 02, 2014 5:07 pm

Re: RPi Cam Web Interface

Sun Apr 27, 2014 1:44 pm

B0SC0 wrote: The only problem I am having now is taking photos. I can get about one or two but the next one is
0bytes
I have described several times. ;)
Newer Firmware does not work anymore.
silvamelchior should fix it.
http://www.raspberrypi.org/forums/viewt ... 84#p537284

User avatar
Trixster
Posts: 261
Joined: Sat Jul 07, 2012 3:53 pm

Re: RPi Cam Web Interface

Sun Apr 27, 2014 2:09 pm

Yep, with the latest firmware the preview window is completely frozen.

B0SC0
Posts: 22
Joined: Tue Jun 04, 2013 3:46 pm

Re: RPi Cam Web Interface

Sun Apr 27, 2014 3:01 pm

Ah yes I had something similar - have you changed the image resolution in /etc/raspimjpeg?
image_width 2592
image_height 1944
jarrah31
I reviewed the raspimijpeg file, and it is already set to that.

:?
Last edited by B0SC0 on Sun Apr 27, 2014 8:34 pm, edited 1 time in total.

kaiser03
Posts: 4
Joined: Sat Apr 26, 2014 5:08 am

Re: RPi Cam Web Interface

Sun Apr 27, 2014 3:24 pm

Hi, thanks for your reply. You are right, it was a specific line - require user username. I did not enter my actual username at first. I corrected this and now works fine.

Regarding the freezes, it seems to occur under the following circumstances:
1. When I try to change the RPI Cam interface settings if the camera is off - I am unable to start the camera again through the interface and I have to do a Pi reboot for the camera to start again. If the camera is on, then I am able to change the settings without issue except for brightness - see below.
2. If I try to change the brightness settings while the camera is on, I get the following error through the website interface:
Error in RaspiMJPEG: Could not set sharpness
Restart RaspiMJPEG (./RPi_Cam_Web_Interface_Installer.sh start) or the whole RPi

Thanks.

RK
I can only think some part of the instructions were accidentally missed because this has worked flawlessly on 3 RPi Cam Web Interfaces that I've set up. I'm asked for a password on mobiles and all the main browsers (Chrome, IE, Firefox, Safari).

I'd suggest going through each step again (not the easiest of instructions to follow I must admit) and if it still doesn't work then I'm not sure what it could be. Maybe try installing from fresh again?

Regarding the random freezes, I have 3 cams running constantly without issue, though I don't enable motion. Could be a power issue if you're not using motion either?

edgedamage
Posts: 14
Joined: Sun Aug 26, 2012 12:49 am

Re: RPi Cam Web Interface

Sun Apr 27, 2014 7:22 pm

Thanks for this great software, it works great. I have one request i have mapped a USB drive and a network share to mount at start up. When running the software I will write to one of two locations:
media/BLUE
media/NASDRIVE

I have to run the command:
sudo mount --bind /media/BLUE /var/www/media
How can I get the pi to run this command automatically at start up? I added this command to the config file but it does not work.

kaiser03
Posts: 4
Joined: Sat Apr 26, 2014 5:08 am

Re: RPi Cam Web Interface

Sun Apr 27, 2014 8:08 pm

Sorry to be such a newbie, I was trying to follow these instructions but am not sure where to find the index.html file. I seem to have many of these files in various directories. Thanks.

RK


First you have to enable the www-data group to reach the shutdown command, otherwise it will not work.
Note that this will introduce a safety risk!!!

To do this type

Code: Select all

sudo visudo
in the console to open nano with the sudoers file. Then put the lines

Code: Select all

www-data ALL=/sbin/shutdown
www-data ALL=NOPASSWD: /sbin/shutdown
at the end of the file and close nano with Ctrl-X, Y and Enter.

Next create a file named 'reboot.php' in /var/www and fill it with this text:

Code: Select all

<?php
shell_exec('sudo shutdown -r now');
echo 'Pi is rebooting now!';
?>
Then paste the following code into 'index.html' to create the reboot button:

Code: Select all

<p><button type='button' id='rebootnow' onClick='window.location="reboot.php"';>Reboot</button></p>
That should do it.

robm99
Posts: 6
Joined: Sat Feb 22, 2014 1:20 am

Re: RPi Cam Web Interface

Sun Apr 27, 2014 9:50 pm

Is there any reason why rotating the image doesn't retain the same section of the image?

If I turn on the Pi, connect and set the web interface to show 4:3 Full FOV, I get one view, but if I then select "Rotation" of 90 degrees, I only see part of that view. Looks like it's cropping it to retain a landscape orientation, when really I'd like a portrait orientation of the image.

Thanks

buhbuhbuh
Posts: 1
Joined: Mon Apr 28, 2014 2:12 am

Re: RPi Cam Web Interface

Mon Apr 28, 2014 2:25 am

Hi All,

First off, thanks for making this project! It seems to work much better than any of the other solutions I've tried. I'm trying to process this video stream to control a robot, so I'm trying to use SimpleCV's built-in handling of mjpeg streams, which has a syntax that looks like this: cam = JpegStreamCamera("http://192.168.65.101:8080/videofeed") or cam = JpegStreamCamera("http://192.168.65.101:8080/video.mjpg")
Should this be able to work? If so, how should I find the correct URL for the mjpeg stream? Thanks!

Return to “Camera board”