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

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 25, 2015 7:41 pm

tomtgrp wrote: 3.
One Problem still stays, I think this isn't trivial:
After a reboot the commands in at-commands must be applied
Yes, it's not trivial and I would have to be careful doing that because there could be a lot
of issues and getting it right for all possible scripts might be a problem. I'll think about ways
to do it, but a simple possibility I've just added would allow leaving that up to the user with a
start script. I added a $D variable which passes times to a script: now dawn sunrise sunset dusk
I tested with this in at-commands.conf and stoped/started pikrellcam:

Code: Select all

daily start "$C/test $C $P $G $D"
And the test script:

Code: Select all

#!/bin/bash

SCRIPTS=$1
FIFO=$2
LOG=$3
NOW=$4
SUNRISE=$6
SUNSET=$7

UP=$((SUNRISE - 5))
DOWN=$((SUNSET + 5))

echo "inform \"times  now: $NOW  up: $UP  down: $DOWN\" 3 3 1" > $FIFO
if ((NOW > UP && NOW < DOWN))
then
    echo "saturation 0" > $FIFO
    echo "inform \"Do setup for day period\" 4 3 1" > $FIFO
else
    echo "saturation -99" > $FIFO
    echo "inform \"Do setup for night period\" 4 3 1" > $FIFO
fi

echo "inform timeout 15" > $FIFO
These "inform" lines draw text on the OSD so I don't have to keep
looking at the log file. Inform is new on the new 1.1.0 pikrellcam.
Whatever args you want to pass to $C/day or $C/night have to first be passed
to this script.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 25, 2015 8:03 pm

There's a new pikrellcam. Now there is a git "Upgrade" button on the web page for one click
upgrades. If anybody is editing source files or non git ignored web files, just be aware that
it does a hard reset to origin master. Do this to upgrade the same way the script upgrades:

Code: Select all

cd ~/pikrellcam
git fetch
git reset --hard origin/master
Restart pikrellcam and reload the web page. Then there will be a www/config-user.php file
you can edit if you want to have a different web page background image. Some text colors
can also be customized to go better with whatever background you use. To be consistent
with the other pages, I modified thumbs.php to use the background.

tomtgrp
Posts: 41
Joined: Thu Jul 09, 2015 8:35 am

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 25, 2015 8:10 pm

billw wrote: ...
These "inform" lines draw text on the OSD so I don't have to keep
looking at the log file. Inform is new on the new 1.1.0 pikrellcam.
Whatever args you want to pass to $C/day or $C/night have to first be passed
to this script.
Thank you.

Yes, I'll try it. Give you the result.

One question, maybe a feature request.

To add custom code (in my case, the Pan-Tilt-IR Controls and a link to a local Pi Monitor) there should be
an option to include code at the end of index.php, which doesnt get affected by update function or produces errors with git pull origin.

something like

Code: Select all

    </div>
<?php include 'custom.php'; ?>
</div>
</body>
</html>

tomtgrp
Posts: 41
Joined: Thu Jul 09, 2015 8:35 am

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 25, 2015 8:45 pm

Found some other bugs:

when stopping and starting with the buttons the motion-regions.conf seems not to be loaded.
tried:
Button Stop
Button Start
klicked Regions, nothing shows up (no rectangle drawn, Vectors shows no speckles)
trying to load the default region by entering default in the textfield and clickig Load shows a [0] region top left,
but my motion-regions.conf should cover 80% from the screen.


tried at shell:
killed pikrellcam pid
started pikrellcam
klicked Regions, rectangle drawn as expected with my 80%, Vectors shows speckles

Br
Thomas

YvesG
Posts: 46
Joined: Wed Oct 03, 2012 6:54 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 25, 2015 8:49 pm

billw wrote:There's a new pikrellcam. Now there is a git "Upgrade" button on the web page for one click
upgrades. If anybody is editing source files or non git ignored web files, just be aware that
it does a hard reset to origin master. Do this to upgrade the same way the script upgrades:

Code: Select all

cd ~/pikrellcam
git fetch
git reset --hard origin/master
Restart pikrellcam and reload the web page. Then there will be a www/config-user.php file
you can edit if you want to have a different web page background image. Some text colors
can also be customized to go better with whatever background you use. To be consistent
with the other pages, I modified thumbs.php to use the background.
All good, button for the upgrade, personal background, thumbs page having now the same look and feel... :D

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

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 25, 2015 9:33 pm

tomtgrp wrote:Found some other bugs:

when stopping and starting with the buttons the motion-regions.conf seems not to be loaded.
tried:
Button Stop
Button Start
klicked Regions, nothing shows up (no rectangle drawn, Vectors shows no speckles)
trying to load the default region by entering default in the textfield and clickig Load shows a [0] region top left,
but my motion-regions.conf should cover 80% from the screen.


tried at shell:
killed pikrellcam pid
started pikrellcam
klicked Regions, rectangle drawn as expected with my 80%, Vectors shows speckles
I'm not able to reproduce this. Can you post your motion-regions.conf.

I added so you can have custom.php and you can also create a subdirectory "custom"
in case you need to have other files referenced from custom.php.

tomtgrp
Posts: 41
Joined: Thu Jul 09, 2015 8:35 am

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 25, 2015 9:45 pm

billw wrote: I'm not able to reproduce this. Can you post your motion-regions.conf.
Here it is:

Code: Select all

[email protected]:~# cat .pikrellcam/motion-regions.conf
add_region 0,100 0,200 0,817 0,529
[email protected]:~#
Attachments
2.jpg
OK state
2.jpg (48.15 KiB) Viewed 4948 times
1.jpg
Error State
1.jpg (47.15 KiB) Viewed 4948 times

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

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 25, 2015 10:21 pm

tomtgrp wrote: Here it is:

Code: Select all

[email protected]:~# cat .pikrellcam/motion-regions.conf
add_region 0,100 0,200 0,817 0,529
[email protected]:~#
There seems to be a locale problem where you have commas for decimal points and the code
expects periods.

When you start from a terminal the locale is set up, but if you start from a web page button
the www-data user is doing a su to user pi and apparently the locale is not set up. I'll have
to look at how to deal with this, so in the meantime, try editing the motion-regions.conf and
change all the ',' to '.' But then I don't know if running from a terminal will then fail.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Aug 25, 2015 11:05 pm

billw wrote: There seems to be a locale problem where you have commas for decimal points and the code
expects periods.
I changed setlocale to do LC_TIME only so numerics now should always use periods. If
commas have gotten into anybodies motion-region files they will unfortunately now need
to be edited out.

tomtgrp
Posts: 41
Joined: Thu Jul 09, 2015 8:35 am

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Aug 26, 2015 8:22 pm

billw wrote:
billw wrote: There seems to be a locale problem where you have commas for decimal points and the code
expects periods.
I changed setlocale to do LC_TIME only so numerics now should always use periods. If
commas have gotten into anybodies motion-region files they will unfortunately now need
to be edited out.
Works all as expected now. Thank you!

custom.php is also very useful.
Thank you!
Attachments
img.jpg
screenshot
img.jpg (47.93 KiB) Viewed 4765 times

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

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Aug 26, 2015 11:21 pm

tomtgrp wrote: custom.php is also very useful.
Thank you!
Actually, from early on I've had in mind integrating servo controls into pikrellcam. I have built my
boards for that (12v-5v DC-DC and gpios 18 and 13 for servos and one stepper) but haven't yet
started the pikrellcam software module. Ultimately what I have in mind is:
1) Manual servo controls like you have done.
2) An api to set up auto pan cycles. This may be a slightly long term project because I want
the pans to coordinate with motion detect holdoff and auto switching to motion detect regions
based on pan preset positions. So this is not something I'm going to have done by next week,
or even month I'm pretty sure... :)
3) Hopefully along with 2) (but I'm not going to promise this yet) object tracking to try to follow
movement.
So I bring this up because of your screenshot. My idea would be to put the servo controls along
side of the record/still buttons just below the preview. If you would be interested in having them
there, within a few days I could go ahead and set it up so they could be put there. And of course
the custom.php can always stay where it is anyway.

Are you using a generic ebay pan/tilt mount or something else? And if you are mounting
outside, what kind of case/enclosure are you using?

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

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Aug 27, 2015 3:01 am

@billw: Good work on the current updates, I like the ability to check the log with a button. Fortunately no need to, though; PiKrellCam continues to work reliably for me 24/7 on the two units I have deployed.

Sounds like you have ambitious plans for the future, as well. The idea of motion tracking sounds interesting. I wonder about the camera being "distracted" away from the main aim point by some minor movement to one side, then miss something more important on the other side, but I guess no single setup can cover every situation. Thanks again for all your work!

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

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Aug 27, 2015 4:29 am

jbeale wrote:@billw: Good work on the current updates, I like the ability to check the log with a button. Fortunately no need to, though; PiKrellCam continues to work reliably for me 24/7 on the two units I have deployed.

Sounds like you have ambitious plans for the future, as well. The idea of motion tracking sounds interesting. I wonder about the camera being "distracted" away from the main aim point by some minor movement to one side, then miss something more important on the other side, but I guess no single setup can cover every situation. Thanks again for all your work!
Yeah, one of the reasons I said I'm not promising this. I would like it but the implementation
could easily get pretty hairy and I won't include it unless I can get it to be at least mostly reliable
under certain defined conditions. And of course it would be optionally enabled.

tomtgrp
Posts: 41
Joined: Thu Jul 09, 2015 8:35 am

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Aug 27, 2015 10:43 pm

billw wrote: Actually, from early on I've had in mind integrating servo controls into pikrellcam. I have built my
boards for that (12v-5v DC-DC and gpios 18 and 13 for servos and one stepper) but haven't yet
started the pikrellcam software module. Ultimately what I have in mind is:
1) Manual servo controls like you have done.
2) An api to set up auto pan cycles. This may be a slightly long term project because I want
the pans to coordinate with motion detect holdoff and auto switching to motion detect regions
based on pan preset positions. So this is not something I'm going to have done by next week,
or even month I'm pretty sure... :)
3) Hopefully along with 2) (but I'm not going to promise this yet) object tracking to try to follow
movement.
So I bring this up because of your screenshot. My idea would be to put the servo controls along
side of the record/still buttons just below the preview. If you would be interested in having them
there, within a few days I could go ahead and set it up so they could be put there. And of course
the custom.php can always stay where it is anyway.

Are you using a generic ebay pan/tilt mount or something else? And if you are mounting
outside, what kind of case/enclosure are you using?
A short answer (I am working on a summary of all information of my control and hardware, result will be on my dropbox):
-I also thought about motion detect holdoff while pan, and yes, the regions must move.
Sounds very interesting.

-servo controls along side: yes, but configuration entry to enable them (eg.if no hardware present)
maybe own code like custom.

-it is a generic ebay type, something like this
http://www.ebay.de/itm/FPV-PT-Pan-Tilt- ... 259a0f9b3a
Not happy with it, wobbly and instable, too high. I own a 3d printer, maybe I make my own mount

-as a outdoor enclosure I bought some Everfocus EHD 350 1,3" domes, removed the parts,reused the camera mounting
Pi fits well. Attached an usb wlan stick, drilled a hole for a sma connector with external antenna.

-i am thinking about an enclosure like this (site is german): http://wcn.netcamera.org/housing.php

-also very interesting, IR Beamer, has a front glass with space for camera:
http://www.ebay.de/itm/Night-vision-inf ... 3f512ca1bd
Problem with integrated IR Beamer are the bugs flying to the camera and triggering motion.

-also useful:
http://www.ebay.de/itm/Network-Socket-P ... 43e192575e

Br
Thomas

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Aug 29, 2015 2:44 am

billw wrote:
tomtgrp wrote: custom.php is also very useful.
Thank you!
My idea would be to put the servo controls along
side of the record/still buttons just below the preview. If you would be interested in having them
there, within a few days I could go ahead and set it up so they could be put there. And of course
the custom.php can always stay where it is anyway.
Now you can have a custom-control.php that will put your buttons below the preview. I have a
control.php (just a mock up for now to demonstrate) that puts controls up if enabled in config-user.php.
So pikrellcam controls will be enabled in config-user.php and any user can have their own custom
controls in custom-control.php that only needs to exist to show up.

kevw
Posts: 22
Joined: Wed Aug 27, 2014 1:49 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Sat Aug 29, 2015 9:46 pm

Evening, not sure when it happened but I'm now not able to play recordings embedded from my android phone using chrome.. I have to download the full file and play it in a standalone player. Is this the same for others or could my browser be causing the issue?

Kind regards

Kev

YvesG
Posts: 46
Joined: Wed Oct 03, 2012 6:54 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Aug 30, 2015 7:31 am

kevw wrote:Evening, not sure when it happened but I'm now not able to play recordings embedded from my android phone using chrome.. I have to download the full file and play it in a standalone player. Is this the same for others or could my browser be causing the issue?

Kind regards

Kev
Hi Kev, i never been able to play any video files from PiKrellCam with chrome on android. I think it's due to the fact that Google decided to remove h264 support into chrome.
Best
Yves

Raspberrz
Posts: 11
Joined: Sat Nov 23, 2013 11:17 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Aug 30, 2015 2:18 pm

Hello billw,
thanks for your wonderful work and sharing it with us!!!
billw wrote: There seems to be a locale problem where you have commas for decimal points and the code
expects periods.

If you start pikrellcam from a terminal the locale is set up, but if you start from a web page button
the www-data user is doing a su to user pi and apparently the locale is not set up.
I live in a country where "," is the decimal point character and my region-configs are correctly using the ".". Everything works fine (the annotate-function is displaying the time in my language) until I stop-start pikrellcam from the web-interface, which leads to display the time in english.
Google chrome browser also asks me to translate the web-page into my language, so it might be a global nginx configuration to discard the locale and using english?

And if the regions might move in the future, is it possible to get "a special area" on your todo-list, where movement in this area is starting a script?

Thanks again,
br Martin

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

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Aug 31, 2015 2:50 am

Raspberrz wrote: I live in a country where "," is the decimal point character and my region-configs are correctly using the ".". Everything works fine (the annotate-function is displaying the time in my language) until I stop-start pikrellcam from the web-interface, which leads to display the time in english.
Google chrome browser also asks me to translate the web-page into my language, so it might be a global nginx configuration to discard the locale and using english?
When started from the web page, pikrellcam is started by nginx which is user www-data and it
does a su pi so the program is run as user pi. So I think it's more that the environment is just not
set up in the first place the same as when run from a terminal.
And if the regions might move in the future, is it possible to get "a special area" on your todo-list, where movement in this area is starting a script?
Yes, a command for motion in a particular region is actually already on the the list.

kevw
Posts: 22
Joined: Wed Aug 27, 2014 1:49 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Aug 31, 2015 10:07 am

YvesG wrote:
kevw wrote:Evening, not sure when it happened but I'm now not able to play recordings embedded from my android phone using chrome.. I have to download the full file and play it in a standalone player. Is this the same for others or could my browser be causing the issue?

Kind regards

Kev
Hi Kev, i never been able to play any video files from PiKrellCam with chrome on android. I think it's due to the fact that Google decided to remove h264 support into chrome.
Best
Yves
Thanks Yves,

Did some testing and Firefox was / is the browser that plays embedded in android

cheers

Kev
Last edited by kevw on Mon Aug 31, 2015 6:26 pm, edited 1 time in total.

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

occasionally a video clip is too short

Mon Aug 31, 2015 2:04 pm

PiKrellCam almost always works perfectly. Very occasionally, I get a video that appears to be cut off at the moment that motion is confirmed, in other words it contains only the "pre-event" part of the video. One camera is set up for 4 seconds of video before the event, and 4 seconds after it ends. I just captured a video that is only 4 seconds long in total, and stops about a second after the object enters the frame. The log file doesn't look unusual, except for the short duration.

EDIT: Oops, looks like I turned it off by mistake

Code: Select all

06:55:32 : Video record: /home/pi/pikrellcam/media/videos/motion_2015-08-31_06.55.32_389.mp4.h264 ...
06:55:32 : event preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/motion_2015-08-31_06.55.32_389.jpg
06:55:33 : event preview save: copy /run/pikrellcam/mjpeg.jpg -> /run/pikrellcam/motion_2015-08-31_06.55.32_389.jpg
06:55:33 : command_process: motion_enable toggle
06:55:33 : Video motion record stopped. Header size: 29  h264 file size: 3046460
06:55:33 : execl:[(MP4Box -quiet -fps 24 -add /home/pi/pikrellcam/media/videos/motion_2015-08-31_06.55.32_389.mp4.h264 /home/pi/pikrellcam/media/videos/motion_2015-08-31_06.55.32_389.mp4 2> /dev/null && rm /home/pi/pikrellcam/media/videos/motion_2015-08-31_06.55.32_389.mp4.h264)]
06:55:33 : execl:[/home/pi/pikrellcam/scripts-dist/_thumb /run/pikrellcam/motion_2015-08-31_06.55.32_389.jpg /home/pi/pikrellcam/media /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log 64 71 97 88]
  convert /run/pikrellcam/motion_2015-08-31_06.55.32_389.jpg -crop 71x71+62+53 -resize 150x150\! /home/pi/pikrellcam/media/thumbs/motion_2015-08-31_06.55.32_389.th.jpg
06:55:33 : execl:[/home/pi/pikrellcam/scripts/preview-save  /run/pikrellcam/motion_2015-08-31_06.55.32_389.jpg /home/pi/pikrellcam/media /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log 64 71 97 88]
cp /run/pikrellcam/motion_2015-08-31_06.55.32_389.jpg /home/pi/pikrellcam/media/stills
06:55:33 : event_preview_dispose(); removing /run/pikrellcam/motion_2015-08-31_06.55.32_389.jpg
06:55:35 : event_motion_end_cmd(); running $C/motion-end $v $P $G
06:55:35 : execl:[/home/pi/pikrellcam/scripts/motion-end /home/pi/pikrellcam/media/videos/motion_2015-08-31_06.55.32_389.mp4 /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log]
UPLOADED motion_2015-08-31_06.55.32_389.jpg

boomlikethat
Posts: 85
Joined: Sun Aug 03, 2014 10:32 pm

Re: PiKrellCam: thumbs

Mon Aug 31, 2015 3:01 pm

@jbeale or @billw:

Is there any way to have the thumbs ordered by date and time? The numbering of the files throws it off, particularly if I start/stop PiKrellCam. Personally, I need the numberings for review, then I get rid of them via NameChanger before I archive them.

Thanks!

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

Re: PiKrellCam: thumbs

Mon Aug 31, 2015 3:47 pm

boomlikethat wrote:Is there any way to have the thumbs ordered by date and time? The numbering of the files throws it off, particularly if I start/stop PiKrellCam. Personally, I need the numberings for review, then I get rid of them via NameChanger before I archive them.
Right now, the thumbs ordering is controlled by this one line in the .php file:

Code: Select all

rsort($a);         // sorts the array of filenames in-place, in reverse order (newest at top)
It sorts on the filename only but that has always given the files in time order to me, I guess because I leave PKCam running all the time.

To sort by the actual file time/date in PHP, I gather you have to do something like the below with filemtime() or filectime(), but I haven't tried this yet:
http://php.net/manual/en/function.filectime.php

Code: Select all

<?PHP
function dirList ($directory, $sortOrder){

    //Get each file and add its details to two arrays
    $results = array();
    $handler = opendir($directory);
    while ($file = readdir($handler)) {  
        if ($file != '.' && $file != '..' && $file != "robots.txt" && $file != ".htaccess"){
            $currentModified = filectime($directory."/".$file);
            $file_names[] = $file;
            $file_dates[] = $currentModified;
        }    
    }
       closedir($handler);

    //Sort the date array by preferred order
    if ($sortOrder == "newestFirst"){
        arsort($file_dates);
    }else{
        asort($file_dates);
    }
    
    //Match file_names array to file_dates array
    $file_names_Array = array_keys($file_dates);
    foreach ($file_names_Array as $idx => $name) $name=$file_names[$name];
    $file_dates = array_merge($file_dates);
    
    $i = 0;

    //Loop through dates array and then echo the list
    foreach ($file_dates as $file_dates){
        $date = $file_dates;
        $j = $file_names_Array[$i];
        $file = $file_names[$j];
        $i++;
            
        echo  "File name: $file - Date Added: $date. <br/>"";        
    }

}
?>
By the way, I was surprised to discover that most Unix-like systems do not have the concept of "file creation date", you can only get "file modified date".

stephencassidy
Posts: 37
Joined: Mon Aug 19, 2013 11:12 am

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Sep 01, 2015 2:22 pm

I'm still loving this software and have it running perfectly on 2 Raspberry Pi's, one of them with a Noir camera board and an external infra red light source.

Could I request (if it doesn't already exist) the ability to change the location/colour of the timestamp?

Both of my cameras loose the timestamp in the clouds

Thanks

ste
Attachments
front.png
front.png (52.73 KiB) Viewed 4051 times
rear.png
rear.png (58.04 KiB) Viewed 4051 times

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

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Sep 01, 2015 4:53 pm

The R-Pi camera firmware supports using a black (or colored) rectangle behind the time/date text so it will not get lost in the image. I have my own PKCam set up to use a black background, but I'm not at my Pi and I forgot how; maybe it is in /home/pi/.pikrellcam/ (?)

Image

Return to “Camera board”