文字识别 OCR

文字识别(OCR)可以将图片中的文字信息转换为可编辑文本。

感谢 linkecoding 提交本功能

ocr.recognize(img)

新增于:Hamibot 1.2.2

识别图片中的文字。

参数

名称类型描述
imgobject图片,参见 Images

示例

auto.waitFor();
if (!requestScreenCapture()) {
  toastLog('没有授予 Hamibot 屏幕截图权限');
  hamibot.exit();
}
sleep(1000);
log('开始截屏');
const img = captureScreen();
toastLog('开始识别');
const res = ocr.recognize(img);
log(res);
hamibot.exit();

ocr.recognizeText(img)

新增于:Hamibot 1.2.2

识别图片中的文字,只返回文本结果。

参数

名称类型描述
imgobject图片,参见 Images

示例

auto.waitFor();
if (!requestScreenCapture()) {
  toastLog('没有授予 Hamibot 屏幕截图权限');
  hamibot.exit();
}
sleep(1000);
log('开始截屏');
const img = captureScreen();
toastLog('开始识别');
const res = ocr.recognizeText(img);
toastLog(res);
hamibot.exit();