Get the ratio of the template frame. Add a README.md

This commit is contained in:
Matt McWilliams 2023-03-13 16:35:39 -04:00
parent 5924c65b39
commit ae0c3bfa39
5 changed files with 43 additions and 1 deletions

12
README.md Normal file
View File

@ -0,0 +1,12 @@
# Animation Scripts
This repository contains scripts and other tools for 2D digital to analog anamation.
## fourcell.sh
Example:
```
bash fourcell.sh example.calibration.json dir/of/images output/dir
```

View File

@ -51,4 +51,21 @@ axdraw () {
echo "START:$(date '+%s')"
ax "${1}" 2>&1
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')
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
}

View File

@ -3,7 +3,7 @@
#set -e
if [[ "${1}" == "" ]]; then
echo "Please provide a calibration JSON"
echo "Please provide a template JSON"
fi
if [[ "${2}" == "" ]]; then

5
template_ratio.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
source ./common.sh
get_outer_ratio "${1}"

View File

@ -1,4 +1,7 @@
#!/bin/bash
source ./common.sh
#iWidth 323 = oWidth 404
#iHeight 242 = oHeight 374
@ -7,6 +10,11 @@ SCALE=$(echo "scale=$DIGITS; 323/404" | bc)
OUTER=$(echo "scale=$DIGITS; 374/404" | bc)
RATIO=$(echo "scale=$DIGITS; 242/323" | bc)
# current ratio 1.088
# template ratio 1.291
if [[ "${1}" != "" ]]; then
DPI=${1}
else