cd /home/pi git clone https://github.com/billw2/pikrellcam.git cd pikrellcam ./install-pikrellcam.shThe install-pikrellcam.sh script installs needed packages and prompts for three things to configure:
First Usage
Motion Vector Direction Detects
After the motion region composite vectors are calculated, the component motion vectors are
filtered for direction and density. This provides high sensitivity and noise
immunity for small to medium sized objects. Motion detection is tested independently for
each motion region.
To adjust direction detects, set the
Vector_Magnitude and Vector_Count values using the OSD. The values should be set
lower in environments where small animal detection is desired or they can be
adjusted higher for moderate sized object detection. The combination of direction
filtering and density checks make this detection method resistant to
camera noise and is why it is good for small object detection.
However, when PiKrellCam detects
camera sparkle noise and the configured Vector_Count is low, the Vector_Count
does get a small dynamic adjustment higher to provide a noise safety margin.
Motion Vector Burst Detects
For large (or close) objects,
the individual camera motion vectors can have large direction distributions.
This is because individual vectors
in larger areas can begin to match pixels in
directions other than the overall object direction and direction detection can
sometimes miss these events.
So instead of using direction filtering, burst detection looks for a sudden
large increase in the number of motion vectors sustained over a number of frames.
This method uses the same region composite vectors as direction
detection, but it does not exclude vectors failing the direction test.
All region composite vectors are combined into an overall frame
composite vector. Motion burst detection is to compare the frame composite vector
count to the Burst_Count limit and to require at least one motion region
to pass a density test which is used to help reduce false detects of
the large noise counts the camera can generate in certain dim light situations.
The burst detect configurations Burst_Count and Burst_Frames are a
coarse adjustment for detection of relatively larger and faster moving
objects and they should be set according to what the noise environment
of the camera allows. For outdoor cameras this noise period occurs in the
minutes before sunrise and after sunset. For indoor cameras any noise
periods will depend on lighting conditions. Since burst detection does not
have the benefit of direction filtering to reduce noise, an
exponential moving average of background noise counts is calculated and
used to provide additional noise margin.
The compared to Burst_Count is dynamically adjusted higher by this average.
You can see the results of PiKrellCam's vector processing on the OSD by turning on the showing of Preset and Vectors. Watching this display will allow you to tune your configured vector limit values to your camera environment. To get a better look at the vectors, you can temporarily raise the mjpeg_divider value so the OSD will update more slowly.
Example Motion Detects
Notes:
A preset is a camera position with a group of motion detect settings (vector magnitude / count and burst count / frames) and a set of motion regions. Clicking the preset up/down arrows moves to a new settings preset which single click loads a completely new set of motion detect settings and motion regions. So presets can be configured with motion detect sensitivities and motion regions appropriate for different weather or other conditions and quickly selected with single clicks.
Preset left/right arrow buttons are shown only if servos are configured and move the servos to configured position presets.
The Servo button and arrows are shown only if servos are enabled. Click the Servo button to cycle the servo arrow direction buttons through three modes: step by one, step by Move_Steps, and scan. When arrow buttons are in scan mode, clicking an arrow will step the servo continuously at Move_Step_msec rate until the arrow button is clicked again or the servo reaches a pan/tilt limit.
Preset behavior without servos:
Motion regions outline areas of the camera view that will be sensitive to motion and provides for excluding from motion detection areas such as wind blown vegetation. Motion regions may be added, deleted, resized or moved at each preset. Motion regions may also be saved by name and this provides a way to maintain a set of motion regions as a backup or a temporary. For example, a backup motion region by name can be loaded as an initial condition after creating a new preset. Or temporary motion regions by name can be loaded if you have a set of different motion regions you want to load to a preset on demand for evaluation. If a motion region is loaded by name it is automatically saved to the current preset unless you have servos and are off a preset.
The increment of a region resize or move can be coarse or fine by selecting/deselecting the Coarse Move select button. When the increment is fine, the adjustment units are single motion vectors. Motion vectors are 16x16 pixel areas of the video so the motion vector array overlayed on the preview display for a 1080p video setting will be 120x68.
A single region can be expanded to cover any motion area of interest, but if the area is large relative to the total frame size, there is one advantage to splitting the area into more than one region. Each region is independently checked for direction motion and there is one composite vector per region. If there are two smaller separated objects moving in the region the composite vector for the region will have a center away from the two objects and the motion test can fail the density check. However, in practice this might not be an issue because the motions may be sporadic or otherwise not synchronous so motion is likely to be detected regardless. But if in doubt, go ahead and split areas into multiple regions. This is why the default motion regions configuration has four regions spanning the width of the motion frame.
This should usually not be an issue, but the size of a motion region should not be so small that it cannot hold the number of vectors that is set for the vector limit count. For example, if the limit count is set to 20 a small region of 10x6 size out of a total frame size of 120x68 will hold three times this limit and should be fine. A safe rule of thumb when limit counts are set higher would be to keep dimensions of motion regions not much smaller than 1/8 of the total frame dimensions.
Motion burst detection considers the total frame composite vector so the total area of all motion regions compared to the burst limit count is the factor to consider.
If servos are not configured, there will be no Move or Copy buttons in the Preset group and there will be no Servo button in the Config group.
Preset
Time Lapse
Config
Camera Params
If this option is
OFF,
the warning is still enabled when showing preset information
with the
Show: Preset button.
Connect an ALSA input capture device such as
USB sound card + microphone, USB mini microphone, or other which can
be recognized by running
arecord -l.
If arecord can record from the device and aplay play the wav file,
then pikrellcam should work using the same sound device. You may need to
run alsamixer to unmute the microphone input and set the capture level.
If you need more information than the basic setup listed here, the web
has many Pi microphone tutorials to look at.
So a microphone setup for PiKrellCam is:
pi@rpi2: ~$ arecord -l | grep USB card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
pi@rpi2: ~$ alsamixer -c 1
# Do a basic 5 second record: pi@rpi2: ~$ arecord -D plughw:1 -d 5 test.wav # And also check using parameters the same as pikrellcam recording defaults, # defaults are: device: plughw:1 channels: 1 rate: 24000 or 48000 16 bit audio. arecord -D plughw:1 -d 5 -c 1 -f s16_LE -r 24000 test.wav # Play the sound: pi@rpi2: ~$ aplay test.wav
Audio Control Buttons
Web page audio control buttons are left to right:
Limitations & Issues
Microphones
Noise is a possible issue when using sensitive omnidirectional microphones. A couple of likely causes are power line hum from the surrounding microphone environment or electrical noise getting into the USB sound card through the power supply. So microphone placement and a clean power supply can be important.
The default loop directory is under the ~/pikrellcam/media directory. This directory can be mounted with a dedicated loop file system and mounting can be done in fstab or in the pikrellcam startup script. Or a dedicated disk can be mounted to some other directory if the loop_dir value in pikrellcam.conf is edited to reference that location.
Loop video recording continuously wears flash disks, so if that is an issue, they can be enabled only for limited times of interest with commands sent to the FIFO:
echo "loop on" > ~/pikrellcam/www/FIFO echo "loop off" > ~/pikrellcam/www/FIFO echo "loop toggle" > ~/pikrellcam/www/FIFOor commands in at-commands.conf like:
Mon-Fri 7:30 "@loop on" Mon-Fri 9:30 "@loop off"Oldest loop videos are automatically deleted to enforce both a configured maximum disk usage percent and configured minimum disk free percent with a priority on minimum disk free percent. The idea is to have a fixed maximum diskusage percent for loop videos and then media videos (manual and motion) and archived videos are allowed to grow until a minimum disk free percent remains if disk free checking is enabled for those videos.
Examples on the interactions of loop recording, setting disk percent limits and enabling disk free checking for motion videos:
~/.pikrellcam/at-commands.conf
~/pikrellcam/scripts/*
~/pikrellcam/www/config-user.php
define("DEFAULT_TEXT_COLOR", "#ffffff");
define("SELECTED_TEXT_COLOR", "#500808");
define("MEDIA_TEXT_COLOR", "#0000EE");
define("MANUAL_VIDEO_TEXT_COLOR", "#085008");
define("LOG_TEXT_COLOR", "#ffffff");
define("BACKGROUND_IMAGE", "images/passion.jpg");
Each motion video will have a corresponding thumbnail jpeg stored in the thumbs sub directory. The motion video and its thumb are created, deleted or archived as a unit. The thumb jpegs are an image of motion extracted from the video and provide a quick view of what caused the motion video.
Media Directories
There are two links in the web page www directory
that pikrellcam uses to store and view media files and the defaults are:
pi@rpi2: ~$ ls -lt pikrellcam/www total 116 lrwxrwxrwx 1 pi www-data 33 Nov 16 09:07 archive -> /home/pi/pikrellcam/media/archive/ lrwxrwxrwx 1 pi www-data 25 Nov 16 09:07 media -> /home/pi/pikrellcam/media/The media link is the main media directory and its media file sub directories which contain a flat list of files where media files for all days are initially stored. Additionally, there is a timelapse and archive sub directory in the main media directory, but these are not a requirement of a media directory and the archive directory location is configurable.
~/pikrellcam/media/videos
/stills
/thumbs
/timelapse
/archive
The default media links
can be configured in media_dir media archive_dir archiveWith this setup, all media files are stored on the Pi SD card. Media files may be configured to be stored on an external disk by editing the
MOUNT_DISK=sda1
This assumes there is a single USB disk plugged into the Pi and it appears as
Also, the mount point can be somewhere else in the filesystem. As an example, you want a VFAT disk to be mounted on /media/mountdir. For this, use absolute pathnames in pikrellcam.conf:
media_dir /media/mountdirIn the startup script, use a mount command like:
sudo mount -t vfat /dev/sda1 /media/mountdir -o rw,user,umask=0002or, if using fstab instead of the startup script, the entry should be like:
/dev/sda1 /media/mountdir vfat rw,user,umask=0002 0 0You can use dmask=0002,fmask=0002 in place of umask=0002.
If mounting a large CIFS filesystem the nounix,noserverino options may be needed in fstab so pikrellcam can make directories. Look at the example fstab entry forum raspberry pi forum
By default, the archive directory is under the pikrellcam media directory and so is on the same file system. But archiving can be to either a separate disk mounted on the archive directory (as described above for mounting the media directory) or to another machine by network mounting on the archive directory. A network mount must have file system permissions set so that the pikrellcam installing user and www-data have read/write permissions from the Pi.
NFS Archiving Example 1
On gkrellm6 (Desktop running Linux - archiving to)
$ cd $ mkdir media-archive
/home/bill/media-archive 192.168.0.0/25(rw,nohide,no_subtree_check,no_root_squash)After editing /etc/exports, restart nfs-kernel-server (/home/bill/media-archive must exist):
$ sudo systemctl restart nfs-kernel-server
192.168.0.10 gkrellm6
gkrellm6:/home/bill/media-archive /home/pi/pikrellcam/media/archive nfs users,noauto 0 0
$ sudo mount gkrellm6:/home/bill/media-archive
NFS Archiving Example 2
On rpi0 (Desktop Pi3 - archiving to)
$ cd /mnt $ sudo mkdir archive $ sudo chown root.disk archive $ sudo chmod 775 archive # Mount partition 3 and make the media-archive subdirectory (my boot disk is sda). $ sudo mount /dev/sda3 /mnt/archive $ mkdir archive/media-archiveI want rpi0 partition 3 mounted at boot, so I have in /etc/fstab (I use PARTUUID in my fstab instead of sda for reliable mounting):
PARTUUID=5d4064ac-01 /boot vfat defaults 0 2 PARTUUID=5d4064ac-02 / ext4 defaults,noatime,discard 0 1 PARTUUID=5d4064ac-03 /mnt/archive ext4 defaults,noatime,discard 0 2
/mnt/archive/media-archive 192.168.0.0/25(rw,nohide,no_subtree_check,no_root_squash)After editing /etc/exports, restart nfs-kernel-server (/mnt/archive/media-archive must exist):
$ sudo systemctl restart nfs-kernel-server
192.168.0.30 rpi0
$ cd /mnt $ sudo mkdir archive $ sudo chown root.disk archive $ sudo chmod 775 archive $ mkdir archive/media-archiveStop pikrellcam and edit archive_dir in ~/.pikrellcam/pikrellcam.conf, then restart pikrellcam.
archive_dir /mnt/archive/media-archive
rpi0:/mnt/archive/media-archive /mnt/archive/media-archive nfs users,noauto 0 0
$ sudo mount rpi0:/mnt/archive/media-archive
NFS Archiving Notes
archive/2017/11/13 or archive/2017/07/04Where 13 is a media directory for November 13. It has the media file sub directories videos, thumbs, and stills. When you archive files from the web page, the web server sends a command to pikrellcam to archive the files and the pikrellcam program does the archiving. Since pikrellcam runs as the user pi, pikrellcam has the sudo permission to create the appropriate directory structure for archiving. Since the web server runs as the user www-data, pikrellcam creates directories with write permission for the user www-data so files can be deleted from the web page. All directories in the archive path have permissions like:
pi@rpi2: ~/pikrellcam/www/archive$ ls -Rl .: total 0 drwxrwxr-x 3 pi www-data 60 Nov 12 12:16 2017/ ./2017: total 0 drwxrwxr-x 6 pi www-data 120 Nov 15 15:28 11/ ./2017/11: total 0 drwxrwxr-x 4 pi www-data 80 Nov 15 15:29 13/ ./2017/11/13: total 0 drwxrwxr-x 2 pi www-data 80 Nov 14 22:08 thumbs/ drwxrwxr-x 2 pi www-data 80 Nov 14 22:08 videos/Keep these permissions in mind if you manage the directory structure outside of pikrellcam.
echo "archive_video day 2017-11-13" > ~/pikrellcam/www/FIFOor a specific video (including its thumb) can be archived with:
echo "archive_video motion_2017-11-05_14.46.14_456.mp4 2017-11-05" > ~/pikrellcam/www/FIFOTo archive all media videos for today or yesterday:
echo "archive_video day today" > ~/pikrellcam/www/FIFO echo "archive_video day yesterday" > ~/pikrellcam/www/FIFOTo archive all loop videos for today or yesterday:
echo "archive_video day_loop today" > ~/pikrellcam/www/FIFO echo "archive_video day_loop yesterday" > ~/pikrellcam/www/FIFOStills may be script archived using the same set of arguments with the archive_still FIFO command.
List of FIFO commands:
audio mic_open audio mic_close audio mic_toggle audio gain [up|down|N] # N: 0 - 30 audio stream_open audio stream_close audio_trigger_video [on|off] audio_trigger_level N # N: 2 - 100 box_MP3_only [on|off] record on record on pre_capture_time record on pre_capture_time time_limit record pause record off loop [on|off|toggle] still tl_start period tl_end tl_hold [on|off|toggle] tl_show_status [on|off|toggle] motion_enable [on|off|toggle] motion_stills_enable [on|off|toggle] motion_detects_fifo_enable [on|off|toggle] motion limits magnitude count motion burst count frames motion trigger code # code is digit N or N:ID N is 0 or 1 and ID is a string (see Examples) motion trigger code pre_capture time_limit motion load_regions name motion save_regions name motion list_regions motion show_regions [on|off|toggle] motion show_vectors [on|off|toggle] motion [command] - other commands sent by the web page to edit motion regions not intented for script or command line use. preset prev_position preset next_position preset prev_settings preset next_settings preset goto position settings zoom percent - percent is 10-100 display [command] - commands sent by the web page to display OSD menus. Not intended for script or command line use. tl_inform_convert video_fps fps video_bitrate bitrate still_quality quality video_mp4box_fps fps inform "some string" row justify font xs ys echo inform \"Have a nice day.\" 3 3 1 > FIFO echo inform timeout 3 archive_video [day|day_loop|video.mp4] [today|yesterday|yyyy-mm-dd] archive_still [day|video.mp4] [today|yesterday]yyyy-mm-dd] annotate_text_background_color [none|rrggbb] # rrggbb is hex color value 000000 - ffffff annotate_text_brightness value # value is integer 0 - 255, 255 default annotate_text_size value # value is integer 6 - 160, 32 default annotate_string [prepend|append] id string annotate_string remove id annotate_string spacechar c fix_thumbs [fix|test] delete_log upgrade quitExamples
echo "motion_enable [on|off|toggle]" > ~/pikrellcam/www/FIFO
echo "still" > ~/pikrellcam/www/FIFO"
echo "record on" > ~/pikrellcam/www/FIFO ... echo "record pause" > ~/pikrellcam/www/FIFO ... echo "record on" > ~/pikrellcam/www/FIFO ... echo "record off" > ~/pikrellcam/www/FIFO
echo "record on 5" > ~/pikrellcam/www/FIFO
echo "record on 10 6" > ~/pikrellcam/www/FIFO
# Use the motion enable currently set, if it is OFF, no video or still. echo "motion trigger" > ~/pikrellcam/www/FIFO" # Force motion enable on for this FIFO command, trigger a record even if motion_enable is OFF. # If there are no other motion direction or burst detects for a motion video, # the web page thumb will be labeled with "FIFO". # A motion still thumb will be labled with "FIFO". echo "motion trigger 1" > ~/pikrellcam/www/FIFO" # Report code string "PIR" in motion-events file and use the motion enable currently set. # If there are no other motion direction or burst detects for a motion video, # the web page thumb will be labeled with "PIR". $ A motion still thumb will be labeled with "PIR". echo "motion trigger 0:PIR" > ~/pikrellcam/www/FIFO"The second usage
echo "motion trigger 1 4 5" > ~/pikrellcam/www/FIFO" # Report code string "laser" in the motion-events file. # If there are no other motion direction or burst detects for this video, # the web page thumb will be labeled with "laser". echo "motion trigger 1:laser 4 5" > ~/pikrellcam/www/FIFO"
echo "fix_thumbs test" > ~/pikrellcam/www/FIFO echo "fix_thumbs fix" > ~/pikrellcam/www/FIFO
#!/bin/bash
echo annotate_text_background_color 808080 > ~/pikrellcam/www/FIFO
echo annotate_text_size 42 > ~/pikrellcam/www/FIFO
# use the ds18b20 script if you actually have a ds18b20 connected to your pi.
# TEMP=`read_ds18b20`, otherwise simulate a temperature.
TEMP="29.1C"
echo annotate_string append id1 _$TEMP > ~/pikrellcam/www/FIFO; sleep 3
echo annotate_string prepend id2 ${HOSTNAME}_ > ~/pikrellcam/www/FIFO; sleep 3
TEMP="30.4C"
echo annotate_string append id1 _$TEMP > ~/pikrellcam/www/FIFO; sleep 3
echo annotate_string remove id2 > ~/pikrellcam/www/FIFO; sleep 3
echo annotate_string remove id1 > ~/pikrellcam/www/FIFO
echo annotate_text_background_color none > ~/pikrellcam/www/FIFO
echo inform \"End of annotate_string demo\" 3 3 1 > ~/pikrellcam/www/FIFO
echo inform timeout 3 > ~/pikrellcam/www/FIFO
Command lines in the file have the form:
frequency time "command"
A minute offset may be added/subracted from the times
dawn sunrise sunset dusk.
If the time is start, the command is executed
once at startup on the day specified
(usually daily)
For all other times, the commands execute when the time occurs while PiKrellCam
is running. This means if you need an initial setting based on a specific
time period (say started during the day versus started at night) when
PiKrellCam is started, you need to have your own script that checks the time.
Such a script can parse the PiKrellCam state file
/run/pikrellcam/state
to get the
current_minute
and compare it to todays sun times from the state file:
dawn sunrise sunset dusk.
Other values in the state file can be used for special actions in at
command scripts.
For the sun times to work, edit ~/.pikrellcam/pikrellcam.conf and set the latitude and longitude values to your location. Check the state file or the log file to check the calculated times.
C - script commands directory full path
I - the PiKrellCam install directory
a - archive directory full path
m - media directory full path
M - mjpeg file full path
P - command FIFO full path
G - log file full path
H - hostname
E - effective user running PiKrellCam
V - video files directory full path
t - thumb files directory full path
v - last video saved full path filename
S - still files directory full path
s - last still saved full path filename
L - timelapse files directory full path
l - timelapse current series filename format: tl_sssss_%%05d.jpg
in timelapse sub directory. If used in any script
arg list, $l must be the last argument.
T - timelapse video full path filename in video sub directory
N - timelapse sequence last number
D - current_minute dawn sunrise sunset dusk
Z - pikrellcam version
If the command string is an internal @command, only the $H substitution variable is
recognized.
Examples
# If no servos, goto position 1 (only 1 position possible with no servos) settings 1: daily start "@preset goto 1 1" # If servos, goto position 3 settings 1 daily start "@preset goto 3 1" daily start "@annotate_string prepend start1 $H_"
Mon-Fri 16:30 "@motion_enable off" Mon-Fri 18:00 "@motion_enable on"
Mon sunrise-5 "@tl_start 60" Fri sunset+5 "@tl_end" Mon-Fri sunset+5 "@tl_hold on" Mon-Fri sunrise-5 "@tl_hold off" Mon-Fri sunrise "@tl_show_status on" Fri sunset+5 "@tl_show_status on"
daily 08:00 "@archive_video day yesterday"Or you could have a custom archive script that does something more complicated like archiving and cleaning out old files. For example, use something like this forum example and have the at-command:
daily 23:00 "$C/do-archive"The do-archive script could be run as an at-command as shown or cron could be used..
daily minute "$C/!ds18b20.py F fifo"
line=`grep motion_enable /run/pikrellcam/state`
motion_state=${line#motion_enable}
The motion_state variable will then be "on" or "off".
When motion_enable is FIFO changed, the new
state should show up in the /run/pikrellcam/state file
within around 100-200 msec.
See the motion_detects_FIFO below if you want to process a continuous stream of motion detects whether or not a motion event is recording.
This file is overwritten with new detect data for each new motion recording and the on_motion_begin command is run immediately after the motion-events file writing begins. The output to the file is flushed after data for each motion detect is written. See script-dist/example-motion-send-alarm2 for an example reading of this file in an on_motion_begin script.
Scripts can determine where motion is in the video frame (by x,y position or motion region number) and then take some action such as sending multicast alarms and/or moving servos.
The format of the file is a header block followed by one or more motion blocks and a final end tag. Inside of motion blocks are the data for each detect during the video.
For example:
<header> to be documented... </header> ... <motion 3.667> f 49 43 57 -2 57 263 1 44 42 53 -4 53 144 2 55 44 61 0 61 119 </motion> <motion 4.100> f 10 36 69 52 86 290 b 949 </motion> <motion 5.120> f 0 0 0 0 0 0 e PIR </motion> <motion 6.000> f 0 0 0 0 0 0 a 45 </motion> ... <end>shows data for a first detect at 3.667 seconds into the video (including precapture). Each line inside a motion block begins with a single character code:
This named pipe fifo is for near real time processing of all PiKrellCam motion detects regardless of motion recording enabled state and so can be a general purpose motion detect front end interface for a user application with its own motion detect policy. If motion video recordings are enabled and there is a configured non-zero confirm gap, then this fifo will report motion events that do not trigger a motion video if the second confirming motion detect required for video recordings did not happen.
This fifo is not intended for use by an on_motion_begin command.
See the
To enable or disable writing all motion detects to the motion_detects_FIFO, send to the command FIFO:
echo "motion_detects_fifo_enable [on|off|toggle]" > ~/pikrellcam/www/FIFOMotion detect data blocks are written to the motion_detects_FIFO in the same format as is written into the
If the enable is "on" it will stay enabled across pikrellcam
restarts until an "off" command or pikrellcam.conf is edited. Once enabled,
pikrellcam tries to write all motion detects into the motion_detects_FIFO
and an external app can read the detects from the motion_detects_FIFO.
The external app can be started by hand, by a command in the
at-commands.conf file, or by cron.
When a "motion_detects_fifo_enable off" command is sent to the command FIFO,
an <off> tag is written to the motion_detects_FIFO so the user app can
know the motion_detects_fifo_enable has been turned off.
Read the example script ~/pikrellcam/scripts-dist/example-motion-detects-fifo for more information. If this script is run by hand from a terminal, a stream of all motion detects is printed.
To test the example script on a Pi running pikrellcam, open a terminal
(SSH terminal if the Pi is headless) and run the example script:
$ ~/pikrellcam/scripts-dist/example-motion-detects-fifo
# The script enables motion_detects_FIFO and motion detects are printed here.
# Terminate the script with ^C or send an off command in another termial:
# $ echo "motion_detects_fifo_enable off" > ~/pikrellcam/www/FIFO
Commands in at-commands.conf can coordinate times when you want
PiKrellCam to have motion recordings and times when you might want to run
a custom motion detect app that reads from the motion_detects_FIFO.
As is done in the example-motion-detects-fifo script, your app can enable
the motion_detects_FIFO or it can be enabled with an at-commands.conf command
before or after your script starts.
And an at-command can turn the motion_detects_FIFO off at a certain time
if you want to signal your app to self terminate.
Multicasting is a network group communication protocol that uses the UDP transport layer which is inherently unreliable (messages may be lost). To address this, the PiKrellCam multicast implementation provides for message retransmission and tagging messages with id numbers that can be acknowledged so loss detection can be implemented. Using either of these mechanisms is optionally up to the user scripts or programs that implement the PiKrellCam LAN multicast system.
PiKrellCam uses a fixed group network IP and port number for multicast communication which user programs must use:
PKC_MULTICAST_GROUP_IP 225.0.0.55 PKC_MULTICAST_GROUP_PORT 22555The scripts-dist directory has examples which can be used as is or as a starting point for more complex programs. To use these pkc-xxx programs, copy them to a bin directory on desktops you will run them from and then they can be run from a terminal or script:
# Turn off motion detection for all PiKrellCams pkc-motion all off # or, "all" is assumed pkc-motion off # Turn on motion detection for two cameras pkc-motion rpi2,rpi4 on
pkc-reboot rpi1
On each Pi you want PiKrellCam to send alarm messages from, the setup is:
Note: the example-motion-send-alarm2 is likely a work in progress.
It is an example of reading the
on_motion_begin $C/motion-send-alarm
Protocol
from_host to_hosts message_type message_body