Skip to content

Instantly share code, notes, and snippets.

@thingsiplay
Created May 13, 2022 17:12
Show Gist options
  • Save thingsiplay/5ff1718479ca49999f0d492cba0bcc66 to your computer and use it in GitHub Desktop.
Save thingsiplay/5ff1718479ca49999f0d492cba0bcc66 to your computer and use it in GitHub Desktop.
ocr - select screen portion and recognize text from non text source such as videos
#!/bin/env bash
input="$(mktemp)"
output="$(mktemp)"
import "$input.png"
tesseract -l eng "$input.png" "$output" 2> /dev/null
cat "$output.txt"
rm -f "$input"
rm -f "$input.png"
rm -f "$output"
rm -f "$output.txt"
@thingsiplay
Copy link
Author

Here is a little and unspectacular script to read text from screen. It uses tesseract to ocr the text and import command from ImageMagick to make a screenshot. Then the script outputs the recognized text to stdout. You could replace the screenshot tool with something else you like, but the script expects the created files.

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