当前位置: 首页>>代码示例>>Java>>正文


Java Tesseract.setLanguage方法代码示例

本文整理汇总了Java中net.sourceforge.tess4j.Tesseract.setLanguage方法的典型用法代码示例。如果您正苦于以下问题:Java Tesseract.setLanguage方法的具体用法?Java Tesseract.setLanguage怎么用?Java Tesseract.setLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sourceforge.tess4j.Tesseract的用法示例。


在下文中一共展示了Tesseract.setLanguage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import net.sourceforge.tess4j.Tesseract; //导入方法依赖的package包/类
public static void main(final String[] args) {
  try {
    String _property = System.getProperty("java.io.tmpdir");
    System.out.println(_property);
    String _env = System.getenv("TESSDATA_PREFIX");
    System.out.println(_env);
    Image _image = new Image("d:\\test\\pdf\\test10.png");
    BufferedImage orgin = _image.getAsBufferedImage();
    BufferedImage textImage = ImageHelper.convertImageToGrayscale(orgin);
    int _width = textImage.getWidth();
    int _multiply = (_width * 5);
    int _height = textImage.getHeight();
    int _multiply_1 = (_height * 5);
    BufferedImage _scaledInstance = ImageHelper.getScaledInstance(textImage, _multiply, _multiply_1);
    textImage = _scaledInstance;
    Tesseract instance = Tesseract.getInstance();
    instance.setLanguage("chi_sim");
    System.out.println("instance done");
    String result = instance.doOCR(textImage);
    System.out.println(result);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:East196,项目名称:maker,代码行数:25,代码来源:Tess4Java.java

示例2: recognizeText

import net.sourceforge.tess4j.Tesseract; //导入方法依赖的package包/类
/**
 * Zooms the text image to make it easier to read
 * */
public static String recognizeText(Image image) {
	LibraryLoaderSingleton.getInstance();
	Image scaledImage = image.scale(8);
	Tesseract instance = Tesseract.getInstance(); // JNA Interface Mapping
	instance.setLanguage("eng");
	System.setProperty("jna.encoding", "UTF8");
	instance.setOcrEngineMode(TessAPI.TessOcrEngineMode.OEM_DEFAULT);
	try {
		String result = instance.doOCR(scaledImage.getInnerImage());
		return result;
	} catch (TesseractException e) {
	throw new IllegalStateException(e);
	}
	catch(Exception ex){
		throw new IllegalStateException("An error during text recognition was encountered.");
	}
	
}
 
开发者ID:gpeshterski,项目名称:chart-recognition-library,代码行数:22,代码来源:OCRReader.java

示例3: recognizeYText

import net.sourceforge.tess4j.Tesseract; //导入方法依赖的package包/类
public static String recognizeYText(Image image) {
	LibraryLoaderSingleton.getInstance();
	Image scaledImage = image.scale(8);
	Tesseract instance = Tesseract.getInstance(); // JNA Interface Mapping
	instance.setLanguage("eng");
	System.setProperty("jna.encoding", "UTF8");
	instance.setOcrEngineMode(TessAPI.TessOcrEngineMode.OEM_DEFAULT);
	try {
		String result = instance.doOCR(scaledImage.getInnerImage());
		return result;
	} catch (TesseractException e) {
		throw new IllegalStateException(e);
	}
	catch(Exception ex){
		throw new IllegalStateException("An error during text recognition was encountered.");
	}
	
}
 
开发者ID:gpeshterski,项目名称:chart-recognition-library,代码行数:19,代码来源:OCRReader.java

示例4: main

import net.sourceforge.tess4j.Tesseract; //导入方法依赖的package包/类
public static void main(String[] args){
		try {
			boolean load = true;
			load = false;
//			BufferedImage image = ImageIO.read(new URL("http://www.miitbeian.gov.cn/captcha.jpg")) ;
//			if(load){
//				ImageIO.write(image, "jpg", new File("E:/captcha.jpg") );
//			}else{
//				image = ImageIO.read(new File("D:\\爬虫测试\\yzm\\111.png")) ;
//			}
			BufferedImage image = ImageIO.read(new File("D:\\爬虫测试\\yzm\\11.jpg")) ;
//			image = ImageUtil.grayFilter(image);
			image = ImageUtil.binaryFilter(image);
			image = ImageUtil.lineFilter(image);
//			image = ImageUtil.lineFilter(image);
//			image = ImageUtil.line2Filter(image);
//			image = ImageUtil.point2Filter(image);
//			image = ImageUtil.lineFilter(image);
			image = ImageUtil.meanFilter(image);
//			image = ImageUtil.lineFilter(image);
//			image = ImageUtil.binaryFilter(image);
			
			
			File imageFile = new File("E:/captcha5.jpg");
//			imageFile = new File("E:/test/test.jpg");
			
			ImageIO.write(image, "jpg", imageFile);
			
			Tesseract tesseract = Tesseract.getInstance();
			tesseract.setLanguage("eng");
			String code = tesseract.doOCR(imageFile);

			System.out.println(code);
			
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
 
开发者ID:DMinerJackie,项目名称:JewelCrawler,代码行数:40,代码来源:ImageUtil.java

示例5: detect

import net.sourceforge.tess4j.Tesseract; //导入方法依赖的package包/类
@Override
public String detect(String filePath) {
    File imageFile = new File(filePath);
    Tesseract tess = new Tesseract();

    tess.setLanguage("hun");

    try {
        String result = tess.doOCR(imageFile);
        return result;
    } catch (TesseractException e) {
        return "ERROR";
    }
}
 
开发者ID:gaborvecsei,项目名称:OCR-libraries,代码行数:15,代码来源:TesseractDetection.java

示例6: ocr

import net.sourceforge.tess4j.Tesseract; //导入方法依赖的package包/类
public static String ocr(File file) {
    Tesseract instance = Tesseract.getInstance();  // JNA Interface Mapping
    instance.setDatapath(tessdataPath);
    instance.setLanguage("eng");
    //instance.setLanguage("number");
    String result = "";
    try {
        result = instance.doOCR(file);
    } catch (TesseractException e) {
        System.err.println(e.getMessage());
    } finally {

    }
    return result;
}
 
开发者ID:fivesmallq,项目名称:tesseract-ocr-demo,代码行数:16,代码来源:App.java

示例7: OCRUtil

import net.sourceforge.tess4j.Tesseract; //导入方法依赖的package包/类
public OCRUtil() {
    tesseract = new Tesseract();
    tesseract.setLanguage("captcha");
    tesseract.setPageSegMode(SINGLE_LINE_MODE);
}
 
开发者ID:cqjjjzr,项目名称:BiliLiveLib,代码行数:6,代码来源:OCRUtil.java

示例8: parse

import net.sourceforge.tess4j.Tesseract; //导入方法依赖的package包/类
public static void parse(BufferedImage image) throws Exception {
	Tesseract tesseract = Tesseract.getInstance();
	tesseract.setLanguage(language);
	
	// ImageIO.write(image, "PNG", new File("img/" + System.currentTimeMillis() + ".png"));
	
	String text = tesseract.doOCR(image).trim();
	
	text = text.replaceAll("[^\\w\n.,;!?\'\":»«„”\\(\\) ]", "");
	
	System.out.println(text);
	
	read(text);
}
 
开发者ID:Dakror,项目名称:WebcamParser,代码行数:15,代码来源:Reader.java


注:本文中的net.sourceforge.tess4j.Tesseract.setLanguage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。