tess4j 官方最新demo運行成功記錄

運行結果

在這裏插入圖片描述

安裝步驟

  1. 電腦必須安裝“tesseract-ocr”應用程序,安裝成功後,到相應目錄運行。
    電腦應用程序是提供給JAVA程序調用的
  1. 配置環境變量(此處省略),jar包裏面封裝,必須按照名字來(可修改,不建議修改)。假如CMD運行成功,但是java無法調用,建議重啓eclipse,或者重啓電腦。
    在這裏插入圖片描述
    在這裏插入圖片描述
  1. 安裝dll文件必須的 運行庫
    在這裏插入圖片描述
    在這裏插入圖片描述
  1. main方法測試,或者直接在使用junit直接運行demo測試代碼塊。(需要配置)
    main測試
    Junit測試
package net.sourceforge.tess4j;

import java.io.File;

public class Test {
	private final static String testResourcesDataPath = "src/test/resources/test-data";
	
	public static void main(String[] args) {
		
		String datapath = System.getenv("TESSDATA_PREFIX");
		System.out.println(datapath);
		String JAVA_HOME = System.getenv("JAVA_HOME");
		System.out.println(JAVA_HOME);
		 
		File imageFile = new File(testResourcesDataPath, "eurotext.tif");
		ITesseract instance = new Tesseract();
		instance.setDatapath("D:\\Program Files\\Tesseract-OCR\\tessdata");
		try {
			String result = instance.doOCR(imageFile);
			System.out.println(result);
		} catch (TesseractException e) {
			System.err.println(e.getMessage());
		}
    }
}

所需工具下載地址

tesseract桌面應用程序:https://github.com/UB-Mannheim/tesseract/wiki
微軟常用運行庫合集:http://www.pc6.com/softview/SoftView_104246.html
tess4j github:https://github.com/nguyenq/tess4j
字體庫:https://github.com/tesseract-ocr/tessdata
博主測試工具代碼整體打包:https://download.csdn.net/download/qq471208499/12086601

可能出現錯誤

  1. “找不到指定模塊” :運行庫不匹配
  2. “tess4j Failed loading language ‘eng’”:字體庫不存在
發佈了16 篇原創文章 · 獲贊 10 · 訪問量 2271
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章