ios - 如何使用 Tesseract OCR 读取身份证上的文字?

标签 ios ocr tesseract

我正在使用 Tesseract 库从身份证信息中读取信息。我得到了每个单词或每一行的置信度分数。

Image Link

Box[0]: x=13, y=12, w=1134, h=57, confidence: 40, text: REPUYBLIQUE FRANCAISE

Box[1]: x=21, y=75, w=1119, h=50, confidence: 42, text:    7  NN99 3W F 59W

Box[2]: x=17, y=137, w=539, h=52, confidence: 30, text:   V7 7  D5 NOM1BOHEL

Box[3]: x=6, y=189, w=954, h=46, confidence: 0, text: 
Box[4]: x=12, y=239, w=1016, h=34, confidence: 40, text:      5   Q  HV2 H CHRISTIANL NICBLE  HBNIOIJE

Box[5]: x=21, y=310, w=975, h=53, confidence: 67, text:   2 E    20 06 1329

Box[6]: x=28, y=372, w=1043, h=83, confidence: 0, text: 
Box[7]: x=11, y=397, w=1147, h=67, confidence: 0, text: 
Box[8]: x=251, y=461, w=837, h=46, confidence: 0, text: 
Box[9]: x=157, y=475, w=1019, h=105, confidence: 0, text: 
Box[10]: x=59, y=648, w=1045, h=32, confidence: 81, text: IDFRADOUEL<<<<<<<<<<<<<<<<<<<<932013

Box[11]: x=57, y=722, w=1047, h=34, confidence: 76, text: 0506932020438CHRISTIANE<<NI2906209F3

这里是使用的代码。

Pix *image = pixRead("/usr/src/tesseract-3.02/phototest.tif");
  tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
  api->Init(NULL, "eng");
  api->SetImage(image);
  Boxa* boxes = api->GetComponentImages(tesseract::RIL_TEXTLINE, true, NULL, NULL);
  printf("Found %d textline image components.\n", boxes->n);
  for (int i = 0; i < boxes->n; i++) {
    BOX* box = boxaGetBox(boxes, i, L_CLONE);
    api->SetRectangle(box->x, box->y, box->w, box->h);
    char* ocrResult = api->GetUTF8Text();
    int conf = api->MeanTextConf();
    fprintf(stdout, "Box[%d]: x=%d, y=%d, w=%d, h=%d, confidence: %d, text: %s",
                    i, box->x, box->y, box->w, box->h, conf, ocrResult);
  }

现在我需要读取身份证中的所有单词。但是我将值 tesseract::RIL_TEXTLINE 设置为 tesseract::RIL_WORD 并运行了代码。即使是图像中没有的文字,我也获得了很高的置信度值。

image link

1.是否使用置信度分数从身份证中读取信息?

1.tesseract OCR 实际返回的置信度分数是多少?

最佳答案

尝试在 Init 调用中添加法语。

关于ios - 如何使用 Tesseract OCR 读取身份证上的文字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25684190/

相关文章:

ocr - Tesseract OCR - 将复选框识别为单词

android - 为什么 Tesseract for Android 在使用 "equ.traineddata"检测数学符号或方程时返回乱码?

c++ - Tesseract baseapi 错误 : 'strncpy' :this function or variable may be unsafe. 考虑改用 strncpy_s

tesseract - 使用 Tesseract-OCR 获取识别字符的字体

iphone - 是 self 释放,释放的实际对象吗?

iphone - 切换icloud帐户时创建永久存储时应用程序崩溃

ios - 如何在swift 4中滚动到 Collection View 中的特定索引?

c# - 如何快速有效地从 'simple' 截图中读取文本?

java - 检测Tesseract OCR Java实现的大字体和小字体

android - 如何根据Flutter Widget中的括号设置宽度