WIP macos-ocr.js

NPM version CI Test coverage node version npm download

Powered by https://developer.apple.com/documentation/vision/vnrecognizetextrequest

Quick start

$ npm i macos-ocr.js -g

$ ocr path/to/image.png

// result
[
  {
    word: 'Hello world',
    rect: { left: 126, top: 54, width: 326, height: 60 },
    confidence: 0.5
  },
  ...
]

Build swift project

bash ./scripts/build.sh

Run sample

node ./sample/ocr.js

Installment

$ npm i macos-ocr.js --save

Usage

const { macosOcr } = require('macos-ocr.js');
const path = require('path');

(async function main() {
  const result = await macosOcr({
    imageUrl: path.join(__dirname, 'img.png'),
  });
  console.log(result);
})();

// result
[
  {
    word: 'Hello world',
    rect: { left: 126, top: 54, width: 326, height: 60 },
    confidence: 0.5
  },
  ...
]

GitHub

View Github