# @n0bisuke/lineocr

> [Node.jsでLINE BRAIN OCR APIを使う](https://qiita.com/n0bisuke/items/00d646685b1cb468e26a)

Latest version **0.0.2** (published 2019-12-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @n0bisuke/lineocr
pnpm add @n0bisuke/lineocr
yarn add @n0bisuke/lineocr
bun add @n0bisuke/lineocr
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2019-12-14 |
| First published | 2019-12-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 167.8 KB |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | n0bisuke |
| Keywords | node, line, sdk, ocr |

## Links

- npm: https://www.npmjs.com/package/@n0bisuke/lineocr
- Repository: https://github.com/n0bisuke/lineocr
- Homepage: https://github.com/n0bisuke/lineocr#readme
- Issues: https://github.com/n0bisuke/lineocr/issues
- npm.io page: https://npm.io/package/@n0bisuke/lineocr

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^0.19.0
- [form-data](https://npm.io/package/form-data.md) ^3.0.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2019-12-14
- 0.0.1 — 2019-12-14

## 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]
    }
  ]
}
```

> <img src="https://github.com/n0bisuke/lineocr/blob/master/example/sample.png?raw=true" width="200px">

## 依存モジュール

axiosを使ってます。

## エラーが出る時

### `Unknown service`

```
{ errorCode: 'ER400', errorMessage: 'Unknown service' }
```

サービスIDが間違ってます。サンプルに書いている`PMqTDgBsucfsyvi7pJEsbIxMIUeNQWDg`などを指定してもダメです。

### WIP: ファイルパスが間違ってたときのハンドリング

---
_Source: https://npm.io/package/@n0bisuke/lineocr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
