【问题标题】:How to extract multiple lines from an image using Tesseract OCR?如何使用 Tesseract OCR 从图像中提取多行?
【发布时间】:2013-03-04 10:16:47
【问题描述】:
  1. 我们传递了一个带有“Hello World”文本的单行图像,并且 Tesseract OCR 完美地显示了结果“Hello World”。

  2. 但是当我们传递一个带有多行文本的图像时

你好世界
你好吗

什么都不显示。

这是我们的代码:

#include "stdafx.h"
#include <iostream>
#include <baseapi.h>
#include <allheaders.h>
#include <fstream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    tesseract::TessBaseAPI api;

    api.Init("", "eng", tesseract::OEM_DEFAULT);
    api.SetPageSegMode(static_cast<tesseract::PageSegMode>(7));
    api.SetOutputName("out");

    cout<<"File name:";
    char image[256];
    cin>>image;
    PIX   *pixs = pixRead(image);

    STRING text_out;
    api.ProcessPages(image, NULL, 0, &text_out);

    cout<<text_out.string();

    ofstream files;
    files.open("out.txt");
    files << text_out.string()<<endl;
    files.close();

    cin>> image;
    return 0;
}

1 行输入

1 行输出

2 行输入

2 行输出

【问题讨论】:

    标签: visual-studio-2010 visual-c++ ocr tesseract


    【解决方案1】:

    页面分割模式 7 将图像视为单个文本行。尝试 3,即全自动页面分割,但没有 OSD(默认)。

    【讨论】:

      猜你喜欢
      • 2012-05-23
      • 1970-01-01
      • 2020-01-25
      • 2021-09-24
      • 1970-01-01
      • 1970-01-01
      • 2021-04-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多