Works with test command but aspect ratio of produced images seem off
This commit is contained in:
parent
6689e6af45
commit
1ddea3ad56
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd fourcell
|
||||
source env/bin/activate
|
||||
cd ..
|
||||
|
||||
python ./fourcell/apply_image.py "${@}"
|
74
fourcell.sh
74
fourcell.sh
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#set -e
|
||||
|
||||
if [[ "${1}" == "" ]]; then
|
||||
echo "Please provide a calibration JSON"
|
||||
fi
|
||||
|
@ -9,15 +11,79 @@ if [[ "${2}" == "" ]]; then
|
|||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
if [ -f "${1}" ]; then
|
||||
if [ -f "${2}" ]; then
|
||||
echo "Exporting frames from ${2}..."
|
||||
OUTPUT=$(mktemp -d)
|
||||
ffmpeg -y -re -i "${1}" \
|
||||
ffmpeg -y -re -i "${2}" \
|
||||
-q:v 1 -qmin 1 -qmax 1 \
|
||||
"${OUTPUT}/frame_%06d.tif"
|
||||
else
|
||||
OUTPUT="${1}"
|
||||
if [ -d "${2}" ]; then
|
||||
OUTPUT="${2}"
|
||||
else
|
||||
echo "Argument ${2} is neither video nor directory"
|
||||
exit 43
|
||||
fi
|
||||
fi
|
||||
|
||||
tiff_name () {
|
||||
filename=$(basename "${1}")
|
||||
filename="${filename%.*}"
|
||||
echo "${filename}.tif"
|
||||
}
|
||||
|
||||
echo "Using frames in ${OUTPUT}..."
|
||||
|
||||
W=$(cat "${1}" | jq -r ".width")
|
||||
H=$(cat "${1}" | jq -r ".height")
|
||||
DPI=$(echo "${W}/8.5" | bc)
|
||||
FRAMES=$(mktemp)
|
||||
|
||||
echo "DPI: $DPI"
|
||||
|
||||
ls -1 "${OUTPUT}"*.{jpg,jpeg,JPG,JPG,png,PNG,gif,GIF,tif,tiff,TIF,TIFF} > "${FRAMES}" 2> /dev/null
|
||||
FC=$(wc -l < "${FRAMES}")
|
||||
PAGES=$(echo "(${FC}/4)+1" | bc)
|
||||
|
||||
TMP=$(mktemp -d)
|
||||
|
||||
for ((i=0;i<${PAGES};++i)); do
|
||||
f1=$(sed -n "$(((i*4)+1))p" < "${FRAMES}")
|
||||
f2=$(sed -n "$(((i*4)+2))p" < "${FRAMES}")
|
||||
f3=$(sed -n "$(((i*4)+3))p" < "${FRAMES}")
|
||||
f4=$(sed -n "$(((i*4)+4))p" < "${FRAMES}")
|
||||
args=""
|
||||
if [[ "${f1}" != "" ]]; then
|
||||
name=$(tiff_name "${f1}")
|
||||
dest="${TMP}/${name}"
|
||||
bash white_fourcell.sh $DPI "${f1}" "${dest}"
|
||||
args="${args} ${dest}"
|
||||
else
|
||||
continue
|
||||
fi
|
||||
if [[ "${f2}" != "" ]]; then
|
||||
name=$(tiff_name "${f2}")
|
||||
dest="${TMP}/${name}"
|
||||
bash white_fourcell.sh $DPI "${f2}" "${dest}"
|
||||
args="${args} ${dest}"
|
||||
fi
|
||||
if [[ "${f3}" != "" ]]; then
|
||||
name=$(tiff_name "${f3}")
|
||||
dest="${TMP}/${name}"
|
||||
bash white_fourcell.sh $DPI "${f3}" "${dest}"
|
||||
args="${args} ${dest}"
|
||||
fi
|
||||
if [[ "${f4}" != "" ]]; then
|
||||
name=$(tiff_name "${f4}")
|
||||
dest="${TMP}/${name}"
|
||||
bash white_fourcell.sh $DPI "${f4}" "${dest}"
|
||||
args="${args} ${dest}"
|
||||
fi
|
||||
bash apply_image.sh ~/Desktop/page_$i.tiff "${1}" ${args}
|
||||
done
|
||||
|
||||
# x determine dpi
|
||||
# convert frame to white_fourcell
|
||||
|
||||
rm "${FRAMES}"
|
||||
rm -rf "${TMP}"
|
||||
|
|
Loading…
Reference in New Issue