import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;
import utils.TextUtils;

import java.io.File;

public class Tes_Sign {

    /**
     * 测试单个图片
     *
     * @param args
     */
    public static void main(String[] args) {

        File imageFile = new File("cut/bdc0.jpg");
        if (!imageFile.exists()){
            System.out.println("======== don't find this file! ========");
            return;
        }

        ITesseract iTesseract = new Tesseract();
        iTesseract.setDatapath("./tessdata/");
        iTesseract.setLanguage("eng+chi_sim");

        try {

            String result = iTesseract.doOCR(imageFile);


            System.out.println(TextUtils.clearFormat(result));

//            iTesseract.createDocuments(imageFile.getPath(), "a", Collections.singletonList(ITesseract.RenderedFormat.TEXT));
        } catch (TesseractException e) {
            e.printStackTrace();
        }
    }
}
