this post was submitted on 08 Feb 2024
98 points (97.1% liked)
Linux
48389 readers
1085 users here now
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Share the script! Share the script! Share the script! (Nobody will judge you if it is written strangely or is hard to adapt, reading other people’s code is always fun (bash scripts are code fight me))
Hi there, I did say it's easily doable, but I didn't have a script because I run things based on the image before OCR manually (like the negating the dark mode I tried in this script; when doing manually it's just one command as I know whether it's dark mode of not myself; similar for the threshold as well).
But here's a one I made for you:
So the middle part is to accommodate images in dark mode. It negates it based on the threshold that you can change. Without that, you can just have
import
for screen capture,tesseract
for running OCR. and optionally pipe it toxclip
for clipboard ornotify-send
for notification.In my use case, I have keybind to take a screenshot like this:
import png:- | xclip -selection c -t image/png
which gives me the cursor to select part of the screen and copies that to clipboard. I can save that as an image (through another bash script), or paste it directly to messenger applications. And when I need to do OCR, I just runtesseract
in the terminal and copy the text from there.