Now Reading
how do you ocr on a mac utilizing the cli or simply python at no cost

how do you ocr on a mac utilizing the cli or simply python at no cost

2024-01-02 12:20:56

a sort reader reached out about all of my iphone alarms and requested how particularly did I run OCR on my mac. I’m not one to gatekeep, so right here’s how one can get your self a pleasant native ocr ‘service’ that works within the terminal/CLI/python and prices 0 {dollars}:

  • ((by the way in which sharing Shortcuts is really weird which is why I’m having you do that all manually…))
  • (additionally, a lot of the stuff under solely must be accomplished as soon as – after that, truly ocr’ing is simple)
  • open the Shortcuts app in your Functions folder
  • click on the “+” button to create a brand new shortcut
  • in the appropriate sidebar, seek for “extract textual content

  • it is best to see “Extract Textual content from Picture” within the checklist of attainable actions. drag it from the appropriate sidebar into the principle space on the left
  • within the “Extract textual content from …” motion that’s now on the left, click on on the pale “Picture” blue-ish capsule
  • choose “Shortcut Enter

  • you’ll see an enormous “Obtain Any enter from Nowhere” motion seem above the “Extract textual content from Shortcut Enter”. it’s all good, depart it as is
  • in the appropriate sidebar, seek for “copy”. it is best to see “Copy to Clipboard”. drag that motion under the “Extract textual content from …” one
    • dragging the “Copy to …” motion under the “Extract from …” is absolutely annoyingly onerous. simply maintain dragging it actually under and it’ll work sooner or later
  • your remaining setup ought to seem like this:

See Also

  • within the final motion, be sure that after “Copy” it does say “Textual content from Picture”!
  • you’re like virtually accomplished!!
  • within the window title bar, sort stuff to call the shortcut. as a result of I’m from a generation, I like to recommend naming it “extract-text” or “ocr-text” or one thing easy with no areas and all lowercase. sorry. press enter after naming the shortcut in any other case it gained’t keep in mind the identify (…??)

  • okay chances are you’ll be truly accomplished right here I feel
  • check out the shortcut in your terminal:
shortcuts run ocr-text -i <A PATH TO SOME IMAGE>
  • then strive command-V – do you see the ensuing textual content? if sure, you’re good to go!!!
  • from python, you are able to do the next:
import subprocess

file_path = '... some file path ...'
ocr_out = subprocess.check_output(
    f'shortcuts run ocr-text -i "{file_path}"', shell=True
)
print(ocr_out)



Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top