我正在扫描单个字母和数字。所有数字都应解析为数字[]。但是它总是捕获异常。例如:结果为“ 3”,但由于某种原因我无法对其进行解析。我还尝试使用if语句检查它是否实际上是“ 3”,但是我还返回了一个假。有人可以解释一下为什么它不起作用吗?
File imageFile = new File("C:\\Users\\Nils\\IdeaProjects\\untitled8\\Images\\Cutted\\"+i+m+".png");
ITesseract instance = new Tesseract(); // JNA Interface Mapping
// ITesseract instance = new Tesseract1(); // JNA Direct Mapping
instance.setDatapath("C:/Users/Nils/Desktop/blum/Tess4J/tessdata"); // path to tessdata directory
try {
String result = instance.doOCR(imageFile);
try {
resultI=Integer.parseInt(result);
numbers[0] = resultI;
}catch (NumberFormatException e){
numbers[0]=0;
}
} catch (TesseractException e) {
System.err.println(e.getMessage());
}