PiKrellCam: motion vector detect + OSD web interface


1088 posts   Page 44 of 44   1 ... 40, 41, 42, 43, 44
by Gavinmc42 » 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.
Posts: 1178
Joined: Wed Aug 28, 2013 3:31 am
by andies » 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
Posts: 128
Joined: Mon Nov 11, 2013 8:12 pm
Location: Berlin
by jbeale » 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.
User avatar
Posts: 3249
Joined: Tue Nov 22, 2011 11:51 pm
by billw » 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.
Posts: 300
Joined: Tue Sep 18, 2012 8:23 pm
by boomlikethat » 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.
Posts: 84
Joined: Sun Aug 03, 2014 10:32 pm
by jbeale » 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
User avatar
Posts: 3249
Joined: Tue Nov 22, 2011 11:51 pm
by boomlikethat » 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!
Posts: 84
Joined: Sun Aug 03, 2014 10:32 pm
by jbeale » 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:
https://www.raspberrypi.org/forums/view ... 6&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.
User avatar
Posts: 3249
Joined: Tue Nov 22, 2011 11:51 pm
by punacmc » 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
Posts: 30
Joined: Tue Nov 19, 2013 4:07 am
by wuster » 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!
Posts: 2
Joined: Thu May 25, 2017 5:33 am
by Gavinmc42 » 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.
Posts: 1178
Joined: Wed Aug 28, 2013 3:31 am
by billw » 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.
Posts: 300
Joined: Tue Sep 18, 2012 8:23 pm
by wuster » 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.
Posts: 2
Joined: Thu May 25, 2017 5:33 am