2014-02-15 122 views
0

如何从包含英文文本的图像中获取数字值。我正在使用tesseract引擎。Tesseract从文本中读取数字

这是代码:

public static String tesseractOCR(String imgPath, Rectangle rect) { 
    File imageFile = new File(imgPath); 
    Tesseract instance = Tesseract.getInstance(); // JNA Interface Mapping 
    // Tesseract1 instance = new Tesseract1(); // JNA Direct Mapping 
    String result = ""; 
    try { 
     result = instance.doOCR(imageFile, rect);//, new Rectangle(50, 128, 405 - 50, 228 - 128) 
    } catch (TesseractException e) { 
     System.err.println(e.getMessage()); 
    } 
    return result; 
} 

回答

0

正方体将grabb全部来自图像包括字母,数字,etc.So,你需要明确地从所提取的文本中删除非数字值标点符号的字符。你可以使用正则表达式。