Calculate an average ratio from all frames

This commit is contained in:
Matt McWilliams 2023-03-14 07:14:59 -04:00
parent ae0c3bfa39
commit 9d235be9da
1 changed files with 21 additions and 10 deletions

View File

@ -53,19 +53,30 @@ axdraw () {
echo "END:$(date '+%s')"
}
get_outer_ratio () {
AX=$(cat "${1}" | jq -r '.["0"]["0"].x')
AY=$(cat "${1}" | jq -r '.["0"]["0"].y')
BX=$(cat "${1}" | jq -r '.["0"]["1"].x')
BY=$(cat "${1}" | jq -r '.["0"]["1"].y')
CX=$(cat "${1}" | jq -r '.["0"]["2"].x')
CY=$(cat "${1}" | jq -r '.["0"]["2"].y')
DX=$(cat "${1}" | jq -r '.["0"]["3"].x')
DY=$(cat "${1}" | jq -r '.["0"]["3"].y')
get_frame_axis () {
cat "${1}" | jq -r '.["'${2}'"]["'${3}'"].'${4}
}
get_outer_ratio_frame () {
AX=$(get_frame_axis ${1} ${2} 0 x)
AY=$(get_frame_axis ${1} ${2} 0 y)
BX=$(get_frame_axis ${1} ${2} 1 x)
BY=$(get_frame_axis ${1} ${2} 1 y)
CX=$(get_frame_axis ${1} ${2} 2 x)
CY=$(get_frame_axis ${1} ${2} 2 y)
DX=$(get_frame_axis ${1} ${2} 3 x)
DY=$(get_frame_axis ${1} ${2} 3 y)
ACX=$(echo "${CX}-${AX}" | bc)
DBX=$(echo "${DX}-${BX}" | bc)
ACY=$(echo "${AY}-${CY}" | bc)
DBY=$(echo "${DY}-${BY}" | bc)
echo "scale=4;((${ACY}+${DBY})/2) / ((${ACX}+${DBX})/2)" | bc
}
get_outer_ratio () {
A=$(get_outer_ratio_frame "${1}" 0)
B=$(get_outer_ratio_frame "${1}" 1)
C=$(get_outer_ratio_frame "${1}" 2)
D=$(get_outer_ratio_frame "${1}" 3)
echo "scale=4;(${A}+${B}+${C}+${D})/4" | bc
}