Compare commits

...

2 Commits

2 changed files with 86 additions and 19 deletions

View File

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
# echo "#"
# phase 1: take screenshots echo "# phase 1: take screenshots"
# echo "#"
if [ ! -d "screenshots" ]; then if [ ! -d "screenshots" ]; then
mkdir screenshots mkdir screenshots
@ -13,12 +13,12 @@ do
filename=$(basename -- "$file") filename=$(basename -- "$file")
#extension="${filename##*.}" #extension="${filename##*.}"
filename="${filename%.*}" filename="${filename%.*}"
ffmpeg -ss 0 -i $file -vf fps=0.5 ./screenshots/$filename%d.png ffmpeg -ss 0 -i $file -vf fps=0.5 ./screenshots/$filename-%d.png
done done
# echo "#"
# phase 2: img preprocess echo "# phase 2: img preprocess"
# echo "#"
if [ ! -d "preproccessed" ]; then if [ ! -d "preproccessed" ]; then
mkdir preproccessed mkdir preproccessed
@ -28,12 +28,12 @@ do
filename=$(basename -- "$file") filename=$(basename -- "$file")
extension="${filename##*.}" extension="${filename##*.}"
filename="${filename%.*}" filename="${filename%.*}"
convert "$file" -gravity SouthWest -crop 560x60+0+0 -fuzz 12% +transparent "#edf1c9" "preproccessed/$filename.png" convert "$file" -gravity SouthWest -crop 560x48+0+8 -fuzz 12% +transparent "#edf1c9" "preproccessed/$filename.png"
done done
# echo "#"
# phase 3: ocr echo "# phase 3: ocr"
# echo "#"
if [ ! -d "ocr" ]; then if [ ! -d "ocr" ]; then
mkdir ocr mkdir ocr
@ -43,14 +43,14 @@ do
filename=$(basename -- "$file") filename=$(basename -- "$file")
extension="${filename##*.}" extension="${filename##*.}"
filename="${filename%.*}" filename="${filename%.*}"
tesseract $file "ocr/$filename" tesseract $file "ocr/$filename" -c tessedit_char_whitelist=" 0123456789KM/HNW."
sed -i 's/ //g' "ocr/$filename.txt"
done done
# echo "#"
# phase 4: prep for geotagging echo "# phase 4: prep for geotagging"
# echo "#"
if [ ! -d "tagged" ]; then if [ ! -d "tagged" ]; then
mkdir tagged mkdir tagged
fi fi
@ -60,5 +60,38 @@ do
extension="${filename##*.}" extension="${filename##*.}"
filename="${filename%.*}" filename="${filename%.*}"
convert $file "tagged/$filename.jpg" convert $file "tagged/$filename.jpg"
exiftool -overwrite_original -TagsFromFile ./knowngood.jpg -All:All "tagged/$filename.jpg"
done done
exiftool -overwrite_original -TagsFromFile ./knowngood.jpg -All:All "tagged/*.jpg"
echo "#"
echo "# phase 5: if ocr was good, geotag. Otherwise, reject."
echo "#"
goodreads=0
badreads=0
if [ ! -d "badread" ]; then
mkdir badread
fi
find "ocr" -iname "*.txt" -print0 | while read -d $'\0' file
do
filename=$(basename -- "$file")
extension="${filename##*.}"
filename="${filename%.*}"
n=$(grep -Poh "(?<=N)[0-9]{2}\\.[0-9]+" "$file")
w=$(grep -Poh "(?<=W)[0-9]{2}\\.[0-9]+" "$file")
if [ -n "$n" ] && [ -n "$w" ]; then
goodreads=$(($goodreads+1))
echo "$filename was OCR'd well; $goodreads good so far"
exiftool -overwrite_original -gpslatitude="$n" -gpslongitude="-$w" -GPSLatitudeRef="North" -GPSLongitudeRef="West" "tagged/$filename.jpg"
else
badreads=$(($badreads+1))
echo "$filename is not perfect; $badreads bad so far"
mv "tagged/$filename.jpg" "badread/$filename.jpg"
mv "ocr/$filename.txt" "badread/$filename.txt"
mv "preproccessed/$filename.png" "badread/$filename.png"
fi
done
echo "$goodreads good, $badreads bad. accuracy:"
bc <<< "scale=4; goodreads=$goodreads; badreads=$badreads; ratio=100*goodreads/(goodreads+badreads);ratio"

34
bash/thumbnailify.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
if [ ! -f "$@" ]; then
echo "file to thumbnailify plz"
fi
fullfilename=$(basename -- "$@")
extension="${fullfilename##*.}"
filename="${fullfilename%.*}"
pushd $(dirname "$@")
if [ -f "$filename""_thumbless.$extension" ]; then
echo "there's already a _thumbless in here... I think i'm already done?"
exit 1
fi
if [ -f "testframe.mp4" ] || [ -f "thumbnailism.txt" ]; then
echo "my temp files are already here... I think i'm redundant?"
exit 1
fi
echo "file testframe.mp4" > thumbnailism.txt
echo "file $fullfilename" >> thumbnailism.txt
ffmpeg -i "$fullfilename" -ss 1.5 -to 1.51666 testframe.mp4
ffmpeg -f concat -i thumbnailism.txt -c copy output.mp4
mv "$fullfilename" "$filename""_thumbless.$extension"
mv output.mp4 "$fullfilename"
rm thumbnailism.txt
rm testframe.mp4
popd