billw
Posts: 389
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Mar 07, 2017 1:15 am

Nestboxtech wrote:Is there a way that I can take the live feed preview and use it in a different webpage?

What I want to do is to use the video preview window on a custom webpage and add buttons to control GPIOs for that RPi.
Camera is in a birdbox, and I want to be able to add some ability to control lighting via GPIOs on a webpage that includes a preview of the video feed. I can do the GPIO control bit, just havent figured out embedding the video feed.
live.php in the www directory is a starting point. You can also add contol buttons to the existing
index.php by putting buttons in a custom-control.php in the www directory. If that file exists, it will
be read into the index.php page. I've done this to have buttons that run a command and the
command toggles a GPIO pin that drives a relay. This is my custom-control.php:

Code: Select all

<?php
if (isset($_POST['poolon']))
    {
    $CMD = "sudo -u pi /usr/local/bin/pool on  > /tmp/pool &";
    exec($CMD);
    }
if (isset($_POST['pooloff']))
    {
    $CMD = "sudo -u pi /usr/local/bin/pool off  > /tmp/pool &";
    exec($CMD);
    }

echo "<div class='text-center top-margin'>";
echo "<form method='post'>";
echo "<span style=\"color: $default_text_color; margin-left:25px;\">Pool:</span>
    <button type='submit' name='poolon' class='btn-control'>On</button>
    <button type='submit' name='pooloff' class='btn-control'>Off</button>";
echo "</form>";
echo "</div>";
?>
You can drop it in to the www dir and reload to see what it does. Files starting with custom are left
alone by git. Maybe somebody else has done something a different or better way and can comment.
The next logical iteration would be to include the video feeds for several PikrellCams into one webpage...
https://cjsavage.com/coding/pikrellcam- ... -page.html

User avatar
underwhelmd
Posts: 93
Joined: Fri Jul 08, 2016 10:05 pm
Location: East Coast, Canada

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Mar 07, 2017 5:44 am

Nestboxtech wrote: The next logical iteration would be to include the video feeds for several PikrellCams into one webpage...

Yup, I'm using a custom version of that code here. It's a good place to start.

Image

Nestboxtech
Posts: 69
Joined: Fri Apr 11, 2014 9:45 pm
Contact: Website

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Mar 08, 2017 7:55 am

underwhelmd wrote:
Nestboxtech wrote: The next logical iteration would be to include the video feeds for several PikrellCams into one webpage...

Yup, I'm using a custom version of that code here. It's a good place to start.

Image
Could you offer any pointers to how you've done your temp charts?
http://nestboxtech.blogspot.co.uk/

User avatar
underwhelmd
Posts: 93
Joined: Fri Jul 08, 2016 10:05 pm
Location: East Coast, Canada

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Mar 08, 2017 9:42 am

Nestboxtech wrote: Could you offer any pointers to how you've done your temp charts?

Sure, I'd help any way I can. It's all "borrowed" scripts, found on various blogs, that I put together to make what I wanted with rrdtool. A real dog's breakfast of scripts.

This thread isn't the place to document that so you can msg me for details on that or I can start a thread in an appropriate forum to show how I made them work.
Last edited by underwhelmd on Tue Mar 21, 2017 8:17 pm, edited 1 time in total.

Nestboxtech
Posts: 69
Joined: Fri Apr 11, 2014 9:45 pm
Contact: Website

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Mar 10, 2017 12:27 am

I had to reinstall onto a new Rpi3 having just fried one :(. This time Pikrellcam wont start automatically and I have to press the START button to get it going. I'm sure I selected autostart on the install script but can't be sure. I cant find where to set that option elsewhere.
http://nestboxtech.blogspot.co.uk/

Ongelma
Posts: 113
Joined: Wed Dec 03, 2014 6:46 am

Re: PiKrellCam: motion vector detect + OSD web interface

Fri Mar 10, 2017 11:14 am

Hello.

Would it be possible for you to implement a switch for loop recording? A simple gui switch please. :) Im not so good at editing stuff in terminal :)

billw
Posts: 389
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Mar 11, 2017 2:37 am

Nestboxtech wrote:I had to reinstall onto a new Rpi3 having just fried one :(. This time Pikrellcam wont start automatically and I have to press the START button to get it going. I'm sure I selected autostart on the install script but can't be sure. I cant find where to set that option elsewhere.
The install script should put a line near the bottom of /etc/rc.local:

Code: Select all

su pi -c '(sleep 5; /home/pi/pikrellcam/pikrellcam) &'
If it is there, I don't know what is wrong. If it is not there, just rerun the install script and notice
if the script gives any errors.

billw
Posts: 389
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Mar 11, 2017 2:41 am

Ongelma wrote:Hello.

Would it be possible for you to implement a switch for loop recording? A simple gui switch please. :) Im not so good at editing stuff in terminal :)
I could add a loop command to generate videos, but managing tracking when to delete them or
maybe if they should be put in a different directory than the videos directory is something I may not
want to add to pikrellcam and are things maybe best handled by scripts.

Ongelma
Posts: 113
Joined: Wed Dec 03, 2014 6:46 am

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Mar 11, 2017 7:55 am

Ok. Didnt quite understand more than its not gona happend :D Would it then be possible maybe, have a switch for "move recorded files to usb daily, weekly etc? Then one could change usb sticks every once in a while. :) Or a button that moves them when pressed?

billw
Posts: 389
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Mar 11, 2017 3:21 pm

Ongelma wrote:Ok. Didnt quite understand more than its not gona happend :D Would it then be possible maybe, have a switch for "move recorded files to usb daily, weekly etc? Then one could change usb sticks every once in a while. :) Or a button that moves them when pressed?
From my perspective there are two paths:
1) I add a command to start and stop video loop recording and loop videos get stored into the
videos directory and that's all. Some user or me later does some work writing some scripts that
manage those videos by deleting old ones after some time or disk capacity check. This is easy for
me and I likely will add such a command after I finish the new feature I'm adding now and get the
next release out.
2) I add loop as a fully supported pikrellcam feature. This means pikrellcam takes care of
managing old videos, has a separate loop video directory, and integrates all into the web page. I
would need to spend time thinking about how to best do that before I could commit to doing it.
So all I can say now is I don't know about this path.

User avatar
underwhelmd
Posts: 93
Joined: Fri Jul 08, 2016 10:05 pm
Location: East Coast, Canada

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Mar 11, 2017 3:55 pm

billw wrote: scripts that manage those videos by deleting old ones after some time or disk capacity check.
^^ this would be very useful.

I would like to automate this: if a video has been sitting there for X amount of days (in my case, 3-4 days) it's deleted. If I haven't seen it and downloaded in X days, it's no good.

Nestboxtech
Posts: 69
Joined: Fri Apr 11, 2014 9:45 pm
Contact: Website

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Mar 12, 2017 10:51 pm

billw wrote:
Nestboxtech wrote:I had to reinstall onto a new Rpi3 having just fried one :(. This time Pikrellcam wont start automatically and I have to press the START button to get it going. I'm sure I selected autostart on the install script but can't be sure. I cant find where to set that option elsewhere.
The install script should put a line near the bottom of /etc/rc.local:

Code: Select all

su pi -c '(sleep 5; /home/pi/pikrellcam/pikrellcam) &'
If it is there, I don't know what is wrong. If it is not there, just rerun the install script and notice
if the script gives any errors.
My rc.local looked as you've kindly shown above... I re-ran the install script as suggested and that seems to have fixed the issue. Many thanks
http://nestboxtech.blogspot.co.uk/

benras
Posts: 58
Joined: Sat Mar 03, 2012 5:52 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Mar 15, 2017 2:22 am

After failing on install, a second install worked, but not without some fiddling.

I just read through all 41 pages of this thread and took notes. I'll share later once I get them all sorted.

Rasilon
Posts: 101
Joined: Wed Mar 11, 2015 7:30 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Mar 21, 2017 7:43 pm

Would it be possible to have the archives on my pc instead of on the pi?

User avatar
Gavinmc42
Posts: 3166
Joined: Wed Aug 28, 2013 3:31 am

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Mar 22, 2017 7:34 am

Has anyone tried the cluster hat yet?
http://clusterhat.com/

Just got one with a Pi ZW
So far it looks like Jessie Lite and gadget mode Zeros also running Lite.
This means pikrellcam is a simple install :lol:

Idea is two use 4 Zeros, two using NOIR's, pikrellcam runs sunrise/sunset script to turn 2 Zero's on/off.
Or 5 cameras for total surround vision :D

Rats, ssh turned of by default, might take some time to get all 5 installed and working :lol:
Time to buy some more 16GB SD's?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

benras
Posts: 58
Joined: Sat Mar 03, 2012 5:52 pm

How to run a Python script on motion detect?

Sun Mar 26, 2017 4:52 pm

Can someone give me the best method for running a custom Python script after the video is captured? I have a script that can upload files to my Google Drive that I want to use for my videos.

Also, is there an easy way to start PiKrellCam with a delay, say 5min, so that it doesn't capture me leaving the house? I suppose I could write a script to delay the PiKrellCam command line start, but maybe there's somewhere in the configuration file that allows this?

RE: Would it be possible to have the archives on my pc instead of on the pi?
You could mount the PC drive as a network drive, then set the archive location in the pikrellcam.conf file.

Fox Mulder
Posts: 42
Joined: Fri Sep 21, 2012 11:24 am

Re: How to run a Python script on motion detect?

Mon Mar 27, 2017 9:14 am

benras wrote:Can someone give me the best method for running a custom Python script after the video is captured? I have a script that can upload files to my Google Drive that I want to use for my videos.

Also, is there an easy way to start PiKrellCam with a delay, say 5min, so that it doesn't capture me leaving the house? I suppose I could write a script to delay the PiKrellCam command line start, but maybe there's somewhere in the configuration file that allows this?
Use the script "motion-end" in the scripts directory which is executed after a motion detect video is created. There you can execute your commands and have access to different variables like the created video filename and path. I use this file to send me a message when a new video was created.

For a delayed start i don't know a way how pikrellcam can do this by itself. I created a little python script which does this with help of the FIFO commands to dis-/enable motion detection and something more like Telegram integration.

Ciao,
Rainer

benras
Posts: 58
Joined: Sat Mar 03, 2012 5:52 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Mar 28, 2017 8:37 pm

Thanks, Rainer, I'll try that.

I'd also like the option to send the log file rather than, or as well as, a snapshot. I think I could design the "motion regions" in such a way as to recognize certain patterns. Maybe even prevent initiating a video if the pattern matches "leaving the house" or "getting the mail" something like that.

benras
Posts: 58
Joined: Sat Mar 03, 2012 5:52 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Apr 02, 2017 2:06 am

I set my media_dir to a thumb drive in pikrellcam.config

media_dir /media/pi/SANDISK-16/pikrellcam

And it saves to this location fine. But when I attempt to view the files in the Media: Vidoes or Stills, it shows nothing. In the pikrellcam/www directory, I see a symbolic link to my thumb drive:

media -> /media/pi/SANDISK-16/

Can someone tell me what else I need to change for the web page to point to the right directory?

Thanks!

BTW: I modified the index.php file to include a StartD button that calls a JS function called pikrellcamD(startD) that initiates the PHP function in sys_command.php that looks for pikrellcam_startD - and to THAT I added

sleep(300);

I tested it - and I wasn't sure that initializing the PHP script would finish if I closed the browser, but it did. So now I have a new button that I can click, close down, and it will continue to run (and wait 5min) before starting pikrellcam.

I wish I had been doing this when pikrellcam was new and hot - it seems like this topic is a little slow. Which is a shame, because it's pretty cool.

Now I need to figure out how to get PKC to record motion region data to a text file that I can email to myself.

billw
Posts: 389
Joined: Tue Sep 18, 2012 8:23 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Apr 02, 2017 2:37 pm

benras wrote:I set my media_dir to a thumb drive in pikrellcam.config

media_dir /media/pi/SANDISK-16/pikrellcam

And it saves to this location fine. But when I attempt to view the files in the Media: Vidoes or Stills, it shows nothing. In the pikrellcam/www directory, I see a symbolic link to my thumb drive:

media -> /media/pi/SANDISK-16/

Can someone tell me what else I need to change for the web page to point to the right directory?
Is the thumb drive linux or windows formatted? If windows it needs the right permissions to be
set when it is mounted and can't be done by pikrellcam. Search for umask in the Help page.
Now I need to figure out how to get PKC to record motion region data to a text file that I can email to myself.
Every motion detect video writes a /run/pikrellcam/motion-events file with detects by region logged
there as text lines. There's a scripts/motion-send-alarm (python) you can look at for an example
of reading the motion-events file and instead of sending an alarm you could send an email.
The file is written in real time as events happen. A script to read the file should be set up to run
in pikrellcam.conf as a on_motion_begin command. Search for the motion-events file in the Help
page and also for on_motion_begin.

benras
Posts: 58
Joined: Sat Mar 03, 2012 5:52 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Apr 04, 2017 3:34 am

The USB is Windows formatted - I'll look into permissions. PiKrellCam writes to it just fine - it just doesn't find them on media-archive.php when I click the Media: Videos button.

Looking at motion-events - yes that's the stuff. I wonder if I could get meaningful data out of it - enough to determine types of events.

Hey - great application! Thanks!

ldon13
Posts: 35
Joined: Mon Mar 27, 2017 9:46 am
Location: Australia

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Apr 06, 2017 4:29 am

Hello,

Any plans to implement a package install? I heard this was been said 2 years ago. Can Pikrellcam be reinstalled without formatting SD card? Im guessing reinstalling php5 and nginx and all the dependencies. Thanks billw. This software is what i needed, thanks for all the hard work. :)

Did a reinstall and the following errors were shown after the setup:

Code: Select all

 
Starting PiKrellCam install...
No packages need to be installed.
Adding a pikrellcam autostart command to /etc/rc.local:
su pi -c '(sleep 5; /home/pi/pikrellcam/pikrellcam) &'
Adding to /etc/sudoers.d: www-data permission to run pikrellcam as user pi:
Adding password for user pi
Installing /etc/nginx/sites-available/pikrellcam
    nginx web server port: 5002
    nginx web server root: /home/pi/pikrellcam/www
Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
mkdir: cannot create directory 'scripts': Permission denied
cp: cannot create regular file '../scripts': Permission denied
cp: cannot create regular file '../scripts': Permission denied
cp: cannot create regular file '../scripts': Permission denied
cp: cannot create regular file '../scripts': Permission denied
cp: cannot create regular file '../scripts': Permission denied
cp: cannot create regular file '../scripts': Permission denied
cp: cannot create regular file '../scripts': Permission denied
cp: cannot create regular file '../scripts': Permission denied
cp: cannot create regular file '../scripts': Permission denied
cp: cannot create regular file '../scripts': Permission denied
cp: cannot create regular file '../scripts': Permission denied

Install finished.
This install script does not automatically start pikrellcam.
To start pikrellcam, open a browser page to:
    http://your_pi:5002
and click on the "System" panel and then the "Start PiKrellCam" button.
PiKrellCam can also be run from a Pi terminal for testing purposes.
Automatic pikrellcam starting at boot is enabled.

[email protected]:~/pikrellcam $ 
[email protected]:~/pikrellcam $ cd
[email protected]:~ $ systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
   Active: failed (Result: exit-code) since Thu 2017-04-06 16:50:58 AEST; 4min 2s ago
  Process: 1410 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
[email protected]:~ $ 
Ignore this, got it all working, i thought installs overwrite the original files, but i had to delete them..
All good!

Ehh, Does PikrellCam, nginx or php5 use any files in /tmp? I moved tmp to tmpfs, did a reboot an hour later and nginx failed to start. Gave the same error above.

Code: Select all

Apr 06 19:00:00 PiZeroW nginx[857]: nginx: [alert] could not open error log file: open() "/var/log/ngi...tory)Apr 06 19:00:00 PiZeroW nginx[857]: 2017/04/06 19:00:00 [emerg] 857#0: open() "/var/log/nginx/error.lo...tory)Apr 06 19:00:00 PiZeroW systemd[1]: nginx.service: control process exited, code=exited status=1
Apr 06 19:00:00 PiZeroW systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Apr 06 19:00:00 PiZeroW systemd[1]: Unit nginx.service entered failed state.
Apr 06 19:00:00 PiZeroW nginx[857]: nginx: configuration file /etc/nginx/nginx.conf test failed

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

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Apr 06, 2017 3:51 pm

Where is the log file written, the one you see when you press the "log" button at the bottom of the main screen? That might be in /tmp ?

I know there is a logfile, and I do not see it listed at the bottom of the original docs page http://billw2.github.io/pikrellcam/pikrellcam.html
so I suspect that page hasn't been updated since the logfile was added.

UPDATE: Looks like it is configurable, but check if your /home/pi/.pikrellcam/pikrellcam.conf file includes this:

Code: Select all

# Log file.
#
log_file /tmp/pikrellcam.log

ldon13
Posts: 35
Joined: Mon Mar 27, 2017 9:46 am
Location: Australia

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Apr 06, 2017 10:03 pm

jbeale wrote:Where is the log file written, the one you see when you press the "log" button at the bottom of the main screen? That might be in /tmp ?

I know there is a logfile, and I do not see it listed at the bottom of the original docs page http://billw2.github.io/pikrellcam/pikrellcam.html
so I suspect that page hasn't been updated since the logfile was added.

UPDATE: Looks like it is configurable, but check if your /home/pi/.pikrellcam/pikrellcam.conf file includes this:

Code: Select all

# Log file.
#
log_file /tmp/pikrellcam.log
Yea, im not quite sure if the migrate of /tmp and syslogs to ramfs was what caused nginx to fail to load. I cant access the nginx server on web browser.

Ill have to reinstall again because the log file would of been erased during reboot, and some other files that could of been important for nginx that nginx failed for some reason.

Im just trying to reduce the amount of writes to the 8GB SD card running on Raspbian Lite, as it will be going 24/7 and limited on disk space. Im as well trying to work out if i could let Pikrellcam save the saved motion detected images to ramfs and email the images while stored in Ram, and automatically remove after it was sent by email to me.

I used this to be added to fstab

Code: Select all

 tmpfs /tmp  tmpfs defaults,noatime 0 0
tmpfs /var/log  tmpfs defaults,noatime,size=64m 0 0 

Fox Mulder
Posts: 42
Joined: Fri Sep 21, 2012 11:24 am

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Apr 06, 2017 11:08 pm

For Debian or Raspbian there is a predefined systemd task for using a ramdisk for /tmp.
https://wiki.debian.org/SSDOptimization ... ia_RAMDISK

For /sys/log on tmpfs i wrote a little script which automatically syncs the content to the sd-card and back within certain intervals to keep the logs but reduce the writes to the sd-card. I think i posted it in some earlier posts here.

Ciao,
Rainer

Return to “Camera board”