I was just messing around with tesseract lately and thought I'd share some fun one-liners..

So go ahead and install the below packages on your Ubuntu-based system:

sudo apt install -y gnome-screenshot flameshot translate-shell tesseract-ocr

# and install a language file for tesseract...for example, how about the Vietnamese file?
sudo apt install -y tesseract-ocr-vie

# and finally install a clipboard package depending on your display server:
# sudo apt install -y xclip
# sudo apt install -y wl-clipboard

Fun time:

EDIT: I don't know why Lemmy keeps changing my ampersands to & either, so please note that in the below examples:

# with flameshot, select text in a image and convert to text, copy to clipboard
flameshot gui --raw | tesseract stdin stdout | xclip -sel c

# same thing, on wayland
flameshot gui --raw | tesseract stdin stdout | wl-copy

# same thing, with gnome-screenshot on X
gnome-screenshot -af /tmp/scrot.png && tesseract /tmp/scrot.png stdout | xclip -sel c

# specifying english or vietnamese input to help tesseract out
flameshot gui --raw | tesseract stdin stdout -l "vie+eng" | xclip -sel c

# translating from vietnamese to english after converting from image to text, and outputting the translation
gnome-screenshot -af /tmp/scrot.png && tesseract /tmp/scrot.png stdout -l vie | trans -b vi:en

# same thing, without auto-correct
gnome-screenshot -af /tmp/scrot.png && tesseract /tmp/scrot.png stdout -l vie | trans -b vi:en -no-autocorrect

# same thing, but with auto-correct, and this time showing the output AND copying to the clipboard
gnome-screenshot -af /tmp/scrot.png && tesseract /tmp/scrot.png stdout -l vie | trans -b vi:en | tee /dev/tty | xclip -sel c

Image to text, with translation? Don't mind if I do...