Pangu
Posts: 78
Joined: Tue Dec 18, 2012 5:30 pm

Re: RPi Cam Web Interface

Wed Aug 17, 2016 7:08 pm

information for the webmaster:

the Wiki seems to have a broken link for the PDF download

Cheers

noxx
Posts: 17
Joined: Fri Oct 25, 2013 8:13 pm

Re: RPi Cam Web Interface

Wed Aug 17, 2016 8:55 pm

hello

what are good values for internal motion detection?

i use
Noise Level 1050
Threshold 1050
Still frames to stop 600

in the annotion settings i added [%c/%f]

if a person are in the camera area, RPi Cam Web Interface start a record (if value Noise Level = %c).
at the same time %f starts a countdown and if %f = the value of Threshold the record stops :-(

i want:
# if a person is in the camera area and the noise level (%c) goes high over 1050,RPi Cam Web Interface should start a record
# when 5 seconds has not changed in the picture, then only the recording should be stopped

quavoce
Posts: 109
Joined: Fri Nov 27, 2015 9:11 am

Re: RPi Cam Web Interface

Thu Aug 18, 2016 7:58 am

noxx wrote:hello

what are good values for internal motion detection?

i use
Noise Level 1050
Threshold 1050
Still frames to stop 600

in the annotion settings i added [%c/%f]

if a person are in the camera area, RPi Cam Web Interface start a record (if value Noise Level = %c).
at the same time %f starts a countdown and if %f = the value of Threshold the record stops :-(

i want:
# if a person is in the camera area and the noise level (%c) goes high over 1050,RPi Cam Web Interface should start a record
# when 5 seconds has not changed in the picture, then only the recording should be stopped
I found this paragraph from the wiki helped me understand what the values do and how to tweak them:
You can see what is going on with internal motion detection by including %c and %f in the annotation string (the date/time info bar at the top of the image). %c will show the filtered changes occurring by frames. When this is above the 'threshold' value then the change frame counter increments (%f) and when this exceeds the start frame count then a capture is triggered. Lower the value of the threshold to increase the sensitivity to small changes.
To be honest though, I could do with someone explaining how the Noise value works in laymans terms please (using Internal motion). At the moment I've left noise at 1050 and just lowered the threshold to 50 because the %c and %f values helped me work out what to set this to.

btidey
Posts: 1635
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Thu Aug 18, 2016 9:25 am

Pangu wrote:information for the webmaster:

the Wiki seems to have a broken link for the PDF download

Cheers
Not so much broken as non-existent. There used to be a separate PDF user doc (with the link) but I moved all the material into the wiki to make it easier to update just one item.

I have removed the link now. If anybody wants a standalone pdf then you can 'print' the wiki and use a pdf printer to generate a doc.

btidey
Posts: 1635
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Thu Aug 18, 2016 9:37 am

quavoce wrote:
To be honest though, I could do with someone explaining how the Noise value works in laymans terms please (using Internal motion). At the moment I've left noise at 1050 and just lowered the threshold to 50 because the %c and %f values helped me work out what to set this to.
When noise level is 1000 or above it kicks in a different algorithm. Firstly a simple 2d filter is applied to the vector changes so that isolated single vector block changes are removed. The 'noise' level then controls a temporal moving filter average to the vector changes found. 999 is subtracted from the noise level and this gives the frame averaging factor.

Moving_Average_n+1 = Moving_Average_n * (Factor - 1) / Factor + Changes_n+1 / Factor

So if Noise = 1000 then Factor = 1 and effectively no averaging is done as the previous average is ignored. If Noise = 1009 then Factor = 10 and 90% comes from the current average and only 10% from new changes. High Noise factors then give 'smoother' changes and make it less susceptible to false triggering but also mean that changes need to be sustained for longer before a trigger occurs.

1050 is pretty high for the filtering. The default is 1010.

btidey
Posts: 1635
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Thu Aug 18, 2016 10:50 am

Pangu wrote:(1) Is there any way to have the "UPTIME" displayed on the Web Cam Interface?

(2) Is it possible to create an additional user for webserver auth that have only pre-defined privileges? I would like to create additional users and define something like:

User Alice should be allowed only to view the live preview
User Bob should be allowed to view the live preview and to browse the recorded media (read-only)
User Charlie should be allowed to view the live preview, browse recorded media (r+w) but should not be able to change camera/motion/scheduler settings.
1) You can use the user annotation variable %a to put any other info in the annotation. The info is picked up from /dev/shm/mjpeg/user_annotate.txt each time the annotation is generated. So use a CRON job or something similar to update this file with a string representing UPTIME.

2) This is not possible with the current software and as quavoce says it needs the pages to be protected by a password management system rather than the current Apache site protection. It would be a nice enhancement but it is a fair bit of work which I won't be able to look at for a bit. If anybody wants to do something and make a pull request that could speed things up.

dennyfmn
Posts: 33
Joined: Thu Aug 16, 2012 1:36 pm
Location: Minnesota/California USA

Re: RPi Cam Web Interface

Thu Aug 18, 2016 8:28 pm

Time Lapse Failures - More Information

Please see posting
viewtopic.php?p=1019461#p1019461

for previous testing on a B+.

I have done additional testing with a Raspberri Pi 3 and Rpi Web Cam Interface, version 6.2.16 . The image files were written to either a remote SMB share, or a local USB drive bound to the /var/www/html/media directory. The faster system fails much more quickly than the B+ did. I forgot to mention in my last post that when it errs, it throws an error like this on the ssh session:

*** Error in `raspimjpeg': double free or corruption (fasttop): 0x0038d5c0 ***

Logging the state of status_mjpeg.txt shows in each case that the status gets stuck on "image" for about 85 seconds, then goes to "ready" and timelape stops.

Notice there are always a couple of high order characters in the scheduleLog.txt line that says:
Image capture timed out

Hardware:
Model: Pi 3 Model B - 1.2GHz Quad Core 1GB
Version: 8.0 Jessie

Kernel: Linux mypi-30 4.4.13-v7+ #894 SMP Mon Jun 13 13:13:27 BST 2016 armv7l GNU/Linux

cat uconfig

rotation 180
image_width 1024
image_height 768
tl_interval 20

run 1 - interval 2 sec, images to network share
stopped after 407 frames
*** Error in `raspimjpeg': double free or corruption (fasttop): 0x0038d5c0 ***
From scheduleLog.txt
{2016/08/16 15:38:35} Capturing image
{2016/08/16 15:38:37} Capturing image
{2016/08/16 15:39:58} Image capture timed out P<D5>8
{2016/08/16 15:40:03} RaspiMJPEG Version 5.6.5

run 2 - interval 2 sec, images to network share
stopped after 2010 frames
*** Error in `raspimjpeg': double free or corruption (fasttop): 0x0038aa80 ***
From scheduleLog.txt
{2016/08/17 11:09:30} Capturing image
{2016/08/17 11:09:32} Capturing image
{2016/08/17 11:10:53} Image capture timed out ¦8
{2016/08/17 11:10:58} RaspiMJPEG Version 5.6.5

run 3 - interval 2 sec, images to network share
stopped after 368 frames
*** Error in `raspimjpeg': double free or corruption (fasttop): 0x0038be20 ***
From scheduleLog.txt
{2016/08/17 13:03:02} Capturing image
{2016/08/17 13:03:04} Capturing image
{2016/08/17 13:04:26} Image capture timed out <B0><BD>8
{2016/08/17 13:04:31} RaspiMJPEG Version 5.6.5

run 4 - interval 4 sec, images to network share
stopped after 420 frames
*** Error in `raspimjpeg': double free or corruption (fasttop): 0x011fb360 ***
From scheduleLog.txt
{2016/08/17 13:54:28} Capturing image
{2016/08/17 13:54:32} Capturing image
{2016/08/17 13:55:52} Image capture timed out <F0><B2>^_^A/www/html/media/tl_0007_0420_20160817_135432.jpg
{2016/08/17 13:55:57} RaspiMJPEG Version 5.6.5

run 5 - interval 4 sec, images to local USB drive
stopped after 10 frames
*** Error in `raspimjpeg': double free or corruption (fasttop): 0x011f6f10 ***
From scheduleLog.txt
{2016/08/18 12:42:45} Capturing image
{2016/08/18 12:42:49} Capturing image
{2016/08/18 12:44:10} Image capture timed out ¦n/www/html/media/tl_0009_0010_20160818_124249.jpg
{2016/08/18 12:44:15} RaspiMJPEG Version 5.6.5

run 6 - interval 4 sec, images to local USB drive
stopped after 87 frames
*** Error in `raspimjpeg': double free or corruption (fasttop): 0x011f8e58 ***
{2016/08/18 13:51:21} Capturing image
{2016/08/18 13:51:25} Capturing image
{2016/08/18 13:52:45} Image capture timed out ¦/www/html/media/tl_0011_0087_20160818_135125.jpg
{2016/08/18 13:52:50} RaspiMJPEG Version 5.6.5

Hopefully this will help to figure out what's going on here and fix it.

Any help will be greatly appreciated.

Thanks,

Denny

quavoce
Posts: 109
Joined: Fri Nov 27, 2015 9:11 am

Re: RPi Cam Web Interface

Thu Aug 18, 2016 8:31 pm

btidey wrote:
quavoce wrote:
To be honest though, I could do with someone explaining how the Noise value works in laymans terms please (using Internal motion). At the moment I've left noise at 1050 and just lowered the threshold to 50 because the %c and %f values helped me work out what to set this to.
When noise level is 1000 or above it kicks in a different algorithm. Firstly a simple 2d filter is applied to the vector changes so that isolated single vector block changes are removed. The 'noise' level then controls a temporal moving filter average to the vector changes found. 999 is subtracted from the noise level and this gives the frame averaging factor.

Moving_Average_n+1 = Moving_Average_n * (Factor - 1) / Factor + Changes_n+1 / Factor

So if Noise = 1000 then Factor = 1 and effectively no averaging is done as the previous average is ignored. If Noise = 1009 then Factor = 10 and 90% comes from the current average and only 10% from new changes. High Noise factors then give 'smoother' changes and make it less susceptible to false triggering but also mean that changes need to be sustained for longer before a trigger occurs.

1050 is pretty high for the filtering. The default is 1010.
Thank you very much Robert, that definitely makes more sense! Sorry about the 1050 typo - mine is set to 1010 but must have gotten muddled with the threshold which is set to 50. :)

btidey
Posts: 1635
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Thu Aug 18, 2016 9:07 pm

dennyfmn wrote:Time Lapse Failures - More Information


Hopefully this will help to figure out what's going on here and fix it.

Any help will be greatly appreciated.

Thanks,

Denny
Replied on the new thread on this issue.

edmun
Posts: 39
Joined: Thu Jan 09, 2014 11:37 am

Re: RPi Cam Web Interface

Fri Aug 19, 2016 9:40 am

Hi Guys

I have opened my own topic, but haven't really received any reply.

I have two questions about RPi Cam Web Interface.

a) why after PI reboots, the scheduler does not start automatically the motion?
At the end, I have left it on "SunBased" schedule, but it seems that if I will restart RaspberryPi, the RPICam won't automatically start the motion until next period starts (which means - next day).

b) I am constantly trying to achieve an e-mail notification with a thumbnail being sent as an attachment
Image
I have tried with following command (designed by myself... so lame..):

Code: Select all

currentdate=$(date +%Y%m%d) && sendemail -f [email protected] -t [email protected] -u test2 -m attachment -a /var/www/cctv/media/vi_00??_$currentdate_??????.mp4.v????.th.jpg
But "??" are not really masking the numbers/symbols.

Anyone could help me with those issues and suggest how can I attach a correct file to an e-mail?

btidey
Posts: 1635
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Fri Aug 19, 2016 10:10 am

edmun wrote:Hi Guys

I have opened my own topic, but haven't really received any reply.

I have two questions about RPi Cam Web Interface.

a) why after PI reboots, the scheduler does not start automatically the motion?
At the end, I have left it on "SunBased" schedule, but it seems that if I will restart RaspberryPi, the RPICam won't automatically start the motion until next period starts (which means - next day).

b) I am constantly trying to achieve an e-mail notification with a thumbnail being sent as an attachment
I have tried with following command (designed by myself... so lame..):

Code: Select all

currentdate=$(date +%Y%m%d) && sendemail -f [email protected] -t [email protected] -u test2 -m attachment -a /var/www/cctv/media/vi_00??_$currentdate_??????.mp4.v????.th.jpg
But "??" are not really masking the numbers/symbols.

Anyone could help me with those issues and suggest how can I attach a correct file to an e-mail?
a) The scheduler can automatically start motion when it reboots. When scheduler starts up (or if the camera system is restarted) then it detects which period it is in and performs the commands configured in the period start for that period.
1) In All Day mode then there is only 1 period so any commands in period start are always sent. md 1 will therefore start motion detection
2) In Sun based or Fixed Times mode then the period start commands for the current period are sent.
Say you are in Sun based and put md 1 in Day and md 0 in Dawn, Night, Dusk. After a reboot if the time is in a day period then motion will be started, else it will wait till next day period starts.

If you want motion on all the time then put md 1 in all period starts.

If this is not working for you then look at scheduler log which will show the period detection and the commands issued.

b) If you want the email sent when a capture is done then use the job macro facilities. For example, a video capture will trigger end_vid.sh if a file of this name is in the macros folder. The file should have execute permissions and preferably be owned by www-data. Job macros are passed the capture file name so there is no need for wild cards. This name is actually the capture file so if you want the thumbnail then the script needs to convert it. E.g.

Code: Select all

#!/bin/bash
list=( $1*.th.jpg )
thumb="${list[-1]}"
$1 is the parameter passed to the script and $thumb will be the thumbnail name.

edmun
Posts: 39
Joined: Thu Jan 09, 2014 11:37 am

Re: RPi Cam Web Interface

Fri Aug 19, 2016 10:41 am

btidey wrote: If this is not working for you then look at scheduler log which will show the period detection and the commands issued.
Something isn't working :(

Please see video which I have made just a moment ago:
(I have cut the part when waiting for the reboot to finish):
https://youtu.be/eNIhqFFKHdE

After refreshing the page it's clearly visible that motion detection is stopped :/

And the log says that md 1 was send:

Code: Select all

{2016/08/19 11:35:13} RaspiMJPEG Version 5.4.2
{2016/08/19 11:35:13} recommended video buffers 1
{2016/08/19 11:35:13} h264 buffers set to recommended 1
{2016/08/19 11:35:13} MJPEG streaming, ready to receive commands
{2016/08/19 11:35:13} send smd 9
[2016/08/19 11:35:18] RaspiCam support started
[2016/08/19 11:35:18] Capture Pipe already exists /var/www/cctv/FIFO1
{2016/08/19 11:35:18} Starting command loop
[2016/08/19 11:35:18] Scheduler loop is started
[2016/08/19 11:35:18] Reload parameters command requested
[2016/08/19 11:35:18] Scheduler loop is started
[2016/08/19 11:35:19] New period detected 3
[2016/08/19 11:35:19] Send md 1
[2016/08/19 11:35:21] Send em auto
[2016/08/19 11:35:23] Scheduled management tasks. Next at 1471606519
Any ideas why it doesn't work ? :/

btidey
Posts: 1635
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Fri Aug 19, 2016 2:00 pm

edmun wrote: Something isn't working :(

After refreshing the page it's clearly visible that motion detection is stopped :/

And the log says that md 1 was send:

Code: Select all

{2016/08/19 11:35:13} RaspiMJPEG Version 5.4.2
{2016/08/19 11:35:13} recommended video buffers 1
{2016/08/19 11:35:13} h264 buffers set to recommended 1
{2016/08/19 11:35:13} MJPEG streaming, ready to receive commands
{2016/08/19 11:35:13} send smd 9
[2016/08/19 11:35:18] RaspiCam support started
[2016/08/19 11:35:18] Capture Pipe already exists /var/www/cctv/FIFO1
{2016/08/19 11:35:18} Starting command loop
[2016/08/19 11:35:18] Scheduler loop is started
[2016/08/19 11:35:18] Reload parameters command requested
[2016/08/19 11:35:18] Scheduler loop is started
[2016/08/19 11:35:19] New period detected 3
[2016/08/19 11:35:19] Send md 1
[2016/08/19 11:35:21] Send em auto
[2016/08/19 11:35:23] Scheduled management tasks. Next at 1471606519
Any ideas why it doesn't work ? :/
The log doesn't look right to me. [] are scheduler events, {} are raspimjpeg events

After starting command loop from raspimjpeg there is no activity from raspimjpeg, It should be logging commands as received on its FIFO.

Here is a snip from a log after a reboot

Code: Select all

[2016/08/19 14:42:27] Capture Pipe already exists /var/www/FIFO1
[2016/08/19 14:42:27] Scheduler loop is started
{2016/08/19 14:42:27} Opening FIFO 0 /var/www/FIFO 6
{2016/08/19 14:42:27} Opening FIFO 1 /var/www/FIFO11 7
{2016/08/19 14:42:27} Starting command loop
[2016/08/19 14:42:27] Reload parameters command requested
[2016/08/19 14:42:27] Scheduler loop is started
[2016/08/19 14:42:28] New period detected 0
[2016/08/19 14:42:28] Send md 1
{2016/08/19 14:42:28} Internal motion detection started
{2016/08/19 14:42:28} recommended video buffers 1
{2016/08/19 14:42:28} h264 buffers set to recommended 1
{2016/08/19 14:42:28} Set up internal detect width=82 height=61
Note how raspimjpeg responds to the md 1 command.

Are any commands working after a reboot? E.g. capture image button or echo -n 'im' >/var/www/cctv/FIFO from a command line?

Your raspimjpeg is version 5.4.2. Current one is 5.6.6. I would upgrade before checking further.

edmun
Posts: 39
Joined: Thu Jan 09, 2014 11:37 am

Re: RPi Cam Web Interface

Fri Aug 19, 2016 2:19 pm

That's what I was thinking about (uninstall and upgrade RPi Cam Interface).
Would raspbian - wheezy affect the interface (instead of using jessy?)
Don't know.
However I will schedule some re-install soon

update: I have uninstalled the rpi-interface and installed it again (from step 1 to step 4). all working fine now after reboot.
After weekend I will be playing with the e-mail notification with thumbnail in e-mail attachment

MoMatt
Posts: 2
Joined: Fri Aug 19, 2016 6:22 pm

Re: RPi Cam Web Interface

Fri Aug 19, 2016 6:32 pm

I am attempting to modify the RPi-Cam-Web main page (index.php) to include a couple of buttons that write to the GPIO on the Pi.

I am unable to get the page to load when I include the PHP I've written to write the GPIO. I would like it to wait until I click my button to write the GPIO, but instead as soon as I go to the main page (localhost:80) it writes the GPIO and exits the entire show.

I am using ajax in a separate .js file that is supposed to wait for my button click to write the GPIO, but instead when it gets to my PHP for the GPIO, it immediately executes it the rest of the page doesn't render.

I'm very new to JS and PHP. How can I figure out why the index.php page isn't rendering fully?

Is it possible that the JS in the RPi Cam package and my JS are interfering?

Thanks for any help!

L_i_v_e
Posts: 32
Joined: Sun Nov 29, 2015 3:51 pm

Re: RPi Cam Web Interface

Fri Aug 19, 2016 7:05 pm

Hi, i have an issue with my cam interface. As long as i change parameters, as long as i reinstall it, i still can't have a maximum quality stream, i'm stucked with low preview quality (Preview quality (1...100) Default 10:
Width (128...1024) Default 512:
Divider (1-16) Default 1:

Those value are not changing, and since i need only a good preview it's an issue, any help? Is there any file i can edit?

btidey
Posts: 1635
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Fri Aug 19, 2016 11:16 pm

L_i_v_e wrote:Hi, i have an issue with my cam interface. As long as i change parameters, as long as i reinstall it, i still can't have a maximum quality stream, i'm stucked with low preview quality (Preview quality (1...100) Default 10:
Width (128...1024) Default 512:
Divider (1-16) Default 1:

Those value are not changing, and since i need only a good preview it's an issue, any help? Is there any file i can edit?
Default settings for the preview are in /etc/raspimjpeg and you can change width, quality and divider there if you want to change the defaults.

The settings under camera settings override these and changes are stored in uconfig in the web folder. I have just changed my width OK and it took immediate effect.

If you are not seeing those values change then check the scheduler log which should record changes. If they are not changing then maybe something is wrong with permissions. Are other settings changing OK?

btidey
Posts: 1635
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Fri Aug 19, 2016 11:27 pm

MoMatt wrote:I am attempting to modify the RPi-Cam-Web main page (index.php) to include a couple of buttons that write to the GPIO on the Pi.

I am unable to get the page to load when I include the PHP I've written to write the GPIO. I would like it to wait until I click my button to write the GPIO, but instead as soon as I go to the main page (localhost:80) it writes the GPIO and exits the entire show.

I am using ajax in a separate .js file that is supposed to wait for my button click to write the GPIO, but instead when it gets to my PHP for the GPIO, it immediately executes it the rest of the page doesn't render.

I'm very new to JS and PHP. How can I figure out why the index.php page isn't rendering fully?

Is it possible that the JS in the RPi Cam package and my JS are interfering?

Thanks for any help!
There would only be conflict between the js files if you have used function names that are already used.

When developing code it is helpful to enable php error reporting at the server as then if you have coding errors then the browser will give you line numbers and errors when they occur. There is a setting to enable this. I think it is in /etc/php5/apache2/php.ini and you would need to restart apache2

I suspect it may be easier to add on to the existing js. Follow the model used for the the buttons controlling the pan/tilt controls

quavoce
Posts: 109
Joined: Fri Nov 27, 2015 9:11 am

Re: RPi Cam Web Interface

Sat Aug 20, 2016 4:37 pm

Has anyone else experienced intermitted issues with streaming recorded videos to an iPhone/iPad/Safari by any chance?

When I try to play back a video over a decent 4G mobile signal, I can never get it to play. This sometimes happens on my local network too.

Just wondering if it's my setup or not...

Thanks.

nospam
Posts: 56
Joined: Sun Jun 14, 2015 10:38 pm

Re: RPi Cam Web Interface

Sun Aug 21, 2016 12:11 am

MoMatt wrote:I am attempting to modify the RPi-Cam-Web main page (index.php) to include a couple of buttons that write to the GPIO on the Pi.

I am unable to get the page to load when I include the PHP I've written to write the GPIO. I would like it to wait until I click my button to write the GPIO, but instead as soon as I go to the main page (localhost:80) it writes the GPIO and exits the entire show.

I am using ajax in a separate .js file that is supposed to wait for my button click to write the GPIO, but instead when it gets to my PHP for the GPIO, it immediately executes it the rest of the page doesn't render.

I'm very new to JS and PHP. How can I figure out why the index.php page isn't rendering fully?

Is it possible that the JS in the RPi Cam package and my JS are interfering?

Thanks for any help!
I had the same idea to use GPIO to toggle a "PiFace Digital" relay output to operate a window defog heater and fan for one of my outdoor camera enclosures. For electrical safety the PiFace relay just provides an electrically isolated contact input to an independent fused timer relay which handles the high voltage end of things.

I added a button called "defog window" in index.php that launches sys_defog(); in script.js which sends the GPIO command "cmd_func.php?cmd=defog". I am attaching the excerpts from my code in each of the three scripts.

index.php

Code: Select all

      <div id="secondary-buttons" class="container-fluid text-center" <?php echo $displayStyle; ?> >
         <?php pan_controls(); ?>
         <a href="preview.php" class="btn btn-default">Download Videos and Images</a>
         &nbsp;&nbsp;
         <?php  if($config['motion_external']): ?><a href="motion.php" class="btn btn-default">Edit motion settings</a>&nbsp;&nbsp;<?php endif; ?>
         <a href="schedule.php" class="btn btn-default">Edit schedule settings</a>
//my code starts here
         <input id="defog window" type="button" class="btn btn-danger" value="defog window" onclick="sys_defog();">
//my code ends here
      </div>
script.js

Code: Select all

//
// Shutdown
//
function sys_shutdown() {
  ajax_status.open("GET", "cmd_func.php?cmd=shutdown", true);
  ajax_status.send();
}

function sys_reboot() {
  ajax_status.open("GET", "cmd_func.php?cmd=reboot", true);
  ajax_status.send();
}
//my code starts here
function sys_defog() {
  ajax_status.open("GET", "cmd_func.php?cmd=defog", true);
  ajax_status.send();
//my code ends here
}
cmd_func.php

Code: Select all

<?php
  define('BASE_DIR', dirname(__FILE__));
  require_once(BASE_DIR.'/config.php');

  function sys_cmd($cmd) {
    if(strncmp($cmd, "reboot", strlen("reboot")) == 0) {
      shell_exec('sudo shutdown -r now');
    } else if(strncmp($cmd, "shutdown", strlen("shutdown")) == 0) {
      shell_exec('sudo shutdown -h now');
//my code starts here
   } else if(strncmp($cmd, "defog", strlen("defog")) == 0) {
          //do stuff here to defog window using piface digital
      shell_exec('gpio -p write 200 1');
      sleep(2);
      shell_exec('gpio -p write 200 0');
//my code ends here
    } else {
      // unknown
    }
  }


  if(isset($_GET['cmd'])) {
    $cmd=$_GET['cmd'];
    sys_cmd($cmd);
  }

?>

confused85
Posts: 5
Joined: Wed Feb 27, 2013 4:29 pm

Re: RPi Cam Web Interface

Sun Aug 21, 2016 8:58 am

Hi. I'm just starting out this this but am having issues with the pi constantly rebooting when I power it up. I have a rpi3 with a v1.3 camera module and a couple of tower pro servos to use with servoblast.
I have configured it all to start on boot up and enabled the servo scripts, but it now just reboots!
Has anyone had this issue?

btidey
Posts: 1635
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Sun Aug 21, 2016 9:06 am

quavoce wrote:Has anyone else experienced intermitted issues with streaming recorded videos to an iPhone/iPad/Safari by any chance?

When I try to play back a video over a decent 4G mobile signal, I can never get it to play. This sometimes happens on my local network too.

Just wondering if it's my setup or not...

Thanks.
Just to clarify, do you mean streaming the main page preview or playing back a full resolution video via the download page?

For the preview case some browsers, particularly on Apple devices don't handle the mjpeg stream case and the default streaming method where stream of individual jpegs should be used. Under system menu on main page the button should show mjpeg-stream not default stream (This means that is in doing default and pushing the button would change to mjpeg streaming. On slower connections it can be worth lowering the bandwidth requirement by lowering the width of the preview and increasing the divider ratio to say 3.

For the high resolution playback first try downloading th emp4 video and playing it back locally in the browser. This helps establish whether it s a bandwidth issue or a format issue.

quavoce
Posts: 109
Joined: Fri Nov 27, 2015 9:11 am

Re: RPi Cam Web Interface

Sun Aug 21, 2016 4:02 pm

btidey wrote:
quavoce wrote:Has anyone else experienced intermitted issues with streaming recorded videos to an iPhone/iPad/Safari by any chance?

When I try to play back a video over a decent 4G mobile signal, I can never get it to play. This sometimes happens on my local network too.

Just wondering if it's my setup or not...

Thanks.
Just to clarify, do you mean streaming the main page preview or playing back a full resolution video via the download page?

For the preview case some browsers, particularly on Apple devices don't handle the mjpeg stream case and the default streaming method where stream of individual jpegs should be used. Under system menu on main page the button should show mjpeg-stream not default stream (This means that is in doing default and pushing the button would change to mjpeg streaming. On slower connections it can be worth lowering the bandwidth requirement by lowering the width of the preview and increasing the divider ratio to say 3.

For the high resolution playback first try downloading th emp4 video and playing it back locally in the browser. This helps establish whether it s a bandwidth issue or a format issue.
It's the playing back full resolution recorded videos that doesn't seem to work. Streaming live view works ok on the iPhone/iPad/Mac (mjpeg stream). Must be a Safari thing because playing back recorded videos work ok using Chrome on my MacBook. I tried Chrome on my iPhone but it wouldn't work properly with my reverse proxy setup.

Probably not bandwidth related because my 4G myfi has a 40Mb download connection (as indicated by a speedtest app on my phone - I can't get over how fast these things are over the mobile network when you have a decent signal - even more so when in a cottage in the middle of Wales!)

I'll do some more testing by opening up the camera to an external port rather than via my proxy to see if that's the culprit.

Quick question - is it possible to spawn off another MP4Box process that encodes the h264 video to a lower mp4 resolution/bitrate for streaming to a mobile phone? I can then do some scripting to pick out the low res video via push notification (which I'll write up an example of soon).

btw, thanks Robert for all the work you're doing on this project. You are single-handily keeping this alive and well which is why so many people use it. It's the most reliable and responsive Raspberry Pi surveillance software out there, and having recently got into using the built-in motion detection I'm thoroughly impressed!

I even use it to keep an eye on our dog in the boot as she easily gets travel sick! The RPi3 is connected via wifi to my 4G myfi device (mainly used as a local wifi hotspot), I then use IP Cam Viewer to occasionally check that she hasn't been ill yet! :)

nospam
Posts: 56
Joined: Sun Jun 14, 2015 10:38 pm

Re: RPi Cam Web Interface

Sun Aug 21, 2016 5:09 pm

confused85 wrote:Hi. I'm just starting out this this but am having issues with the pi constantly rebooting when I power it up. I have a rpi3 with a v1.3 camera module and a couple of tower pro servos to use with servoblast.
I have configured it all to start on boot up and enabled the servo scripts, but it now just reboots!
Has anyone had this issue?
Have you tried a different power supply? Try removing all USB devices and see if it powers up then add a new device and keep going until you figure out which one is causing the problem.

quavoce
Posts: 109
Joined: Fri Nov 27, 2015 9:11 am

Re: RPi Cam Web Interface

Mon Aug 22, 2016 7:40 am

How to set up Push Notifications when motion is detected
I've had this running for a week and it works really well and is quick! For iPhone, Android, and Desktop!
There is a £3.99 lifetime license (per platform) after the 7-day trial, but well worth it for the price.

The end result of this tutorial is to have push notifications sent to you as soon as motion is detected. It doesn't use SMS so a mobile data connection would be required. The message itself will send a URL to your device that when clicked on will take you to your camera's website and open the thumbnail image that was created when motion was detected.

The service I use is called Pushover - https://pushover.net. You don't need to install any software on the Pi as it just sends a Curl message to their API using a bash script.

Signing and Setting up Pushover
1. Sign up for an account here: https://pushover.net/login
2. Make a note of your "user key" (copy it into a text editor for example)
3. Select the Apps & Plugins link
4. Click Create a new Application
5. Give your app a name, and choose Script within the Type drop-down menu.
6. Tick the checkbox and press Create Application
7. Make a note of your API/Token key.

Install the Smartphone App or launch the desktop client
1. Links to the apps are on the Pushover website under the Android, iOS, & Desktop link

Create a script on the Pi
1. At the command prompt, cd to the macros folder (substitute html for the folder you specified during setup)

Code: Select all

cd /var/www/html/macros/
2. Create a start_vid.sh file using your favourite text editor (nano or vim for example - the latter of which needs to be installed using "sudo apt-get install vim" - nano is easier if you don't know vim)

Code: Select all

sudo vim start_vid.sh
3. Paste the following into the file:

Code: Select all

time=`date`
url="http://MyDynamicURLorIP:optionalPort/html" #no trailing slash after html
cameraName="myCam"

filename=${1##*/}
thumb=`echo $filename | awk -F "_" '{ print $2 }'`
thumbname="v${thumb}.th.jpg"
sendurl="${url}/media/${filename}.${thumbname}"

curl -s \
  -F "token=yourAPITokenKey" \
  -F "user=yourUserKey" \
  -F "message=Motion detected at $time." \
  -F "title=Motion Detected from $cameraName" \
  -F "url=$sendurl" \
  -F "url_title=Click to open image" \
  https://api.pushover.net/1/messages.json > /dev/null 2>&1
4. Save the file and the change the permissions so it can be executed.

Code: Select all

sudo chmod +x start_vid.sh
sudo chown www-data:www-data start_vid.sh
5. Test it works

Code: Select all

sudo ./start_vid.sh /var/www/html/media/vi_0003_20160818_092213.mp4
6. This should send a push message to your phone with a link to thumbnail for the above file (which obviously won't work for you unless you already have a video with the exact date and time as above) :)

Hopefully the above will work for you. Let me know if you have any issues or the instructions need updating for clarity.

My next project will be to integrate it with Life360, IFTTT, and someting called Raspi_Runner. The plan being that when the last person leaves our house, motion detection is turned on automatically. Same in reverse, it turns on when the first person arrives home.

Return to “Camera board”