Calculate an average ratio from all frames
This commit is contained in:
parent
ae0c3bfa39
commit
9d235be9da
31
common.sh
31
common.sh
|
@ -53,19 +53,30 @@ axdraw () {
|
||||||
echo "END:$(date '+%s')"
|
echo "END:$(date '+%s')"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_outer_ratio () {
|
get_frame_axis () {
|
||||||
|
cat "${1}" | jq -r '.["'${2}'"]["'${3}'"].'${4}
|
||||||
AX=$(cat "${1}" | jq -r '.["0"]["0"].x')
|
}
|
||||||
AY=$(cat "${1}" | jq -r '.["0"]["0"].y')
|
|
||||||
BX=$(cat "${1}" | jq -r '.["0"]["1"].x')
|
get_outer_ratio_frame () {
|
||||||
BY=$(cat "${1}" | jq -r '.["0"]["1"].y')
|
AX=$(get_frame_axis ${1} ${2} 0 x)
|
||||||
CX=$(cat "${1}" | jq -r '.["0"]["2"].x')
|
AY=$(get_frame_axis ${1} ${2} 0 y)
|
||||||
CY=$(cat "${1}" | jq -r '.["0"]["2"].y')
|
BX=$(get_frame_axis ${1} ${2} 1 x)
|
||||||
DX=$(cat "${1}" | jq -r '.["0"]["3"].x')
|
BY=$(get_frame_axis ${1} ${2} 1 y)
|
||||||
DY=$(cat "${1}" | jq -r '.["0"]["3"].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)
|
ACX=$(echo "${CX}-${AX}" | bc)
|
||||||
DBX=$(echo "${DX}-${BX}" | bc)
|
DBX=$(echo "${DX}-${BX}" | bc)
|
||||||
ACY=$(echo "${AY}-${CY}" | bc)
|
ACY=$(echo "${AY}-${CY}" | bc)
|
||||||
DBY=$(echo "${DY}-${BY}" | bc)
|
DBY=$(echo "${DY}-${BY}" | bc)
|
||||||
echo "scale=4;((${ACY}+${DBY})/2) / ((${ACX}+${DBX})/2)" | 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
|
||||||
}
|
}
|
Loading…
Reference in New Issue