forked from kkevsekk1/kkevsekk1.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
118 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,84 @@ | ||
# OCR文档 | ||
>稳定性: | ||
> | ||
> 实验性的函数、模块或特性, | ||
> 在未来的更新中可能会更改或移除。应该谨慎使用这些函数或模块,或者仅用作临时或试验用途。 | ||
# Paddle OCR | ||
**5.6.1 新增** | ||
基于百度飞桨的 OCR | ||
## paddle.ocr(img, path) | ||
- `img` {Image} 图片 | ||
- `path` {String} 自定义模型路径,必须是绝对路径 | ||
- `return` {Array} | ||
|
||
# 基于百度PaddleOCR文字识别 | ||
使用自定义模型进行文字识别 | ||
``` | ||
// files.path() 将相对路径转为绝对路径 | ||
let myModelPath = files.path("./models"); | ||
let result = paddle.ocr(img, myModelPath) | ||
``` | ||
## paddle.ocr(img[, cpuThreadNum=4, useSlim=true]) | ||
- ` img ` {Image} 图片 | ||
- ` cpuThreadNum ` {Number} 识别使用的 CPU 核心数量 | ||
- ` useSlim ` {Boolean} 加载的模型,可选值: | ||
- `true` ocr_v2_for_cpu(slim) :快速模型,默认 | ||
- `false` ocr_v2_for_cpu : 精准模型 | ||
- `return` {Array} | ||
|
||
## paddle.ocrText(img, cpuThreadNum, useSlim); | ||
高精度识别,返回值包含坐标,置信度 | ||
```js | ||
let res = paddle.ocr(img); | ||
toastLog(JSON.stringify(res)) | ||
``` | ||
返回值示例 | ||
```json | ||
[{ | ||
"bounds": { | ||
"bottom": 535, | ||
"left": 348, | ||
"right": 631, | ||
"top": 384 | ||
}, | ||
"confidence": 0.9808736, | ||
"inferenceTime": 188.0, | ||
"preprocessTime": 53.0, | ||
"text": "约定", | ||
"words": "约定" | ||
}] | ||
``` | ||
## paddle.ocrText(img[, cpuThreadNum=4, useSlim=true]) | ||
- ` img ` {Image} 图片 | ||
- ` cpuThreadNum ` {Number} 识别使用的 CPU 核心数量 | ||
- ` useSlim ` {Boolean} 加载的模型,可选值: | ||
- `true` ocr_v2_for_cpu(slim) :快速模型,默认 | ||
- `false` ocr_v2_for_cpu : 精准模型 | ||
- `return` {Array} 字符串数组 | ||
|
||
识别结果为字符串数组 | ||
|
||
## paddle.ocr(img, cpuThreadNum, useSlim); | ||
|
||
识别结果为包含字符串,坐标,置信度等的JSON数组 | ||
|
||
* img {图片对象} 需要识别的图片,可以是`images.captureScreen()`、`images.read(path)`等等 | ||
* cpuThreadNum {number} 识别使用的CPU核心数量,可选参数,默认为4 | ||
* useSlim {布尔} 可选参数,加载的模型,默认true (slim) | ||
|
||
两种模型:ocr_v2_for_cpu与ocr_v2_for_cpu(slim),,前者更快后者更精准 | ||
|
||
以上均为全局函数。 | ||
只返回文本识别信息 | ||
```js | ||
let res = paddle.ocrText(img); | ||
toastLog("识别信息: " + JSON.stringify(res)) | ||
//["约定","最终相遇"] | ||
``` | ||
## paddle.release() | ||
释放 native 内存,非必要,供万一出现内存泄露时使用 | ||
# Tessract OCR | ||
**6.2.9 新增** | ||
前往 github 下载完整例子:[TessractOCR](https://github.com/wilinz/autoxjs-tessocr) | ||
# Google ML kIT OCR | ||
**6.3.4 新增** | ||
## gmlkit.ocr(img,Language) | ||
- `img` {Image} 图片 | ||
- `Language` {String} 识别语言,可选值为: | ||
- `la` 拉丁 | ||
- `zh` 中文 | ||
- `sa` 梵文 | ||
- `ja` 日语 | ||
- `ko` 韩语 | ||
- [更多语言](https://developers.google.cn/ml-kit/vision/text-recognition/v2/languages) | ||
- `retrun` {Object} Json | ||
```JS | ||
//识别中文 | ||
let result = gmlkit.ocr(img, "zh"); | ||
log(result.text) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters