Last active
February 12, 2016 16:57
-
-
Save pauljz/9590a38bcae9b53eceee to your computer and use it in GitHub Desktop.
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 | |
# Install homebrew and dependencies if missing... | |
if ! hash brew 2>/dev/null; then | |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
fi | |
if ! hash tesseract 2>/dev/null; then | |
brew install tesseract | |
fi | |
if ! hash fswatch 2>/dev/null; then | |
brew install fswatch | |
fi | |
if ! hash convert 2>/dev/null; then | |
brew install imagemagick | |
fi | |
while true; do | |
SCREENSHOT=$(fswatch -1 ~/Desktop | grep '/Screen Shot') | |
if [ "$SCREENSHOT" ]; then | |
echo "Running OCR on $SCREENSHOT..." | |
convert "$SCREENSHOT" -resize 300% -set colorspace Gray -separate -average -sigmoidal-contrast 10x60% ~/ss.tif | |
OCR_TEXT=$( | |
tesseract ~/ss.tif stdout 2> /dev/null | | |
sed 's/ //g' | # Remove spaces | |
sed 's/O/0/g' # Replace O with 0 | |
) | |
echo "$OCR_TEXT" | |
echo "$OCR_TEXT" | pbcopy | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment