Skip to content

Instantly share code, notes, and snippets.

@justjake
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justjake/9565070 to your computer and use it in GitHub Desktop.
Save justjake/9565070 to your computer and use it in GitHub Desktop.
Convert Titanfall end-of-game scoreboards into text files
#!/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"
@justjake
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment