nicooprat Posted November 9, 2018 Posted November 9, 2018 (edited) Hi there, Just sharing my first workflow. Some OCR workflow already exist but are relying on some obscur chinese API with exposed personal credentials... This one use your system own installation of `tesseract`. Just take a snapshot and paste the text. The script usually takes no more than a few seconds. https://github.com/nicooprat/alfred-ocr PR welcome. Hope it helps! Edited December 6, 2018 by nicooprat cands, Mike Outram, JJJJ and 3 others 6
bikeNik Posted November 9, 2018 Posted November 9, 2018 (edited) Mega useful for me. Thnx. p.s. I excluded the warning message by Alfred's utility "Replace" with regex: Warning: Invalid resolution.*?\nEstimating resolution.*?\n Edited November 9, 2018 by bikeNik marlowe and paulw 2
crybaby Posted December 4, 2018 Posted December 4, 2018 It doesn't work for me.. I get the error Quote Error, unknown command line argument '-l' Reinstalled tesseract and still have this problem. I am on tesseract 4.0.
nicooprat Posted December 6, 2018 Author Posted December 6, 2018 I recently added the `lang` parameter with `-l` flag: tesseract /tmp/ocr_snapshot.png stdout -l {query} 2>&1 It should allow you to run the command with `OCR fra` for french for example, but it should still work without any parameter. Tried just now and it works (Mac High Sierra & tesseract 3.05.01). Possible solutions: * add a way in the bash script to remove `-l` flag if `{query}` is undefined (don't know how to do this) * downgrade to tesseract 3 as it seems to behave differently in 4 * remove this part in the bash script if you don't need it (see screenshot attached) Hope it helps. ReinaSuo 1
crybaby Posted December 6, 2018 Posted December 6, 2018 Solution no. 3 -- removing said query -- fixed it for me, thanks!
ReinaSuo Posted December 15, 2018 Posted December 15, 2018 I tried the solution No.3. Thanks for sharing. btw I am wondering if it is normal to have "warning" in clipboard. It's very useful for me while recognizing English now. How can I make this work with Chinese?
ReinaSuo Posted December 15, 2018 Posted December 15, 2018 (edited) 1 hour ago, ReinaSuo said: 我尝试了解决方案No.3。感谢分享。顺便说一句我想知道在剪贴板中是否有“警告”是正常的。 现在识别英语对我来说非常有用。我怎样才能用中文做这个工作? I tried `brew install tesseract --with-all-languages` again.😭 Here is what I got: Error: An exception occurred within a child process: Errno::ENOENT: No such file or directory @ rb_sysopen - Edited December 15, 2018 by ReinaSuo
nicooprat Posted December 17, 2018 Author Posted December 17, 2018 On 12/15/2018 at 3:43 PM, ReinaSuo said: I tried the solution No.3. Thanks for sharing. btw I am wondering if it is normal to have "warning" in clipboard. It's very useful for me while recognizing English now. How can I make this work with Chinese? The warning is certainly because you're taking the screenshot on a different monitor than your main one. Can't find anything in Tesseract to avoid this... Simplest workaround is to drag your app window to your main monitor and take the screenshot from there. Results should be much better! By default, Tesseract try to guess language from results, so I guess it should work as is. In the last version of my Alfred script (see https://github.com/nicooprat/alfred-ocr/blob/master/README.md#usage), you can type "OCR [lang]" where "[lang]" is in this list: https://github.com/tesseract-ocr/tesseract/blob/b67ea2c1a70c56053e142a5fb7cc18fb29cdc4b8/src/training/language-specific.sh#L21 On 12/15/2018 at 5:11 PM, ReinaSuo said: I tried `brew install tesseract --with-all-languages` again.😭 Here is what I got: Error: An exception occurred within a child process: Errno::ENOENT: No such file or directory @ rb_sysopen - I can't help with this one, you should seek help on the Tesseract project: https://github.com/tesseract-ocr/tesseract/issues
ReinaSuo Posted December 25, 2018 Posted December 25, 2018 On 2018/12/17 at PM7点49分, nicooprat said: 警告当然是因为您在不同的显示器上拍摄屏幕截图而不是主显示屏。在Tesseract中找不到任何东西以避免这种情况...最简单的解决方法是将您的应用程序窗口拖动到主显示器并从那里截取屏幕截图。结果应该好多了! 默认情况下,Tesseract尝试从结果中猜测语言,所以我猜它应该按原样运行。在我的Alfred脚本的最新版本中(参见https://github.com/nicooprat/alfred-ocr/blob/master/README.md#usage),您可以输入“OCR [lang]”,其中“[lang]”在此列表中:https: //github.com/tesseract-ocr/tesseract/blob/b67ea2c1a70c56053e142a5fb7cc18fb29cdc4b8/src/training/language-specific.sh#L21 我对这个问题无能为力,你应该在Tesseract项目上寻求帮助:https: //github.com/tesseract-ocr/tesseract/issues Thank you very much.
dkgrieshammer Posted December 27, 2018 Posted December 27, 2018 Just a hint to fix the language issue; adding a check if a paramter was given helps in tesseract 4; remember that the language attributes are a little weird (eng for english, deu for german etc.) thanks a lot for the script export PATH=/usr/local/bin/:$PATH screencapture -i /tmp/ocr_snapshot.png if [{query} = ""]; then tesseract /tmp/ocr_snapshot.png stdout 2>&1 else tesseract /tmp/ocr_snapshot.png stdout -l {query} 2>&1 fi
deanishe Posted December 27, 2018 Posted December 27, 2018 7 minutes ago, dkgrieshammer said: eng for english, deu for german etc. ISO 639-2 or ISO 639-3 perhaps?
nicooprat Posted January 3, 2019 Author Posted January 3, 2019 On 12/27/2018 at 9:45 PM, dkgrieshammer said: Just a hint to fix the language issue; adding a check if a paramter was given helps in tesseract 4; remember that the language attributes are a little weird (eng for english, deu for german etc.) thanks a lot for the script export PATH=/usr/local/bin/:$PATH screencapture -i /tmp/ocr_snapshot.png if [{query} = ""]; then tesseract /tmp/ocr_snapshot.png stdout 2>&1 else tesseract /tmp/ocr_snapshot.png stdout -l {query} 2>&1 fi Thanks, merged your pull request but it looks like it just deleted the workflow file. Uploaded a new one with your code, works great! On 12/27/2018 at 9:55 PM, deanishe said: ISO 639-2 or ISO 639-3 perhaps? I don't know, but the full list of supported languages by Tesseract is here: https://github.com/tesseract-ocr/tesseract/blob/b67ea2c1a70c56053e142a5fb7cc18fb29cdc4b8/src/training/language-specific.sh#L21
nicooprat Posted January 10, 2019 Author Posted January 10, 2019 (edited) Someone got this error: `Processing output of 'output.notification' with arg 'read_params_file: Can't open stdout Tesseract Open Source OCR Engine v4.0.0 with Leptonica`. I have no clue what's happening, maybe someone could help here: https://github.com/nicooprat/alfred-ocr/issues/3. Edit: solved, see Github issue. Edited January 10, 2019 by nicooprat
mmroczka Posted February 14, 2020 Posted February 14, 2020 I get the strangest behavior on Catalina. I'd run the workflow and it'd give me no errors, but it'd also give an empty notification saying it was "done" but their wouldn't be anything in my clipboard. It turns out that the screenshot command sort of isn't working on Catalina. It'll run and take a screenshot, but whenever you take a screenshot of something on the computer, it'll actually take a screenshot of your desktop BEHIND the window you're trying to capture. 🤯 Does anyone even know where to begin debugging this? It seems like their is something wrong with the `screenshot` method itself, but isn't that a core library component?
selfmade69 Posted March 11, 2020 Posted March 11, 2020 (edited) This is some insanely productive and underrated plugin. It made my note taking life 10x easier Edited March 11, 2020 by selfmade69 nicooprat and JJJJ 2
Alan He Posted October 1, 2020 Posted October 1, 2020 For chinese,recommend to use baidu ocr, it's free I create a workflow https://github.com/alanhg/alfred-workflows/tree/master/ocr
blueweasley Posted April 13, 2021 Posted April 13, 2021 Hi you all, I ran to a problem. When I run OCR, it does not pop up any info after capturing the image. And in the pasted clipboard this appears: /bin/bash: line 4: tesseract: command not found Do you know what's wrong?
velaia Posted October 10, 2022 Posted October 10, 2022 This can easily be achieved using macOS Shortcuts functionality now. See for example this Shortcut I shared on iCloud: https://www.icloud.com/shortcuts/8f9963c277024df4be2fe91f6a5b7be1
slyfox Posted February 27, 2023 Posted February 27, 2023 Here is a more functional Siri Shortcut with a few changes. https://www.icloud.com/shortcuts/4b7a5e1350c045598ac4e0b78aadb934 Then just connect Alfred with the shortcut.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now