人工智能Java SDK - OCR文字識(shí)別工具箱(支持文字識(shí)別,版面分析,表格識(shí)別)
共 3175字,需瀏覽 7分鐘
·
2022-02-09 17:41
目錄:AIAS - AI加速器
文字識(shí)別(OCR)目前在多個(gè)行業(yè)中得到了廣泛應(yīng)用,比如金融行業(yè)的單據(jù)識(shí)別輸入,餐飲行業(yè)中的發(fā)票識(shí)別, 交通領(lǐng)域的車(chē)票識(shí)別,企業(yè)中各種表單識(shí)別,以及日常工作生活中常用的身份證,駕駛證,護(hù)照識(shí)別等等。 OCR(文字識(shí)別)是目前常用的一種AI能力。
OCR工具箱功能:
- 方向檢測(cè),支持4個(gè)文字方向:0度、90度、180度、270度。
2. 圖片旋轉(zhuǎn)
3. 文字識(shí)別,提供三個(gè)模型:mobile模型,light模型,服務(wù)器端大模型。
4. 版面分析(支持5個(gè)類(lèi)別, 用于配合文字識(shí)別,表格識(shí)別的流水線(xiàn)處理)
Text,Title,List,Table,F(xiàn)igure
5. 表格識(shí)別
- 生成html表格
- 生成excel文件
運(yùn)行OCR識(shí)別例子
1.1 文字方向檢測(cè):
- 例子代碼: OcrDetectionExample.java
- 運(yùn)行成功后,命令行應(yīng)該看到下面的信息:
[INFO ] - Result image has been saved in: build/output/detect_result.png
[INFO ] - [
class: "0", probability: 1.00000, bounds: [x=0.073, y=0.069, width=0.275, height=0.026]
class: "0", probability: 1.00000, bounds: [x=0.652, y=0.158, width=0.222, height=0.040]
class: "0", probability: 1.00000, bounds: [x=0.143, y=0.252, width=0.144, height=0.026]
class: "0", probability: 1.00000, bounds: [x=0.628, y=0.328, width=0.168, height=0.026]
class: "0", probability: 1.00000, bounds: [x=0.064, y=0.330, width=0.450, height=0.023]
]- 輸出圖片效果如下:
1.2 文字方向檢測(cè)幫助類(lèi)(增加置信度信息顯示,便于調(diào)試):
- 例子代碼: OcrDetectionHelperExample.java
- 運(yùn)行成功后,命令行應(yīng)該看到下面的信息:
[INFO ] - Result image has been saved in: build/output/detect_result_helper.png
[INFO ] - [
class: "0 :1.0", probability: 1.00000, bounds: [x=0.073, y=0.069, width=0.275, height=0.026]
class: "0 :1.0", probability: 1.00000, bounds: [x=0.652, y=0.158, width=0.222, height=0.040]
class: "0 :1.0", probability: 1.00000, bounds: [x=0.143, y=0.252, width=0.144, height=0.026]
class: "0 :1.0", probability: 1.00000, bounds: [x=0.628, y=0.328, width=0.168, height=0.026]
class: "0 :1.0", probability: 1.00000, bounds: [x=0.064, y=0.330, width=0.450, height=0.023]
]- 輸出圖片效果如下:
2. 圖片旋轉(zhuǎn):
每調(diào)用一次rotateImg方法,會(huì)使圖片逆時(shí)針旋轉(zhuǎn)90度。
- 例子代碼: RotationExample.java
3. 文字識(shí)別:
再使用本方法前,請(qǐng)調(diào)用上述方法使圖片文字呈水平(0度)方向。
- 例子代碼: LightOcrRecognitionExample.java
- 運(yùn)行成功
后,命令行應(yīng)該看到下面的信息:
[INFO ] - [
class: "你", probability: -1.0e+00, bounds: [x=0.319, y=0.164, width=0.050, height=0.057]
class: "永遠(yuǎn)都", probability: -1.0e+00, bounds: [x=0.329, y=0.349, width=0.206, height=0.044]
class: "無(wú)法叫醒一個(gè)", probability: -1.0e+00, bounds: [x=0.328, y=0.526, width=0.461, height=0.044]
class: "裝睡的人", probability: -1.0e+00, bounds: [x=0.330, y=0.708, width=0.294, height=0.043]
]- 輸出圖片效果如下:
4. 版面分析:
- 運(yùn)行成功后,命令行應(yīng)該看到下面的信息:
[INFO ] - [
class: "Text", probability: 0.98750, bounds: [x=0.081, y=0.620, width=0.388, height=0.183]
class: "Text", probability: 0.98698, bounds: [x=0.503, y=0.464, width=0.388, height=0.167]
class: "Text", probability: 0.98333, bounds: [x=0.081, y=0.465, width=0.387, height=0.121]
class: "Figure", probability: 0.97186, bounds: [x=0.074, y=0.091, width=0.815, height=0.304]
class: "Table", probability: 0.96995, bounds: [x=0.506, y=0.712, width=0.382, height=0.143]
]- 輸出圖片效果如下:
5. 表格識(shí)別:
- 運(yùn)行成功后,命令行應(yīng)該看到下面的信息:
Methods
R
P
F
FPS
SegLink[26]
70.0
86.0
770
89
PixelLink[4j
73.2
83.0
77.8
...
- 輸出圖片效果如下:
- 生成excel效果如下:
Github & Gitee 代碼地址:
https://github.com/mymagicpower/AIAS/tree/main/1_image_sdks/text_recognition/ocr_sdkhttps://gitee.com/mymagicpower/AIAS/tree/main/1_image_sdks/text_recognition/ocr_sdkAIAS介紹:
Calvin:AIAS (AI Acceleration Suite)人工智能加速器套件介紹0 贊同 · 0 評(píng)論文章評(píng)論
圖片
表情
