Appearance
YOLO 模块(yolo)
yolo 模块约定
对当前屏截图检测;区域四元组在前。无默认值,参数均必填。
最短示例:
javascript
yolo.loadModel('model.mlmodel');
const hits = yolo.findClass('button', 0.5, 0.45, 10);
if (hits[0]) auto.click(hits[0].centerX, hits[0].centerY);yolo.loadModel / getModelInfo
typescript
function yolo.loadModel(modelPath: string): Promise<YoloModelInfo>;
function yolo.getModelInfo(): Promise<YoloModelInfo>;返回字段:
| 字段 | 类型 | 描述 |
|---|---|---|
| loaded | boolean | 是否已加载 |
| model / modelPath | string | 模型名 / 路径 |
| classCount | number | 类别数 |
| labels | string[] | 类别名 |
yolo.detect - 目标检测
typescript
function yolo.detect(confidence, iou, limit): Promise<YoloDetection[]>;
function yolo.detect(x1,y1,x2,y2, confidence, iou, limit): Promise<YoloDetection[]>;参数说明:
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
| confidence | number | 是 | - | 置信度阈值 |
| iou | number | 是 | - | IoU 阈值 |
| limit | number | 是 | - | 最多检测数 |
返回字段:
| 字段 | 类型 | 描述 |
|---|---|---|
| label / classIndex / confidence | - | 类别与置信度 |
| x,y,ex,ey,width,height,centerX,centerY | number | 框 |
示例:
javascript
let dets = yolo.detect(0.5, 0.45, 100);
const region = yolo.detect(0, 0, 400, 600, 0.5, 0.45, 100);yolo.findClass - 按类名查找
typescript
function yolo.findClass(className, confidence, iou, limit): Promise<YoloDetection[]>;
function yolo.findClass(x1,y1,x2,y2, className, confidence, iou, limit): Promise<YoloDetection[]>;参数说明:
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
| className | string | 是 | - | 类别名 |
| confidence | number | 是 | - | 置信度阈值 |
| iou | number | 是 | - | IoU 阈值 |
| limit | number | 是 | - | 最多命中数 |
示例:
javascript
let hits = yolo.findClass('person', 0.5, 0.45, 10);