Skip to content

Instantly share code, notes, and snippets.

@abserari
Created March 6, 2023 02:18
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 abserari/a3142df43a575ec46d98c55a8dc6c730 to your computer and use it in GitHub Desktop.
Save abserari/a3142df43a575ec46d98c55a8dc6c730 to your computer and use it in GitHub Desktop.
#!/bin/env bash
# Dependencies: tesseract-ocr flameshot imagemagick xclip
#Name: OCR Picture
#Fuction: take a screenshot and OCR the letters in the picture
#Path: /home/Username/...
#you can only scan one character at a time
SCR="/home/Username/pictures/SCR"
mv $SCR.png $SCR.prev.png
# take a shot what you wana to OCR to text
flameshot gui -p $SCR.png
# increase the png
mogrify -modulate 100,0 -resize 400% $SCR.png
# should increase detection rate
# OCR by tesseract
tesseract $SCR.png $SCR &> /dev/null -l eng+chi_sim
# get the text and copy to clipboard
cat $SCR.txt | xclip -selection clipboard
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment