标签: hocr

如何使用Tesseract分割文档,然后输出生成的边界框和标签

我正在尝试让Tesseract输出一个带有标记边界框的文件,该边界框来自页面分割(预OCR).我知道它必须能够"开箱即用",因为在ICDAR比赛中显示的结果是参赛者必须分段和各种文件(学术论文在这里).以下是该论文中的一个示例,说明了我想要创建的内容: 分段和标记输出的图像

我已经使用brew构建了最新版本的tesseract brew install tesseract --HEAD,并且一直在尝试编辑位于/usr/local/Cellar/tesseract/HEAD/share/tessdata/configs/输出标记框中的配置文件.使用hocr配置接收的输出,即

tesseract infile.tiff outfile_stem -l eng -psm 1 hocr
Run Code Online (Sandbox Code Playgroud)

给出了一切的边界框,并在class标签中有一些标签,例如

<p class='ocr_par' dir='ltr' id='par_5_82' title="bbox 2194 4490 3842 4589">
    <span class='ocr_line' id='line_5_142' ...
Run Code Online (Sandbox Code Playgroud)

但我无法想象这一点.是否有可视化hOCR文件的标准工具,或者是否可以创建带有Tesseract内置边界框的输出文件?

目前的头版版本详情:

tesseract 3.04.00
 leptonica-1.71
  libjpeg 8d : libpng 1.6.16 : libtiff 4.0.3 : zlib 1.2.5
Run Code Online (Sandbox Code Playgroud)

编辑

我真的希望使用命令行工具实现这一点(如上例所示).@nguyenq指出我的API参考,遗憾的是我没有c ++经验.如果唯一的解决方案是使用API​​,请提供一个快速的python示例吗?

ocr tesseract hocr

30
推荐指数
2
解决办法
2万
查看次数

将hOCR转换为HTML表

我正在寻找一个工具或想法在python中实现,将hOCR文件(由应用程序的tesseract生成)转换为html表.这个想法是利用hOCR文件中的文本位置信息(在bbox属性中提供)来创建基于所提供位置的表.我提供了一个解释上述想法的例子:

我使用SlideShare.net中的这个图像作为我使用tesseract的应用程序的输入,我得到了下面的hOCR/xml文件作为输出.

hOCR文件:

  <div class='ocr_page' id='page_2' title='image "sample_slide.jpg"; bbox 0 0 638 479; ppageno 1'>
   <div class='ocr_carea' id='block_1_1' title="bbox 0 0 638 479">
    <p class='ocr_par' dir='ltr' id='par_1' title="bbox 31 104 620 439">
     <span class='ocr_line' id='line_1' title="bbox 32 104 613 138"><span class='ocrx_word' id='word_1' title="bbox 32 105 119 131">done:</span> <span class='ocrx_word' id='word_2' title="bbox 132 104 262 138">working</span> <span class='ocrx_word' id='word_3' title="bbox 273 105 405 138">product,</span> <span class='ocrx_word' id='word_4' title="bbox 419 104 517 132">hotels</span> <span class='ocrx_word' id='word_5' title="bbox 528 104 613 …
Run Code Online (Sandbox Code Playgroud)

html python tesseract html-table hocr

12
推荐指数
1
解决办法
3547
查看次数

用于可视化的HOCR到HTML

如何将hOCR转换为HTML以进行可视化?

如果打开原始hOCR文件,它只会呈现为纯文本(元素未定位)

html ocr hocr

9
推荐指数
3
解决办法
5003
查看次数

Tesseract的hOCR输出真的包含每个字符的边界框和置信度吗?

Tesseract FAQ中,他们说你可以:

如何获得每个角色的坐标和信心?

有两种选择.如果您不想进入编程,可以使用Tesseract的特殊输出格式(有关详细信息,请参阅Tesseract手册页).

但是当我创建一个示例hOCR输出(它是一个.html文件)时,边界框和置信度仅在单词级别可用.

我在这里错过了什么吗?

我已将示例输入/输出添加为插图(输入已调整大小).


这是输入图像:

在此输入图像描述


这是Tesseract的hOCR输出:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name='ocr-system' content='tesseract'/>
</head>
<body>
<div class='ocr_page' id='page_1' title='image "in2.tif"; bbox 0 0 1882 354'>
<div class='ocr_carea' id='block_1_1' title="bbox 78 59 457 100">
<p class='ocr_par'>
<span class='ocr_line' id='line_1_1' title="bbox 78 61 456 97"><span class='ocr_word' id='word_1_1' title="bbox 78 62 175 97"><span class='ocrx_word' id='xword_1_1' title="x_wconf -2">Dear</span></span> <span class='ocr_word' id='word_1_2' title="bbox 205 62 …
Run Code Online (Sandbox Code Playgroud)

ocr tesseract hocr

6
推荐指数
1
解决办法
9948
查看次数

使用OCR引擎tesseract无法理解提取文档中的坐标

我从tesseract中提取了一个图像文档并且已经提取成功了.但我无法理解提取文件的坐标.

问题描述: -

它显示坐标,但让我知道这些坐标代表像素或其他东西.这些是四个像title ="bbox 10 13 43 46",所以10,13 43和46是什么位置它们代表什么位置

提取后的完整代码

   <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>
</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name='ocr-system' content='tesseract'/>
</head>
<body>
<div class='ocr_page' id='page_1' title='image "D:\ABC.tif"; bbox 0 0 464 101'>
    <div class='ocr_carea' id='block_1_1' title="bbox 10 13 330 55">
    <p 1class='ocr_par'>
        <span class='ocr_line' id='line_1_1' title="bbox 10 13 330 55">
            <span class='ocr_word' id='word_1_1' title="bbox 10 13 43 46">
                <span class='ocrx_word' id='xword_1_1' title="x_wconf -1"><strong>hi</strong></span>
            </span> 
            <span class='ocr_word' id='word_1_2' …
Run Code Online (Sandbox Code Playgroud)

ocr tesseract text-extraction hocr

4
推荐指数
3
解决办法
3731
查看次数

如何使用python-tesseract获取Hocr输出

使用pytesseract我获得了非常好的结果,但是它不能保留双倍空格,它们对我来说真的很重要。而且,所以我决定检索hocr输出而不是纯文本。但是;似乎没有任何方法可以使用pytessearct指定配置文件。

因此,是否可以使用pytesseract指定配置文件,或者是否可以更改一些默认配置文件以获取hocr输出?

#run method from pytessearct.py
def run_tesseract(input_filename, output_filename_base, lang=None, boxes=False, config=None):
    '''
    runs the command:
        `tesseract_cmd` `input_filename` `output_filename_base`

    returns the exit status of tesseract, as well as tesseract's stderr output

    '''
    command = [tesseract_cmd, input_filename, output_filename_base]

    if lang is not None:
        command += ['-l', lang]

    if boxes:
        command += ['batch.nochop', 'makebox']

    if config:
        command += shlex.split(config)
    #command+=['C:\\Program Files (x86)\\Tesseract-OCR\\tessdata\\configs\\hocr']
    #print "command:",command
    proc = subprocess.Popen(command,
            stderr=subprocess.PIPE)
    return (proc.wait(), proc.stderr.read())
Run Code Online (Sandbox Code Playgroud)

tesseract hocr python-tesseract

3
推荐指数
3
解决办法
7708
查看次数