Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #1009913 // Run Tesseract on Screenshot (assumes it's on PATH)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (3622L/26K).

1  
!7
2  
3  
static bool use4dot0 = false;
4  
5  
p {
6  
  S options = "-oem 4"; // Neural Network for "best" traineddata
7  
    // "--tessdata-dir " + platformQuote(userHome("Downloads"));
8  
  
9  
  File tesseract = userHome("local/bin/tesseract");
10  
  if (!fileExists(tesseract) || !use4dot0) {
11  
    tesseract = findCmdOnPATH("tesseract");
12  
    options = "";
13  
  }
14  
  if (tesseract == null) print("Tesseract not found on PATH");
15  
16  
  File png = getProgramFile("screen.png");
17  
  print("Making screenshot.");
18  
  hideConsole(); sleepSeconds(1);
19  
  shootScreenAsPNGFile(png);
20  
  showConsole();
21  
  print("Running Tesseract.");
22  
  time {
23  
    print(backtick(print(platformQuote(tesseract) + " " + platformQuote(png) + " stdout" + " " + options)));
24  
  }
25  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1009913
Snippet name: Run Tesseract on Screenshot (assumes it's on PATH)
Eternal ID of this version: #1009913/12
Text MD5: c17369dc5cad2e7761ae7385779eccfb
Transpilation MD5: 37b3f93b9f20bc4bb3b06e5591184e04
Author: stefan
Category: javax / ocr
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-25 20:31:06
Source code size: 731 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 456 / 977
Version history: 11 change(s)
Referenced in: [show references]