1.6.1.6 ocr_detection()

优质
小牛编辑
134浏览
2023-12-01

ocr_detection(self, *args, **kwargs) 方法

Ocr光学字符识别接口,返回识别文本结果
request syntax

ocr_request = OcrRequest(image=image)
ocr_result = vision_client.ocr_detection(ocr_request)

parameters

image :Image 类型,必须, 待识别的带有文本信息的图片

支持的语言代号列表

简体中文英文法语德语西班牙语日语韩语印地语
zh-chsenfrdeesjakohi

返回结果: OcrResult 类型

Field Summary

nametypemeaning
textAngleint待识别文字与中轴线所成的角度
statusCodeint状态码,0表示正常
orientationstring文字朝向(UP, DOWN, LEFT, RIGHT)
languagestring所识别出的语言代码,对应关系见上表
regionsOcrRegion 类型数组识别出的文本结果,包括文本内容以及坐标位置信息

样例

{
    "regions":[
        {
            "boundingBox":"142,196,306,300",
            "lines":[
                {
                    "boundingBox":"237,196,164,16",
                    "text":"COMPANY NAME "
                },
                {
                    "boundingBox":"244,220,144,6",
                    "text":"SLOGAN OF THE GOES HERE "
                },
                {
                    "boundingBox":"142,441,138,14",
                    "text":"DWYANE CLARK "
                },
                {
                    "boundingBox":"184,464,95,8",
                    "text":"GRAPHIC DESIGNER "
                },
                {
                    "boundingBox":"375,479,32,6",
                    "text":"AD DRESS "
                },
                {
                    "boundingBox":"364,489,84,7",
                    "text":"LOcanON, USA "
                }
            ]
        }
    ],
    "statusCode":0,
    "textAngle":0,
    "orientation":"UP",
    "language":"en"
}