ocr-service
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese功能
Features
从图像中提取文字内容,支持多种图像格式和语言。
Extract text content from images, supporting multiple image formats and languages.
调用方式
Calling Method
python
from services.ocr_service.client import OCRServiceClient
client = OCRServiceClient()python
from services.ocr_service.client import OCRServiceClient
client = OCRServiceClient()健康检查
Health check
status = client.health_check()
status = client.health_check()
OCR识别
OCR recognition
image_base64 = client.image_to_base64("/path/to/image.jpg")
result = client.ocr(image_base64)
image_base64 = client.image_to_base64("/path/to/image.jpg")
result = client.ocr(image_base64)
获取识别结果
Get recognition results
texts = result["rec_texts"] # ["识别的文字1", "识别的文字2", ...]
scores = result["rec_scores"] # [0.98, 0.95, ...]
undefinedtexts = result["rec_texts"] # ["Recognized text 1", "Recognized text 2", ...]
scores = result["rec_scores"] # [0.98, 0.95, ...]
undefined返回格式
Return Format
json
{
"doc_preprocessor_res": {"angle": 0},
"dt_polys": [[x1,y1], [x2,y2], ...],
"rec_texts": ["识别的文字1", "识别的文字2"],
"rec_scores": [0.98, 0.95]
}json
{
"doc_preprocessor_res": {"angle": 0},
"dt_polys": [[x1,y1], [x2,y2], ...],
"rec_texts": ["Recognized text 1", "Recognized text 2"],
"rec_scores": [0.98, 0.95]
}字段说明
Field Description
- : 识别出的文字列表
rec_texts - : 每个文字块的置信度
rec_scores - : 检测到的文本区域坐标
dt_polys
- : List of recognized texts
rec_texts - : Confidence score for each text block
rec_scores - : Coordinates of detected text areas
dt_polys