Hi, Iseahound,
Speaking of accuracy, I was thinking of using blacklist and creating two different ocr()'s. One for alpha and one for numeric. Is there a blacklist function like whitelist?
Thank you.
Vis2 - Image to Text OCR()
Re: Vis2 - Image to Text OCR()
Update: There is some heavy development going on at the moment. Going forward, there will be less of a dependence on Tesseract. Just a reminder that this project is not dead.
-
- Posts: 401
- Joined: 30 Sep 2017, 03:59
- Facebook: marius.sucan
- GitHub: mariussucan
- Location: Romania
- Contact:
Re: Vis2 - Image to Text OCR()
Very good to hear this!
Good luck and thank you for developing it further.
Good luck and thank you for developing it further.
Re: Vis2 - Image to Text OCR()
Hi, I like this work very much. Thank you.
My English is not good.
I don't understand how to run this function from a macro I created.
I want to send the coordinates and copy the text. But how.
Thanks.
My English is not good.
I don't understand how to run this function from a macro I created.
I want to send the coordinates and copy the text. But how.
Thanks.
Re: Vis2 - Image to Text OCR()
I tried the tool and it gives excellent result. I hope new development could reduce package size (24 Mo)and dependences
Thank you so much!
Re: Vis2 - Image to Text OCR()
Hello Iseahound, I like your tesseract wrapper and I'am watching your progress since month's. I'am using your library for some experiments with pdf files.
I missed a solution to use my own leptonica and tesseract directory's. More than about 3 times I changed your Vis2.ahk file at this position to the path's I use.
Today I just wanted to write a function in the hope that you find this useful. The function will write's the path of tesseract, tessdata and leptonica_util to an .ini file.
If someone want to use tesseract from your repository the function will write and read relative path's. So you can leave a ready made .ini file in your \lib directory of your repository.
Is this file is deleted or some key are deleted or missed, my function will ask for it.
This is an ini-file with relative paths:
Part1:
Part2:
I missed a solution to use my own leptonica and tesseract directory's. More than about 3 times I changed your Vis2.ahk file at this position to the path's I use.
Code: Select all
class Tesseract {
static leptonica := A_ScriptDir "\bin\leptonica_util\leptonica_util.exe"
static tesseract := A_ScriptDir "\bin\tesseract\tesseract.exe"
static tessdata_best := A_ScriptDir "\bin\tesseract\tessdata_best"
static tessdata_fast := A_ScriptDir "\bin\tesseract\tessdata_fast"
If someone want to use tesseract from your repository the function will write and read relative path's. So you can leave a ready made .ini file in your \lib directory of your repository.
Is this file is deleted or some key are deleted or missed, my function will ask for it.
This is an ini-file with relative paths:
Code: Select all
[leptonica]
exePath=\bin\leptonica_util\leptonica_util.exe
[tesseract]
exePath=\bin\tesseract\tesseract.exe
data_best=\bin\tesseract\tessdata_best
tessdata_fast=\bin\tesseract\tessdata_fast
Code: Select all
class Tesseract {
static leptonica := Vis2.stdlib.paths("leptonica")
static tesseract := Vis2.stdlib.paths("tesseract")
static tessdata_best := Vis2.stdlib.paths("tessdata_best")
static tessdata_fast := Vis2.stdlib.paths("tessdata_fast")
...
Code: Select all
class stdlib {
...
; for user customable paths to leptonica and tesseract
paths(toWhat){
static lastdir
If Instr(toWhat, "leptonica")
{
IniRead, leptonica, % A_ScriptDir "\lib\Vis2.ini", leptonica, exePath
If ( (leptonica="ERROR") or !InStr(leptonica, "leptonica_util.exe") )
{
Vis2.Graphics.Subtitle.Render("You have not specified a path to leptonica_util.exe.`nPlease select the file now!", "t7000 xCenter y5% p1.35% c88EAB6 r8", "s2.23% cBlack")
again:=1
While (again=1)
{
FileSelectFile, leptonica,, C:, Please select leptonica.exe, *.exe
If InStr(leptonica, "leptonica_util.exe")
again=0
}
If Instr(leptonica, A_ScriptDir)
leptonica:= StrReplace(leptonica, A_ScriptDir)
IniWrite, % leptonica, % A_ScriptDir "\lib\Vis2.ini", leptonica, exePath
If ErrorLevel
throw Exception("Can not write to ini file!",, A_ScriptDir "\lib\Vis2.ini")
}
lastDir:= Vis2.stdlib.GetParentDir(leptonica)
return SubStr(leptonica, 1, 1) = "\" ? A_ScriptDir . leptonica : leptonica
}
If Instr(toWhat, "tesseract")
{
IniRead, tesseract, % A_ScriptDir "\lib\Vis2.ini", tesseract, exePath
If ( (tesseract="ERROR") or !InStr(tesseract, "tesseract.exe") )
{
Vis2.Graphics.Subtitle.Render("You have not specified a path to tesseract.exe.`nPlease select the file now!", "t7000 xCenter y5% p1.35% c88EAB6 r8", "s2.23% cBlack")
again:=1
While (again=1)
{
FileSelectFile, tesseract,, % lastDir, Please select tesseract.exe, *.exe
If InStr(tesseract, "tesseract.exe")
again=0
}
If Instr(tesseract, A_ScriptDir)
tesseract:= StrReplace(tesseract, A_ScriptDir)
IniWrite, % tesseract, % A_ScriptDir "\lib\Vis2.ini", tesseract, exePath
If ErrorLevel
throw Exception("Can not write to ini file!",, A_ScriptDir "\lib\Vis2.ini")
}
lastDir:= Vis2.stdlib.GetParentDir(tesseract)
return SubStr(tesseract, 1, 1) = "\" ? A_ScriptDir . tesseract : tesseract
}
If Instr(toWhat, "tessdata_best")
{
IniRead, tessdata_best, % A_ScriptDir "\lib\Vis2.ini", tesseract, data_best
If (tessdata_best="ERROR")
{
Vis2.Graphics.Subtitle.Render("You have not specified a path to tessdata_best.`nPlease select the path now!", "t7000 xCenter y5% p1.35% c88EAB6 r8", "s2.23% cBlack")
again:=1
While (again=1)
{
FileSelectFolder, tessdata_best, % lastDir, 2, Please select path to tessdata_best
again:=ErrorLevel
}
If Instr(tessdata_best, A_ScriptDir)
tessdata_best:= StrReplace(tessdata_best, A_ScriptDir)
IniWrite, % tessdata_best, % A_ScriptDir "\lib\Vis2.ini", tesseract, data_best
If ErrorLevel
throw Exception("Can not write to ini file!",, A_ScriptDir "\lib\Vis2.ini")
}
lastDir:= Vis2.stdlib.GetParentDir(tessdata_best)
return SubStr(tessdata_best, 1, 1) = "\" ? A_ScriptDir . tessdata_best : tessdata_best
}
If Instr(toWhat, "tessdata_fast")
{
IniRead, tessdata_fast, % A_ScriptDir "\lib\Vis2.ini", tesseract, tessdata_fast
If (tessdata_fast="ERROR")
{
Vis2.Graphics.Subtitle.Render("You have not specified a path to tessdata_fast.`nPlease select the path now!", "t7000 xCenter y5% p1.35% c88EAB6 r8", "s2.23% cBlack")
again:=1
While (again=1)
{
FileSelectFolder, tessdata_fast, % lastDir, 2, Please select path to tessdata_fast
again:=ErrorLevel
}
If Instr(tessdata_fast, A_ScriptDir)
tessdata_fast:= StrReplace(tessdata_fast, A_ScriptDir)
IniWrite, % tessdata_fast, % A_ScriptDir "\lib\Vis2.ini", tesseract, tessdata_fast
If ErrorLevel
throw Exception("Can not write to ini file!",, A_ScriptDir "\lib\Vis2.ini")
}
return SubStr(tessdata_fast, 1, 1) = "\" ? A_ScriptDir . tessdata_fast : tessdata_fast
}
}
; small RegEx function to get parent dir from a given string
GetParentDir(Dir){
Return RegExReplace(Dir, "\\[^\\]+$")
}
}
class Text {
Re: Vis2 - Image to Text OCR()
Hi,
First, Iseahound this is a beautiful tool, thank you for that.
Second, is there a way to find coordinate position of string that I am searching for.
Usually there is only one unique string, but somethimes there are few of them on same page.
First, Iseahound this is a beautiful tool, thank you for that.
Second, is there a way to find coordinate position of string that I am searching for.
Usually there is only one unique string, but somethimes there are few of them on same page.
Re: Vis2 - Image to Text OCR()
And one more question is how to increase limit of characters to be able read the whole picture from once?
For now I only get part of the page as a result.
For now I only get part of the page as a result.