summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-06-11 22:55:48 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-06-11 22:55:48 +0300
commitcf34b77a5f84e552f8cf6f3ce025a0684d651d2c (patch)
tree9f8ded05a64a98de4fcbbadad0ee3b0df59a223e
parent9fb7e0fd02e289456832b8700311c2db080ed6da (diff)
ipcam_motion_worker: move dvr-scan options to config
-rw-r--r--doc/ipcam_motion_worker.md11
-rwxr-xr-xtools/ipcam_motion_worker.sh23
2 files changed, 25 insertions, 9 deletions
diff --git a/doc/ipcam_motion_worker.md b/doc/ipcam_motion_worker.md
index 8a79133..9a5e7b0 100644
--- a/doc/ipcam_motion_worker.md
+++ b/doc/ipcam_motion_worker.md
@@ -14,7 +14,6 @@ Local worker config example:
```
api_url=http://ip:port
camera=1
-threshold=1
```
Remote worker config example:
@@ -22,14 +21,18 @@ Remote worker config example:
remote=1
api_url=http://ip:port
camera=1
-threshold=1
fs_root=/var/ipcam_motion_fs
fs_max_filesize=146800640
```
-Optional fields:
+Optional fields (dvr-scan options):
```
roi_file=roi.txt
+threshold=1
+min_event_length=3s
+downscale_factor=3
+frame_skip=2
+dvr_scan_path=
```
`api_url` must point to `ipcam_server` instance.
@@ -56,4 +59,4 @@ apt-get install python3-opencv
pip3 install drv-scan
```
-Then add to `~/.local/bin` to `$PATH`. \ No newline at end of file
+Then add to `~/.local/bin` to `$PATH`.
diff --git a/tools/ipcam_motion_worker.sh b/tools/ipcam_motion_worker.sh
index c76dacd..7b47cdc 100755
--- a/tools/ipcam_motion_worker.sh
+++ b/tools/ipcam_motion_worker.sh
@@ -157,12 +157,12 @@ do_motion() {
local timecodes=()
if [ -z "$roi_file" ]; then
- timecodes+=($(dvr_scan "$input"))
+ timecodes+=($(do_dvr_scan "$input"))
else
echoinfo "using roi sets from file: ${BOLD}$roi_file"
while read line; do
if ! [[ "$line" =~ ^#.* ]]; then
- timecodes+=("$(dvr_scan "$input" "$line")")
+ timecodes+=("$(do_dvr_scan "$input" "$line")")
fi
done < <(cat "$roi_file")
fi
@@ -174,6 +174,10 @@ do_motion() {
}
dvr_scan() {
+ "${config[dvr_scan_path]}" "$@"
+}
+
+do_dvr_scan() {
local input="$1"
local args=
if [ ! -z "$2" ]; then
@@ -183,7 +187,11 @@ dvr_scan() {
echoinfo "dvr_scan(${BOLD}${input}${RST}${CYAN}): no roi, mt=${config[threshold]}"
fi
time_start
- dvr-scan -q -i "$input" -so --min-event-length 3s -df 3 --frame-skip 2 -t ${config[threshold]} $args | tail -1
+ dvr_scan -q -i "$input" -so \
+ --min-event-length ${config[min_event_length]} \
+ -df ${config[downscale_factor]} \
+ --frame-skip ${config[frame_skip]} \
+ -t ${config[threshold]} $args | tail -1
debug "dvr_scan: finished in $(time_elapsed)s"
}
@@ -224,12 +232,17 @@ if [ -z "$allow_multiple" ] && pidof -o %PPID -x "$(basename "${BASH_SOURCE[0]}"
fi
read_config "$config_file" config
-check_config config "api_url camera threshold"
-
+check_config config "api_url camera"
if [ -n "${config[remote]}" ]; then
check_config config "fs_root fs_max_filesize"
fi
+[ -z "${config[threshold]}" ] && config[threshold]=1
+[ -z "${conifg[min_event_length]}" ] && config[min_event_length]="3s"
+[ -z "${conifg[frame_skip]}" ] && config[frame_skip]=2
+[ -z "${conifg[downscale_factor]}" ] && config[downscale_factor]=3
+[ -z "${conifg[dvr_scan_path]}" ] && config[dvr_scan_path]="dvr-scan"
+
if [ -z "${config[remote]}" ]; then
process_local
else