https://github.com/n0bisuke/lineocr
https://github.com/n0bisuke/lineocr
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/n0bisuke/lineocr
- Owner: n0bisuke
- License: mit
- Created: 2019-12-14T02:22:29.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-05T18:07:50.000Z (over 5 years ago)
- Last Synced: 2025-10-21T15:34:19.310Z (9 months ago)
- Language: JavaScript
- Size: 164 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## LINE BRAIN OCR APIの非公式SDKです。
[Node.jsでLINE BRAIN OCR APIを使う](https://qiita.com/n0bisuke/items/00d646685b1cb468e26a)
## 使い方
```bash
npm i @n0bisuke/lineocr
```
公式が作るかもしれないのでネームスペース汚染しないようにこうしておきました。
```example/app.js
'use strict';
const Brain = require('@n0bisuke/lineocr');
const ocr = new Brain(`サービスID`);
const IMAGE_PATH = `./sample.png`; // 画像パス
//DETECTION - 文字領域の検出のみを行います。
ocr.detection(IMAGE_PATH)
.then(res => console.log(res.data)) //成功時
.catch(err => console.log(err.response)); //失敗時
//RECOGNITION - 文字認識のみを行います。もしくは、文字領域の検出と認識を順に行います。
const options = {
entrance: 'detection', //optional: Default value: recognition
// language: 'jp', //optional: Default value: jp
// scaling: false, //optional: Default value: false
// ratePosition: false, //optional: Default value: false
// segments: true //optional: Default value: true
};
ocr.recognition(IMAGE_PATH, options)
.then(res => console.log(res.data)) //成功時
.catch(err => console.log(err.response)); //失敗時
```
```bash
$ node example/app.js
{
words: [ { boundingBox: [Array], lineBreak: false, segments: [Array] } ]
}
{
words: [
{
boundingBox: [Array],
text: '斎場御獄',
confidence: 0.6916899085044861,
lineBreak: false,
segments: [Array]
}
]
}
```
> 
## 依存モジュール
axiosを使ってます。
## エラーが出る時
### `Unknown service`
```
{ errorCode: 'ER400', errorMessage: 'Unknown service' }
```
サービスIDが間違ってます。サンプルに書いている`PMqTDgBsucfsyvi7pJEsbIxMIUeNQWDg`などを指定してもダメです。