from easyocr import easyocr


# 创建一个OCR读取器,指定需要识别的语言,例如中文简体和英文
reader = easyocr.Reader(['ch_sim', 'en'])

# 指定要识别的图像文件路径
image_path = 'extracted_20241211_111539chemen_processed_region_processed.jpg'

# 使用readtext方法读取图像中的文字
# 该方法返回一个包含识别结果的列表,每个元素包括文字的位置、内容及置信度分数
results = reader.readtext(image_path)

# 打印识别结果
for res in results:
    bbox, text, confidence = res
    print(f"Bounding box: {bbox}, Text: {text}, Confidence: {confidence:.2f}")
    print("位置:", res[0])  # 文字的位置(矩形区域的四个坐标)
    print("识别文字:", res[1])  # 识别出的文字内容
    print("置信度:", res[2])  # 置信度分数(confidence score)
    print()

Logo

一站式 AI 云服务平台

更多推荐