Page 3 of 17

Re: Vis2 - OCR()

Posted: 06 Jan 2018, 18:13
by iseahound
BoBo wrote:.
I'm unable to reproduce the errors you encountered. For testing, I typically use the following procedure.

1) Add #^w:: MsgBox % OCR("Untitled - Notepad") to the script and run it.
2) Open a new notepad window.
3) Type some things in the notepad window and press #^w.

The text in notepad should be equal to what the MsgBox displays.

Re: Vis2 - OCR()

Posted: 06 Jan 2018, 19:00
by BoBo
iseahound wrote:
BoBo wrote:.
I'm unable to reproduce the errors you encountered. For testing, I typically use the following procedure.

1) Add #^w:: MsgBox % OCR("Untitled - Notepad") to the script and run it.
2) Open a new notepad window.
3) Type some things in the notepad window and press #^w.

The text in notepad should be equal to what the MsgBox displays.
Thx for that quick response. I'll go to bed now (01:00AM here) but will do some further testing. Stay tuned 8-)

Re: Vis2 - OCR()

Posted: 08 Jan 2018, 04:49
by songdg
iseahound wrote:
songdg wrote:If it is possible to conbine the syntax text := OCR("C:\image.png") and text := OCR([0, 0, 430, 150]) to scan an image file in specific region.
I just updated a new version on my GitHub. Redownload it please.

Code: Select all

    #include Vis2.ahk
    MsgBox % OCR("https://i.stack.imgur.com/sFPWe.png", , [0,120,999,999]) ; [x, y, width, height]
   
^ There is a blank parameter, that is for a feature I have not created yet.
Thanks,I've tried your new version,but it seems no response.And I've been installed tesseract-ocr4.0 in my pc,is that the reason.

Re: Vis2 - OCR()

Posted: 08 Jan 2018, 05:39
by iseahound
songdg wrote:.
Could you tell me what you are doing, and what the result is? If you have some code that is not working please show me. Otherwise the above code should work, I just double checked it.

This line of code

Code: Select all

MsgBox % OCR("https://i.stack.imgur.com/sFPWe.png", , [0,325,999,400])
should say: brown dog jumped over the lazy fox.

Re: Vis2 - OCR()

Posted: 11 Jan 2018, 02:14
by songdg
iseahound wrote:
songdg wrote:.
Could you tell me what you are doing, and what the result is? If you have some code that is not working please show me. Otherwise the above code should work, I just double checked it.

This line of code

Code: Select all

MsgBox % OCR("https://i.stack.imgur.com/sFPWe.png", , [0,330,999,400])
should say: brown dog jumped over the lazy fox.
I didn't known the reason why,perhaps I should tried it on another computer.Anyway thanks!

Re: Vis2 - OCR()

Posted: 18 Mar 2018, 03:48
by r2997790
HI Everyone....

Thanks to Iseahound for this _amazing_ fucntion! Super useful.

I'm trying to get it to work with Cyrillic without any luck -- it would be ideal as I don't speak or type Russian -- but need to 'capture' some Russian text. I wouldn't know how to type the characters on the keyboard so this OCR function would be the perfect solution.

Does anyone know if it is possible for it work with foreign character sets?

I've tried to set my keyboard to Russian but when Vis2 parses the text it doesn't paste the right characters to the clipboard -- I am not sure if that is because it's trying to map to Western characters or perhaps it just doesn't recognise the text?

********************************************** Update **********************************************

I've read that Vis2 using Tesseract and I've found the Russian and Ukrainian language files to train the data here: https://github.com/tesseract-ocr/tessdata_best

But I am not sure how to 'active' these libraries / get Vis2 to use this data when analysing the image snippet.

Does anyone have any idea?

Many thanks
R

Re: Vis2 - OCR()

Posted: 19 Mar 2018, 01:24
by iseahound
Additional Language support added.

Using Additional Languages
Go to https://github.com/tesseract-ocr/tessdata_best and place your desired languages in bin/tessdata_best.
Go to https://github.com/tesseract-ocr/tessdata_fast and place your desired languages in bin/tessdata_fast.

Fast is used in the interactive GUI implementation, while best will be used for othe cases. See below for what I mean.

Code: Select all

#c:: OCR(, "fra")      ; French (requires fast fra.traineddata)
#x:: OCR(, "eng+fra")  ; English and French

Code: Select all

MsgBox % OCR("https://i.imgur.com/T7WMxMs.png", "rus+eng")  ; Requires best eng.traineddata and rus.traineddata.
Tested only on my computer. If there are errors, let me know the exact steps to reproduce them.


EDIT: the text you should get

Code: Select all

Да, я и дальше буду
выбирать свое чудо!

Yes, and further | will
choose my (own) miracle!

Re: Vis2 - OCR() - Update: Additional Language Support

Posted: 19 Mar 2018, 02:01
by r2997790
Thank you so much iseahound. I'm going to try it out now.... super super help and much appreciated.

Unlocks a whole new load of opportunity with this tool now!

Re: Vis2 - OCR() - Update: Additional Language Support

Posted: 19 Mar 2018, 02:05
by iseahound
You're welcome! Let me know - I built tesseract 4.0 on my windows machine, so there is a possibility it might not work.

Re: Vis2 - OCR() - Update: Additional Language Support

Posted: 19 Mar 2018, 09:21
by BoBo
Hi iseahound,
unfortunately it didn't work for me. The preview mode is showing the correct/captured area but the function didn't return any text.
I've tried several other options (see below) none of them worked/returned any text [Vis2.ahk/Gdip_All.ahk/AHK1.1.26.x/Win7].
Thx for your support :)

Code: Select all

#r::MsgBox % OCR("https://i.stack.imgur.com/sFPWe.png")
#c::MsgBox % test := OCR()
#g::Vis2.OCR.google()
#m::MsgBox % OCR("C:\Program Files\AHK\Vis2-master\sFPWe.png")
#x::MsgBox % OCR(, "eng+deu")
#k::MsgBox % test := OCR("C:\Program Files\AHK\_Kassenzettel\img20180319_12410579.png",,[0,0,932,3510])

Re: Vis2 - OCR() - Update: Additional Language Support

Posted: 19 Mar 2018, 18:55
by iseahound
I added a new version of tesseract.exe. It should provide Windows 7 support. However, I do not have access to a windows 7 machine, so please report back if it works.

EDIT: Fixed Vis2.OCR.google(), however, you could use, and should use OCR().google()!
I also realigned the saved to clipboard message to be above the preview text. Also, the preview text now displays the correct text copied to clipboard. There was a bug where it wasn't.

Re: Vis2 - OCR() - Update: Additional Language Support

Posted: 20 Mar 2018, 07:16
by r2997790
I didn't work for me yesterday BUT after downloading Iseahound new build overnight it now works with the foreign languages and is even more awesome then before! Thank you so much.

(I had to download new build, including Tesseract... I'm running Windows 10).

Re: Vis2 - OCR() - Update: Additional Language Support

Posted: 20 Mar 2018, 11:16
by iseahound
I appreciate the confirmation, r2997790. Now I'll need Bobo or another windows 7 user to report back if it works for them.

I'm glad people find my pet project to be useful.

Re: Vis2 - OCR() - Update: Additional Language Support

Posted: 20 Mar 2018, 15:19
by burque505
Hi iseahound, I'm not having any luck with Win7 64-bit, AHK_L 1.1.28.00, either 32-bit or 64-bit.
I cloned the github repository and ran a script with the following code (from GitHub):

Code: Select all

#include Vis2.ahk
MsgBox % OCR("https://i.stack.imgur.com/sFPWe.png")
Only a blank message box appears. I visited the link to verify that there is text there to work on, and of course there is.
Regards,
burque505

Edit: I just ran the version from roughly December 4, 2017, and it works fine:
Capture.PNG
Capture.PNG (44.94 KiB) Viewed 6336 times

Re: Vis2 - OCR() - Update: Additional Language Support

Posted: 20 Mar 2018, 17:34
by iseahound
I think you need to have Microsoft Visual C++ 2017 Redistributable (x86) installed. Link: https://aka.ms/vs/15/release/vc_redist.x86.exe

It does bother me that the original executable worked on most versions of windows. I think it probably supported 2013, but I'm not sure how to target that. To be honest, I might be reaching the extent of my current ability

If this does solve the issue, let me know!

Re: Vis2 - OCR() - Update: Additional Language Support

Posted: 20 Mar 2018, 17:42
by BoBo
I'm on android ATM, so can't test it before tomorrow 01:30 PM CET. Stay tuned 8-)

Re: Vis2 - OCR() - Update: Additional Language Support

Posted: 21 Mar 2018, 07:59
by burque505
Hi iseahound, I installed the C++ redistributable from the link, but no luck.
I also tried replacing the bin folder with the bin folder from the December 2017 version, still no luck.
Regards,
burque505

Re: Vis2 - OCR() - Update: Additional Language Support

Posted: 21 Mar 2018, 09:10
by BoBo
Re-installed from here: https://github.com/iseahound/Vis2/archive/master.zip
But once executed, following the instructions here: https://github.com/iseahound/Vis2
... I ended up with the (kinda expected) error message about ~"[tesseract] not compatible with the system ...".
I'd guess it's (still) compiled as a 32bit executable not running on (my) Win 7 64bit with AHKU64.exe :|
Using the tesseract.exe from a few days ago is showing up empty results but won't fail during execution.

Constructive critic:
a) while the "(file in) folder structure" setup is explicitly mentioned/advised here: https://autohotkey.com/boards/viewtopic ... 89#p168389
b) ... it's shown differently here: https://github.com/iseahound/Vis2
c) ... and it extracts from the zip the same way as described in b) not as in a)
:shifty:

Question, why not already provide the file you've advised to create manually (let's name it "my.ahk") ...
  • "Create a new AHK script in the same folder as Vis2.ahk, copying the code below."

Code: Select all

   #include %A_ScriptDir%\lib\Vis2.ahk
    MsgBox % OCR("https://i.stack.imgur.com/sFPWe.png")
... within the zip-archive that gets extracted to Vis2's root folder, while Vis2.ahk itself will be hosted within the lib-folder (together with a local copy of an image and Gdip_All.ahk)
Based on that, the #Include-path within my.ahk would have been adjusted to point to Vis2.ahk in the lib-folder accordingly. All except the "capture text manually"-samples could be already part of my.ahk!
That would provide the user that "WOW"-effect right from scratch, and would decrease the number of support requests bc of errors made by the most error-prone part of scripting: me in front of the keyboard 8-)

Re: Vis2 - OCR() - Update: Additional Language Support

Posted: 21 Mar 2018, 16:57
by BoBo

Re: Vis2 - OCR() - Update: Additional Language Support

Posted: 21 Mar 2018, 21:30
by FabXP
Hello! :-)

Is there any way to use image-files as input?

I mean: Example:
I have a text with smileys in them. I'd like the OCR to translate the smiley to a special word. E.g.:

:geek: -----OCR engine-----> "[smiley-geek]"

So basically I'd like to combine image search with normal OCR. And "train" the OCR engine to translate special graphical elements to special alphanumeric sequences. In other words, I'd like to add "custom characters", which are little image files.

Can this somehow be done with this library?

Sorry for the probable quite newbish question! :roll: :oops:
Thanks for any info or help!!!!
Fab