Last active
August 29, 2015 13:57
-
-
Save justjake/9565070 to your computer and use it in GitHub Desktop.
Convert Titanfall end-of-game scoreboards into text files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Converts a titanfall scoreboard from any image format into a TXT document | |
# Uses imagemagick for image magick (apt-get install imagemagick) | |
# Uses tesseract for OCR (apt-get install tesseract-ocr) | |
set -e | |
CONVERT_LOCATION="/tmp/titanfall" | |
in="$1" | |
out="$2" | |
usage () { | |
echo "usage: $0 INPUT_IMAGE OUTPUT_TEXT" | |
exit 1 | |
} | |
if [ -z "$in" ] ; then | |
echo "Needs input file" | |
usage | |
fi | |
if [ -z "$out" ] ; then | |
echo "Needs output file" | |
usage | |
fi | |
mkdir -p "$CONVERT_LOCATION" | |
# prepare the image for OCR | |
convert "$in" \ | |
-normalize -level 0,61%,0.00001 \ | |
-fuzz 30% -fill black -opaque red -fuzz 50% -fill black -opaque green \ | |
-monochrome \ | |
-fill black -draw "rectangle 0,370 544,1200" \ | |
"$CONVERT_LOCATION/latest.jpg" | |
tesseract "$CONVERT_LOCATION/latest.jpg" "$CONVERT_LOCATION/as_text" > /dev/null &2>1 | |
sed '2,${ /^[^0-9]/d }' "$CONVERT_LOCATION/as_text.txt" | sed '/^$/d' > "$out" | |
cat "$out" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This assumes that you're playing the game at 1920x1200 resolution. You will have to adjust the
0,370 544,1200
on L36 to remove the status and prestige icons if you use a different resolution