Files
bettergi-scripts-list/repo/js/AutoPlanDomain/utils/tool.js
yan 0126de556c feat(bgi_tools): 添加BGI工具HTTP配置拉取推送功能
- 实现pullJsonConfig函数用于拉取指定uid的JSON配置数据
- 实现pushAllJsonConfig函数用于推送全部JSON配置数据
- 在配置中添加bgi_tools相关API接口地址配置项
- 新增bgi_tools加载类型支持并添加到加载映射表中
- 更新加载模式界面选项增加bgi_tools加载选项
- 修改加载顺序逻辑支持按优先级排序
- 修复自动域参数初始化时副本轮数传递问题
- 更新多选框组件标签文本增加http获取配置说明
- 添加OCR区域资源释放后的空行格式化调整
2026-02-08 21:07:19 +08:00

34 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 对指定区域进行OCR文字识别
* @param {number} x - 区域左上角x坐标默认为0
* @param {number} y - 区域左上角y坐标默认为0
* @param {number} w - 区域宽度默认为1920
* @param {number} h - 区域高度默认为1080
* @returns {Promise<string|null>} 返回识别到的文本内容如果识别失败则返回null
*/
async function ocrRegion(x = 0,
y = 0,
w = 1920,
h = 1080) {
// 创建OCR识别对象使用指定的坐标和尺寸
let recognitionObjectOcr = RecognitionObject.Ocr(x, y, w,h);
// 捕获游戏区域图像
let region3 = captureGameRegion()
try {
// 在捕获的区域中查找OCR识别对象
let res = region3.find(recognitionObjectOcr);
// 返回识别到的文本内容如果不存在则返回undefined
return res?.text
} catch (e) {
// 捕获并记录错误信息
log.error("识别异常:{1}", e.message)
return null
} finally {
// 确保释放区域资源
region3.Dispose()
}
}
export {
ocrRegion
}