【问题标题】:highlighting texts separately when extracted from an image从图像中提取文本时分别突出显示文本
【发布时间】:2019-10-18 07:18:57
【问题描述】:

如何分别突出显示从图像中提取的每个文本。

我提供了将图像转换为文本文件的代码,其中使用 tesseract 作为 OCR 技术。

   public class Sample{ 
        public static void main(String[] args) 
        { 
            Tesseract tesseract = new Tesseract(); 
            try { 

                tesseract.setDatapath("D:/Tess4J/tessdata"); 

                String text 
                    = tesseract.doOCR(new File("image.jpg")); 

                System.out.print(text); 
            } 
            catch (TesseractException e) { 
                e.printStackTrace(); 
            } 
        }

【问题讨论】:

    标签: java ocr tesseract


    【解决方案1】:

    我不太清楚“单独从图像中提取的单个文本”是什么意思。但我会猜。 如果要拆分从图像中获取的文本,请使用下一个:

    text.split("some symbol");
    

    然后您可以将零件添加到数组并使用 ANSI 代码为每个零件着色:

    String[] array = text.split("some symbol");
    for(int i=0; i<array.length; i++){
     System.out.print(ANSI_CODE+array[0]);
    }
    

    此帖How to print color in console using System.out.println?将帮助您选择代码

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-25
      • 2016-01-20
      • 2013-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多