4h, perl
parent
c21a1506b7
commit
318592fd4d
|
|
@ -1,7 +1,7 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local nonrecent_unix="$(($(_date +%s) - 24 * 60 * 60))" # 1d ago
|
local nonrecent_unix="$(($(_date +%s) - 4 * 60 * 60))" # 4h ago
|
||||||
local nonrecent_ts="$(_date -d @$nonrecent_unix -u +%Y-%m-%dT%H:%M:%SZ)"
|
local nonrecent_ts="$(_date -d @$nonrecent_unix -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||||
|
|
||||||
for uuid in $(
|
for uuid in $(
|
||||||
|
|
@ -54,32 +54,35 @@ main() {
|
||||||
threshold="$max_of_last_n"
|
threshold="$max_of_last_n"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
threshold="$(echo "$threshold + 0.01" | bc)"
|
threshold="$(perl -e "print $threshold + 0.005")"
|
||||||
|
|
||||||
local max_flattened_score=$(echo "${flattened_scores[@]:5:${#flattened_scores[@]}-10}" | tr ' ' '\n' | sort -n | tail -n 1)
|
|
||||||
local has_change=false
|
local has_change=false
|
||||||
|
if [ "${#flattened_scores[@]}" -lt 10 ]; then
|
||||||
|
has_change=true
|
||||||
|
else
|
||||||
|
local max_flattened_score=$(echo "${flattened_scores[@]:5:${#flattened_scores[@]}-10}" | tr ' ' '\n' | sort -n | tail -n 1)
|
||||||
if [[ "${max_flattened_score#*.}" > "${threshold#*.}" ]]; then
|
if [[ "${max_flattened_score#*.}" > "${threshold#*.}" ]]; then
|
||||||
has_change=true
|
has_change=true
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if $has_change; then
|
if $has_change; then
|
||||||
echo "$uuid.$recording" >> /tmp/movement_detection_via_api_ffmpeg.sh.txt
|
echo "$uuid.$recording" >> /tmp/movement_detection_via_api_ffmpeg.sh.txt
|
||||||
else
|
else
|
||||||
echo no movement in "$recording"
|
echo no movement in "$recording"
|
||||||
api "/api/cameras/$uuid/$stream/view.mp4" \
|
echo api "/api/cameras/$uuid/$stream/view.mp4" \
|
||||||
-X DELETE \
|
-X DELETE \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
-d "$(printf '{"runStartId": %s}' "$recording")"
|
-d "$(printf '{"runStartId": %s}' "$recording")"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
break
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
api() {
|
api() {
|
||||||
local path="$1"
|
local path="$1"
|
||||||
shift
|
shift
|
||||||
curl -sS "${CAMS_URL:-https://cams.inhome.blapointe.com}/${path#/}" "$@"
|
curl -sS "${CAMS_URL:-http://192.168.0.86:29898}/${path#/}" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
_date() {
|
_date() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue