Rank: Advanced Member
Groups: Approved
Joined: 9/13/2018(UTC) Posts: 54 Thanks: 18 times Was thanked: 18 time(s) in 13 post(s)
|
This is simple script, but it works pretty fine
It would be good to use a square gesture
Download files: https://github.com/tesse...tesseract/wiki/Downloads - Tesseract OCR (3.5.1 is stable version) https://github.com/tesseract-ocr/tessdata - .traineddata files
or for better results: https://github.com/tesse...TM#400-alpha-for-windows - Tesseract OCR ("zip file with cppan generated .dll and .exe files" <- hyperlink) https://github.com/tesse...esseract/wiki/Data-Files - .traineddata files
Better update your Microsoft Visual C++ Redistributable before you start.
Folder to create: C:\tesseract-Win64\(create a folder "tessdata" and put .traineddata files in there and do not mix them!)
Issue: Sometimes for some reason if you try to run tesseract from partition other than C:\ you get an error like you don't have traineddata files (even if you placed them correctly).
Command to run tesseract manualy: Get test ocr image from internet run CMD -> go to "tesseract-Win64" folder -> type "tesseract input.png output" (output will be created as ".txt")Code:// FILE PATHS
f_tesseract_exe = "C:\\tesseract-Win64\\tesseract.exe";
f_tmp_img_in = "C:\\tesseract-Win64\\tmp_img_in.png";
f_tmp_txt_out = "C:\\tesseract-Win64\\tmp_txt_out"; // tesseract ocr save txt by default
// GET IMG FROM SCREEN AND SAVE IT IN TESSERACT FOLDER
// some part of code from "Snip Screen Area"
sp.Sleep(100);
var memoryImage = new drawing.System.Drawing.Bitmap(action.Bounds.Width, action.Bounds.Height);
var memoryGraphics = drawing.System.Drawing.Graphics.FromImage(memoryImage);
memoryGraphics.CopyFromScreen(action.Bounds.X, action.Bounds.Y, 0, 0, action.Bounds.Size);
// you could put some code here, like image resize (larger) to get better results
// tesseract ocr does not work very well with small text
memoryImage.Save(f_tmp_img_in); // save image to file
memoryGraphics.Dispose();
memoryImage.Dispose();
// RUN TESSERACT OCR
sp.RunProgram(f_tesseract_exe, f_tmp_img_in + " " + f_tmp_txt_out, "", "", false, true, true);
// OUTPUT FILE
output = File.ReadAllText(f_tmp_txt_out + ".txt");
output = output.trim();
sp.MessageBox(output, "Tesseract ocr");
|
1 user thanked Yuichi for this useful post.
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
I've been thinking myself or someone should bind up a .DLL to handle Tesseract stuff as a Plug-In
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 9/13/2018(UTC) Posts: 54 Thanks: 18 times Was thanked: 18 time(s) in 13 post(s)
|
Plugin will be much better than this mess
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close