Powered by https://developer.apple.com/documentation/vision/vnrecognizetextrequest
$ 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
},
...
]
bash ./scripts/build.sh
node ./sample/ocr.js
$ npm i macos-ocr.js --save
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
},
...
]