Page 6 of 17

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

Posted: 31 Mar 2018, 02:00
by GeneBene
iseahound wrote:@GeneBene Did you download the latest version from https://github.com/iseahound/Vis2/archive/master.zip ? Is there an error message? I just tested Vis2 again on Windows 10 64 bit, new install.
downloaded again and it works great, tried it on images with not that clear text and it still worked, great work :superhappy:

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

Posted: 31 Mar 2018, 10:35
by burque505
Just a quick comparison of Vis2 and Capture2Text on text from the Vis2 github page:
Original text on Vis2 github page (large font):
Vis2 - OCR()
(Capture2Text)
Q’JViSZ - OCRO
(Vis2)
Vis2 - OCROQ
Regards,
burque505

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

Posted: 31 Mar 2018, 14:45
by ferryiol
Very accurate

in the git you write

"Press Alt + Space to get the coordinates of the grey rectangle."

When I do this on windows 10 some little text popups up on upper right of screen that says x y h w but it has no data

can you tell me the steps to make it work ?

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

Posted: 31 Mar 2018, 15:38
by iseahound
@ferryiol I changed

Code: Select all

               Vis2.Graphics.Subtitle.Draw("x: " this.x1() " │ y: " this.y1() " │ w: " this.width() " │ h: " this.height()
to

Code: Select all

Vis2.Graphics.Subtitle.Draw("x: " x " │ y: " y " │ w: " w " │ h: " h
on Github, does latest version fix it?

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

Posted: 31 Mar 2018, 18:29
by drozdman
This is really elaborate. Great work.

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

Posted: 31 Mar 2018, 21:24
by ferryiol
iseahound wrote:@ferryiol I changed

Code: Select all

               Vis2.Graphics.Subtitle.Draw("x: " this.x1() " │ y: " this.y1() " │ w: " this.width() " │ h: " this.height()
to

Code: Select all

Vis2.Graphics.Subtitle.Draw("x: " x " │ y: " y " │ w: " w " │ h: " h
on Github, does latest version fix it?
thank you, works great

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

Posted: 04 Apr 2018, 03:39
by iseahound
UPDATE: Added ImageIdentify() - use it to identify objects in images. Is it useful? probably not. But it is fun to use.

USER WARNING Abuse of ImageIdentify() will get you temporarily IP banned by Google. (<12 hours) If you would like to continue using it after the ban, please sign up for a free google account and get a Cloud Vision API key and input it into the popup. Free 1000 images per month I think.

; Cloud Platform Console Help - Setting up API keys
; Step 1: https://support.google.com/cloud/answer/6158862?hl=en
; Step 2: https://cloud.google.com/vision/docs/before-you-begin

Re: Vis2 - OCR(), ImageIdentify()

Posted: 04 Apr 2018, 12:00
by bhanson
Hi,

I am also having troubles on Windows 10 Home 64-bit.

I have downloaded the latest version from https://github.com/iseahound/Vis2/archive/master.zip

It works in interactive mode, but when I try to use the other methods I get the blank box problem.

Code: Select all

#include <Vis2>  ; Equivalent to #include .\lib\Vis2.ahk


MsgBox % OCR("test.jpg")  ; << Does not work

#c:: OCR()   ; <<  Works perfect!
Esc:: ExitApp
I also tried the WinTitle (using notepad) and URL methods, which also did not work.

I ran the DetectBugs script posted earlier in this thread and I get this error:

https://i.imgur.com/0TZQk5P.png

From here, I did some further digging and this is what I found:

Code: Select all

; Line 2140 of Vis2.ahk
_cmd .= q this.tesseract q " --tessdata-dir " q fast q " " q in q " " q SubStr(out, 1, -4) q
%out% contains only the filename without extension, so the SubStr does not remove the extension (as I think intended?) and instead shortens the actual name.

  • Vis2_screenshot2f379028-4dde-47c6-b9f6-9b3713be8123.bmp
    Vis2_preprocess2f379028-4dde-47c6-b9f6-9b3713be8123.tif
    Vis2_text2f379028-4dde-47c6-b9f6-9b3713be.txt
Is an example of what gets created on my system.

Then %out% is looking for the full file name and this of course does not exist so the exception is thrown.

If I remove the SubStr and append the .txt to %out% then I can get DetectBugs to run.

Code: Select all

_cmd .= q this.tesseract q " --tessdata-dir " q fast q " " q in q " " q out q
;_cmd .= q this.tesseract q " --tessdata-dir " q fast q " " q in q " " q SubStr(out, 1, -4) q

; (...snip...)

out := out . ".txt
And my results are:
  • No text file found. #1
    Test2: No text file found. #2
Regards. :)

[edit] Also, when I run my main script again:

Code: Select all

#include <Vis2>  ; Equivalent to #include .\lib\Vis2.ahk


MsgBox % OCR("test.jpg")  ; << Does not work

#c:: OCR()   ; <<  Works perfect!
Esc:: ExitApp
The file that gets created in my temp has two extensions:

Vis2_text38ed24b5-3fc9-4feb-8a57-b4057148aee2.txt.txt

Re: Vis2 - OCR(), ImageIdentify()

Posted: 04 Apr 2018, 12:30
by burque505
I'm getting the blank box again on Win7, 64-bit also. Version from 3-31-18 still working fine :D
About a missing extension, though - the intermediate file has no extension, it gets processed to text later. That's why your mod is giving you a file with .txt.txt.
Here's what it looks like on my system (in the %temp% folder, after running the 3-31-18 working version):
IntermediateFile.PNG
IntermediateFile.PNG (1.9 KiB) Viewed 6613 times
Regards,
burque505

Re: Vis2 - OCR(), ImageIdentify()

Posted: 04 Apr 2018, 12:59
by iseahound
@bhanson @burque505 It should be fixed now. https://github.com/iseahound/Vis2

EDIT: Also ImageIdentify() will work with input files now. Like ImageIdentify("test.jpg")

Re: Vis2 - OCR(), ImageIdentify()

Posted: 04 Apr 2018, 13:06
by bhanson
iseahound wrote:@bhanson @burque505 It should be fixed now. https://github.com/iseahound/Vis2
Working! :D

Re: Vis2 - OCR(), ImageIdentify()

Posted: 04 Apr 2018, 14:15
by bhanson
I'm getting an error trying to call OCR() on the same bitmap with different coordinate options.

Running OCR() on a bitmap using the 3rd parameter as coordinates seems to destroy the original bitmap.

Code: Select all

#include <Vis2>
; start Gdip:

if !pToken := Gdip_Startup()
{
   MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
   ExitApp
}

bmp := Gdip_CreateBitmapFromFile("test.jpg")


; This works
;MsgBox % OCR(bmp)
;MsgBox % OCR(bmp, , [0, 0, 1000, 120])


; Does not work
MsgBox % OCR(bmp, , [0, 0, 1000, 120])
MsgBox % OCR(bmp)


; Also does not work (what I'm trying to do)
;MsgBox % OCR(bmp, , [0, 0, 1000, 120])
;MsgBox % OCR(bmp, , [0, 138, 1000, 120]
Is this intended?

[edit] I know of course I can clone the portion of the image I want to process before sending to OCR(), but I guess I expected OCR to not modify the source input.

Re: Vis2 - OCR(), ImageIdentify()

Posted: 04 Apr 2018, 17:02
by iseahound
No that is an oversight of mine. It is fixed on GitHub.

Re: Vis2 - OCR(), ImageIdentify()

Posted: 04 Apr 2018, 17:21
by iseahound
Some ImageIdentify() examples:

Code: Select all

MsgBox % ImageIdentify("https://i.imgur.com/ffnoUVR.jpg")
modern art (90%), art (87%), painting (69%), visual arts (61%), paint (61%), acrylic paint (61%), artwork (60%), graphics (57%), graphic design (51%)

Code: Select all

MsgBox % ImageIdentify("https://i.imgur.com/ffnoUVR.jpg",,[113,159,151,91])
orange (92%), fish (92%), product (74%), fish (60%), animal figure (56%)

Fun to play around with. There's a lot of potential. General Question: How are you using Vis2? For me it's basically a toy project. I prefer the GUI, since it allows me to extract text from websites that disallow text selection.

Re: Vis2 - OCR(), ImageIdentify()

Posted: 04 Apr 2018, 18:38
by burque505
Hi, iseahound, this code caused AHK_L 64-bit, 1.1.28.01, to crash, and my Win7 SP1 64-bit computer to lock up completely:

Code: Select all

MsgBox % ImageIdentify("https://i.imgur.com/ffnoUVR.jpg")
Tried it three times, same result, not really ready to do it again :)
Regards,
burque505

Re: Vis2 - OCR(), ImageIdentify()

Posted: 04 Apr 2018, 19:49
by iseahound
I think it works now. I commented out ObjRelease(pStream) in 3 areas, but I don't know why it's causing crashes. Does RtlMoveMemory delete the source data?

Re: Vis2 - OCR(), ImageIdentify()

Posted: 05 Apr 2018, 11:31
by robodesign
iSeaHound: I just tested the script on Win 10 x64 and it works well.

I am having eye-sight issues and I am very interested in such a tool, but I would like the process simplified / automated... I want to have it capture the text underneath the mouse cursor by detecting the line of text underneath, looking at close letters or something. Is it possible?

Best regards, Marius.

Re: Vis2 - OCR(), ImageIdentify()

Posted: 05 Apr 2018, 12:50
by PaulySkating
robodesign wrote:iSeaHound: I just tested the script on Win 10 x64 and it works well.

I am having eye-sight issues and I am very interested in such a tool, but I would like the process simplified / automated... I want to have it capture the text underneath the mouse cursor by detecting the line of text underneath, looking at close letters or something. Is it possible?

Best regards, Marius.
I suspect that is possible because he allows you to do an ocr based on x y w h, so you can detect the xy of the mouse and then do an ocr

Re: Vis2 - OCR(), ImageIdentify()

Posted: 05 Apr 2018, 13:39
by robodesign
Yes, it would be only a matter of identifying the boundaries of the text line underneath the mouse cursor...

Re: Vis2 - OCR(), ImageIdentify()

Posted: 23 Apr 2018, 05:43
by robodesign
Hello, again!

@ iseahound: would this be useful? http://www.danvk.org/2015/01/07/finding ... numpy.html

I found this bit of information trying to understand how this would be done [detect the boundaries of text].