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

Re: PiKrellCam: motion vector detect + OSD web interface

Sat May 06, 2017 1:02 am

Can the 19.2MHz be divided accurately enough by the PWM or GPCLK0?
To answer half my own Question, No.

The GPCLK's only have 12 bit dividers.
So 19.2MHz /4095 = 4688Hz is nowhere close enough to 15-120Hz required for a IR LED strobe pulse unless an extra divider is used.
Found this out using Ultibo but it looks like Gordon's WiringPi which was ported to Ultibo will work in Raspbian etc
http://wiringpi.com/reference/core-functions/
pinMode(1, GPIO_CLOCK) will setup pin 18 as the GPCLK0.

There are two unknown? clock sources testdebug0/1. Are these I/O pins? JTAG CLK?
Not sure if GPCLK1/2 are free to use, have GPCLK1 outputting to pin 5, feed it back into pin 6 as JTAG-CLK/debug clock?
With two GPCLK's in series should get real accurate clock out of GPCLK0 for a LED strobe but only 50% duty cycle.
So now time to figure out the PWM hardware.

There are solutions already in software and external hardware for IR strobes, but the point of me doing it this way is to learn the Pi's hardware. And to make a simple IR strobe for night use of Pikrellcam.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

andies
Posts: 130
Joined: Mon Nov 11, 2013 8:12 pm
Location: Berlin

Re: PiKrellCam: motion vector detect + OSD web interface

Sat May 06, 2017 9:57 am

I am helping myself at the moment with

Code: Select all

#!/bin/bash
#---------------------------------------------------------
YEAR=$( date +%Y) 
M0=$( date --date='1 month ago' +%m)
M1=$( date  +%m)
curl http://<user>:<password>@localhost/media-archive.php?mode=archive&year=$YEAR&m0=$M0&d0=1&m1=$M1&d1=1&delete_all 
and I am evaluating m0 and m1 as above. A little bit cumbersome. It would be great to have a "general" command.
raspberry B, Noir camera, Mac Book Air, iPhone, Bezzera

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sat May 06, 2017 2:15 pm

yes, with a fixed time interval not depending on actual disk use, you may suddenly run out of storage space if you have a period of time with an unusually large number of events.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sat May 06, 2017 3:15 pm

jbeale wrote:yes, with a fixed time interval not depending on actual disk use, you may suddenly run out of storage space if you have a period of time with an unusually large number of events.
Which is why I will have to make a builtin implementation that checks space per video. Probably it will
be a single config of disk percent usage limit and then you wouldn't have to worry about it again.
At some point there should be a video protect but I'm not sure how I would implement that yet.

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

Re: PiKrellCam: getting preview, but no recording (all black

Thu May 18, 2017 12:10 pm

Thought I'd post this here. I've noticed over the last few weeks that I occasionally get video recordings that show the preview, but the entire video is blacked out.

I don't believe it's an issue with PiKrellCam, could it be a possibility my SD card is going up, or a setting in PiKrellCam I'm missing? It works very well 99.9% of the time.

Thanks in advance.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Thu May 18, 2017 8:07 pm

No idea about your specific situation but I can tell you, after about a year of heavy use, one of my PiKrellCam units started having "blackouts" somewhere in the middle of a clip, either a freeze-frame or just a gap typically about 5 seconds long. This was infrequent, maybe 2% of all clips but it happened quite a few times. I was using an external 32 GB Sandisk USB thumb drive to hold the video. I replaced the memory stick with a new one, and it has not happened since. Both old and new models were like this one:
SanDisk Cruzer Fit 32GB https://www.amazon.com/SanDisk-Cruzer-L ... B00812F7O8

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

Re: PiKrellCam: motion vector detect + OSD web interface

Thu May 18, 2017 11:15 pm

jbeale wrote:No idea about your specific situation but I can tell you, after about a year of heavy use, one of my PiKrellCam units started having "blackouts" somewhere in the middle of a clip, either a freeze-frame or just a gap typically about 5 seconds long. This was infrequent, maybe 2% of all clips but it happened quite a few times. I was using an external 32 GB Sandisk USB thumb drive to hold the video. I replaced the memory stick with a new one, and it has not happened since. Both old and new models were like this one:
SanDisk Cruzer Fit 32GB https://www.amazon.com/SanDisk-Cruzer-L ... B00812F7O8
@jbeale

Yeah, I'm thinking the same thing. I use mine heavily as well. I'll try swapping out the SD with another, been working great for quite a while.

Good idea on the USB, might try that instead. Thanks!

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

Re: PiKrellCam: motion vector detect + OSD web interface

Fri May 19, 2017 5:41 pm

I've now had several systems fail due to SD card corruption, in some cases perhaps just flash wearout. In my usage, I suspect the SD card is the weakest link in the RPi by orders of magnitude (unless it gets wet, in which case connectors can corrode).

I think the safest approach is to use a read-only root FS after the initial setup and config is done. Here's how:
viewtopic.php?f=63&t=161416&start=50

I haven't done this yet, but I will be trying it right away. I will use ramdisk for short-term file storage, and then immediately transfer recorded files to external USB and/or remote hosts.

punacmc
Posts: 31
Joined: Tue Nov 19, 2013 4:07 am

Re: PiKrellCam: motion vector detect + OSD web interface

Tue May 23, 2017 2:24 am

I changed the logical expression to a while loop for efficiency. I use 90% for my limit and it works well. Sure is nice not checking the cameras everyday to delete old files...

Code: Select all

#!/bin/bash

#cdrof.sh (check disk remove oldest file) Created by PuNacMC on 04-17-2017.
#punacmc@gmail.com for questions or suggestions
#This script is freely given to use as you wish on the condition you give credit
#where credit is due.

#The purpose of this script is to check the disk useage on the partition where
#Pikrellcam stores the  media. It then conducts a simple conditional statement
#to determine if the oldest file in the folder should be deleted based on the
#variables the user can define at the begining of the script. The script should
#be set to run by Pikrellcam using "event_motion_end_cmd" in the "pikrellcam.conf"
#file. For example "event_motion_end_cmd $C/cdrof.sh". This will run the script
#after the motion event has ended. This script is not quaranteed to work and you
#use it at your own risk.

#Credit for the syntax for deleting the oldest file goes to the_velour_fog
#located at https://unix.stackexchange.com/questions/355389/delete-oldest-file-in-directory

#Credit for the syntax for checking disk space and storing into variable
#goes to LINOXIDE at https://www.linux.com/blog/linux-shell-script-monitor-space-usage-and-send-email


#Terminate script after the first line that fails (returns nonzero exit code)
set -e

#Echo status on (1) or off (0). This is for debugging outside of Pikrellcam.
ESTAT=0

#Maximum used space variable. Set this to an integer that represents a percentage.
LIMIT=90

#Directory variables. Set these to where your Pikrellcam stores video and thumbnails
DIR="/home/pi/pikrellcam/media/videos"
DIR2="/home/pi/pikrellcam/media/thumbs"

#Navigate to first folder which should point to your videos.
cd $DIR
#Debugging echo statement
if [ $ESTAT -eq 1 ];
   then
   echo "Navigated to $DIR"
   fi

#Get used space of folders partition, and store in variable
USED=`df . | awk '{print $5 }' | sed -ne 2p | cut -d"%" -f1`

#Debugging echo statement
if [ $ESTAT -eq 1 ]; then echo "$USED"
fi
#Debugging echo statement
if [ $ESTAT -eq 1 ]; then echo "Used space is $USED"
fi

#Logic test to see if USED is greater than or equal to LIMIT
while [ $USED -eq $LIMIT ] || [ $USED -gt $LIMIT ];

#If logic test is true
do
   #Find the files in the video folder and sort them by date and time, pull the oldest and delete
   find . -type f -printf '%T+ %p\n' | sort | head -n1 | awk '{print $2}' | xargs rm -v
   #Debugging echo statement
   if [ $ESTAT -eq 1 ]; then echo "Deleted from Videos"
   fi
   #Change directory to second folder which should point to your thumbs
   cd $DIR2
   #Find the files in the thumbs folder and sort them by date and time, pull the oldest and delete
   find . -type f -printf '%T+ %p\n' | sort | head -n1 | awk '{print $2}' | xargs rm -v
   #Debugging echo statement
   if [ $ESTAT -eq 1 ]; then echo "Deleted from Thumbs"
   fi
   #Navigate to first folder which should point to your videos
   cd $DIR
   #Get used space of folders partition, and store in variable
   USED=`df . | awk '{print $5 }' | sed -ne 2p | cut -d"%" -f1`

done

#Script has completed without error
exit 0

wuster
Posts: 2
Joined: Thu May 25, 2017 5:33 am

Re: PiKrellCam: motion vector detect + OSD web interface

Thu May 25, 2017 5:42 am

Hi I am trying to run a command at the end of the motion detect event. So in pikrejllcam.conf I am using the on_motion_end directive with $v for the full path and filename. However $v returns the previous video and not the current one for which the motion detect event is for. Is there another substitution variable I should be using for the current video file? Thanks!

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

Re: PiKrellCam: motion vector detect + OSD web interface

Thu May 25, 2017 9:07 am

Lost one Pi to corrosion, used sandwich baggy not box so self inflicted.
Really need to use long term solution not quick fix that never gets fixed.

Lost a few SDcards to wear, but that to be expected doing 24/7 for nearly 3 years.
External powered USB caddy HD, WD purple work well.
Have yet to do long term testing of USB sticks.

Trying in slow time to come up with a PiCore OS based solution using IR night LEDs, Pi Cluster, Zero's and HD.
PiCore does not write to SD card and is more stable/smaller than Jessie Lite which sucks to update at the moment.

Need to run motion script that only saves car images that do not drive past.
So Zero's facing up/down street can detect cars and only record slow or ones that stop.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: PiKrellCam: motion vector detect + OSD web interface

Thu May 25, 2017 2:37 pm

wuster wrote:Hi I am trying to run a command at the end of the motion detect event. So in pikrejllcam.conf I am using the on_motion_end directive with $v for the full path and filename. However $v returns the previous video and not the current one for which the motion detect event is for. Is there another substitution variable I should be using for the current video file? Thanks!
$v is right, but I see I added a bug in the last release. I'll try to get a fix for it up today.

EDIT: You can upgrade to 4.0.2 now and it should be fixed.

wuster
Posts: 2
Joined: Thu May 25, 2017 5:33 am

Re: PiKrellCam: motion vector detect + OSD web interface

Thu May 25, 2017 5:28 pm

billw wrote:
wuster wrote:Hi I am trying to run a command at the end of the motion detect event. So in pikrejllcam.conf I am using the on_motion_end directive with $v for the full path and filename. However $v returns the previous video and not the current one for which the motion detect event is for. Is there another substitution variable I should be using for the current video file? Thanks!
$v is right, but I see I added a bug in the last release. I'll try to get a fix for it up today.

EDIT: You can upgrade to 4.0.2 now and it should be fixed.
Thank you! It's working as expected now.

asez73
Posts: 7
Joined: Tue Jun 19, 2012 4:04 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Thu Jun 01, 2017 7:36 pm

Hello, I saw this ip67 box https://shop.openh.io/products/rubicon- ... ne-arduino yesterday. It has transparent cover and other stacking options. Just if you might need it. This is not an advertisment.

Chris Race
Posts: 2
Joined: Sun Jun 04, 2017 9:07 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Jun 04, 2017 9:26 pm

Thumbs up for the new audio support - I will test it as soon as the microphones will arrive.
I'm running two Raspberrys with Pikrellcam, one for a birds nest (http://chrisrace.ownspace.de/wordpress/ ... estbetrieb), the other one for the birds feeding place (http://chrisrace.ownspace.de/wordpress/ ... aus-kamera).

Great work Bill, many thanks for that program!

Just one question to all of you that use a USB-Stick for saving the videos: Everything works fine, but I can't accesss the saved videos via the Website. I know that is possibly due to the rights of the automounted Stick (via usbmount), but I can't find a solution on that.

Anyone can help?

Egregius
Posts: 1
Joined: Sun Apr 10, 2016 7:21 am
Contact: Website

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Jun 11, 2017 5:37 am

SD wear out is a pain. Here's my workaround for it:

Set a /temp folder in tmpfs using /etc/fstab

Code: Select all

tmpfs   /temp        tmpfs   defaults,noatime,nosuid,mode=777,size=500m      0       0
Set pikrellcam to use the /temp folder in .pikrellcam/pikrellcam.conf

Code: Select all

media_dir /temp
archive_dir /temp/archive
Use a on_motion_end script in .pikrellcam/pikrellcam.conf

Code: Select all

on_motion_end /home/pi/on_motion_end.sh
Create the script. This script archives the images into their correct folders and tries to send them to my nas (if he's online).

Code: Select all

#!/bin/bash
/home/pi/pikrellcam/scripts-dist/_archive-still day today /temp/archive /temp /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log
sleep 2
/home/pi/pikrellcam/scripts-dist/_archive-video day today /temp/archive /temp /home/pi/pikrellcam/www/FIFO /tmp/pikrellcam.log
sleep 5
rsync -aP --stats --remove-source-files -e "ssh -i /home/pi/.ssh/id_rsa -p 1598" "/temp/archive/" "guy@192.168.2.10:/volume1/files/PiCam1/archive"
/home/pi/checkdisk.sh
If the nas isn't online the checkdisk.sh scripts wakes it when the temp folder is over 50% usage. During the script, when the sync is succesfull it pings another pikrellcam to also do his sync, that's to avoid the nas being waked just after another sync.

Code: Select all

#!/bin/sh
dev=$(hostname)
df -H | grep -vE '^Filesystem|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
  usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1  )
  partition=$(echo $output | awk '{ print $2 }' )
  echo $usep
if [ $usep -ge 50 ]; then
        sudo /home/pi/sync2nas.sh
        if [ "$?" -eq "4" ]
		then
        	curl -s --connect-timeout 2 --max-time 5 http://192.168.2.11/sync2nas.php
		fi
fi
done
sleep 5

df -H | grep -vE '^Filesystem|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
  usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1  )
  partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge 80 ]; then
	msg="Running out of space \"$partition ($usep%)\" on $dev"
	curl -s --connect-timeout 2 --max-time 5 --data-urlencode "text=$msg" --data "silent=false" http://127.0.0.1/telegrammsg.php
fi
done
(The telegram messages are in their for debugging purposes)

Chris Race
Posts: 2
Joined: Sun Jun 04, 2017 9:07 pm

Re: PiKrellCam: motion vector detect + OSD web interface

Tue Jun 13, 2017 3:52 pm

Chris Race wrote:Just one question to all of you that use a USB-Stick for saving the videos: Everything works fine, but I can't accesss the saved videos via the Website. I know that is possibly due to the rights of the automounted Stick (via usbmount), but I can't find a solution on that.

Anyone can help?
No more help needed, sometimes reading the help file does the trick ;) .

As Bill wrotes there:
BillW wrote:However, if the filesystem is not a linux filesystem (eg. VFAT or FAT32) then pikrellcam cannot set up the needed permissions for the web interface to work and media files will not be shown unless the proper permissions are specified when the partition is mounted. For this case, the mount command or fstab entry should specify umask or dmask/fmask permissions of 0002.

namirda
Posts: 4
Joined: Sun Jun 18, 2017 5:29 am

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Jun 18, 2017 5:48 am

Hi Bill,

Thanks for this great software - up and running straight out of the box. That's pretty rare in my experience!

I am using a usb flash drive for my media directory and my NAS for the archive directory. Works perfectly except that if the NAS is not up then I cannot start pkc - startup fails with the message:

Failed to create media, archive or loop dir, exiting!

Is it necessary to be so strict? I would like the opportunity to have pkc saving data to the flash drive and then copy to the NAS when it later becomes available. Any chance?

Thanks

N

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

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Jun 18, 2017 5:20 pm

namirda wrote: Thanks for this great software - up and running straight out of the box. That's pretty rare in my experience!

I am using a usb flash drive for my media directory and my NAS for the archive directory. Works perfectly except that if the NAS is not up then I cannot start pkc - startup fails with the message:

Failed to create media, archive or loop dir, exiting!

Is it necessary to be so strict? I would like the opportunity to have pkc saving data to the flash drive and then copy to the NAS when it later becomes available. Any chance?
The idea was that if there's a directory problem PKC would be starting in a
not working state, but at least for the archive dir you have a point.
And maybe there's a better general way to do this.

So I can be sure about exactly what is going on in your case, can you
show me your log of a failing start? It would be better if you could
try a commandline verbose start for this: pikrellcam -v

Also, are you mounting your NAS in the PKC startup script or sometime later?

namirda
Posts: 4
Joined: Sun Jun 18, 2017 5:29 am

Re: PiKrellCam: motion vector detect + OSD web interface

Sun Jun 18, 2017 9:46 pm

Hi Bill

Thanks for the reply. Here is the command line output of pikrellcam -v

Code: Select all

========================================================
======= PiKrellCam 4.0.2 started at 2017-06-19 09:01:14
========================================================
at_command_add [daily] at: sunset  command: [@exposure_mode night]
at_command_add [daily] at: sunset+10  command: [@video_fps 4]
at_command_add [daily] at: sunset+10  command: [@video_mp4box_fps 4]
at_command_add [daily] at: sunset+10  command: [@mjpeg_divider 1]
at_command_add [daily] at: sunrise-10  command: [@video_fps 24]
at_command_add [daily] at: sunrise-10  command: [@video_mp4box_fps 24]
at_command_add [daily] at: sunrise-10  command: [@mjpeg_divider 4]
at_command_add [daily] at: sunrise  command: [@exposure_mode auto]
  check_modes(/home/pi/pikrellcam/www) 775
    getgrgid() current group name: www-data
    getpwuid() current user name: pi
    User and group names already OK.
    Access mode 775 already OK.
command FIFO: /home/pi/pikrellcam/www/FIFO
audio FIFO  : /home/pi/pikrellcam/www/audio_FIFO
mjpeg stream: /run/pikrellcam/mjpeg.jpg
make_dir(/media/camstick/pikrellcam/current)
  make_dir(/media/camstick/pikrellcam/current) dir already exists.
  check_modes(/media/camstick/pikrellcam/current) 775
    getgrgid() current group name: www-data
    getpwuid() current user name: pi
    User and group names already OK.
    Access mode 775 already OK.
make_dir(/mnt/qnap451/PiCam1)
  make_dir() execing sudo mkdir -p /mnt/qnap451/PiCam1
09:01:14 : execl[wait:1]: sudo mkdir -p /mnt/qnap451/PiCam1
mkdir: cannot create directory ‘/mnt/qnap451’: Permission denied
make_dir(/mnt/qnap451/PiCam1) failed. No such file or directory
Failed to create media, archive or loop dir, exiting!
I am using autofs to mount the NAS share on the pi.

If the NAS goes offline when pkc is up and running then there is no problem - however it is not possible to start pkc unless the NAS is available.

Isn't the most obvious solution simply to issue a warning rather than a fatal error if the archive directory is not available at start?

Thanks

N

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

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jun 19, 2017 12:59 am

namirda wrote: Isn't the most obvious solution simply to issue a warning rather than a fatal error if the archive directory is not available at start?
OK, there's an upgrade to 4.0.3 you can try that doesn't abort if making the archive
dir fails.

namirda
Posts: 4
Joined: Sun Jun 18, 2017 5:29 am

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jun 19, 2017 3:12 am

Thank you - just what I needed.

N

namirda
Posts: 4
Joined: Sun Jun 18, 2017 5:29 am

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jun 19, 2017 4:30 am

Hi Bill,

About a year ago (1st April 2016) there were a few posts by user "djako" in which he proposed changes to the pkc web interface to make it more mobile friendly and he offered his help to implement it. Did anything come of that? I believe he was waiting for you to implement a few updates before proceeding.

N

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

Re: PiKrellCam: motion vector detect + OSD web interface

Mon Jun 19, 2017 12:46 pm

namirda wrote:Hi Bill,

About a year ago (1st April 2016) there were a few posts by user "djako" in which he proposed changes to the pkc web interface to make it more mobile friendly and he offered his help to implement it. Did anything come of that? I believe he was waiting for you to implement a few updates before proceeding.

N
I've long since made those mentioned updates, but have never heard any more from him
about his changes.

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

Re: PiKrellCam: motion vector detect + OSD web interface

Wed Jun 28, 2017 12:04 pm

jbeale wrote:I've now had several systems fail due to SD card corruption, in some cases perhaps just flash wearout. In my usage, I suspect the SD card is the weakest link in the RPi by orders of magnitude (unless it gets wet, in which case connectors can corrode).

I think the safest approach is to use a read-only root FS after the initial setup and config is done. Here's how:
viewtopic.php?f=63&t=161416&start=50

I haven't done this yet, but I will be trying it right away. I will use ramdisk for short-term file storage, and then immediately transfer recorded files to external USB and/or remote hosts.
I missed this reply. Thanks. I'd really like to get away from recording to the SD and perhaps directly to a remote drive, but I could never get it to work for me, guess I'm a noob on that one.

Return to “Camera board”

Who is online

Users browsing this forum: No registered users and 16 guests