Skip to content

IFeishuTenantV1AIOpticalCharRecognition - 租户AI光学字符识别API ​

功能描述 ​

飞书AI光学字符识别接口,包括识别图片中的文字,按图片中的区域划分,分段返回文本列表。支持租户管理员通过租户访问令牌对图片进行文字识别。

参考文档 ​

函数列表 ​

函数名称功能描述认证方式HTTP 方法
BasicRecognizeImageAsync识别图片中的文字TenantAccessTokenPOST

函数详细内容 ​

BasicRecognizeImageAsync ​

识别图片中的文字

函数签名

csharp
Task<FeishuApiResult<BasicRecognizeImageResult>?> BasicRecognizeImageAsync(
    [Body] BasicRecognizeImageRequest request,
    CancellationToken cancellationToken = default);

认证 TenantAccessToken(租户访问令牌)

参数

参数名类型必填描述示例
requestBasicRecognizeImageRequest✅上传用于AI处理的文件请求体(包含图片base64或URL)-
cancellationTokenCancellationToken⚪取消操作令牌对象default

响应

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "text_list": [
      { "text": "第一段识别文本", "location": { "x": 10, "y": 20, "w": 100, "h": 30 } },
      { "text": "第二段识别文本", "location": { "x": 10, "y": 60, "w": 120, "h": 30 } }
    ]
  }
}

说明

  • 可识别图片中的文字,按图片中的区域划分,分段返回文本列表
  • 文件大小需小于5M

代码示例

csharp
var ocrApi = feishuApp.GetApi<IFeishuTenantV1AIOpticalCharRecognition>();
var request = new BasicRecognizeImageRequest
{
    ImageBase64 = "iVBORw0KGgoAAAANSUhEUgAA..."
};
var result = await ocrApi.BasicRecognizeImageAsync(request);
if (result?.Data?.TextList != null)
{
    foreach (var item in result.Data.TextList)
        Console.WriteLine($"[{item.Location?.X},{item.Location?.Y}] {item.Text}");
}