UNPKG

easyocr-wrapper

Version:

EasyOCR wrapper for Node.js using PythonShell

24 lines (19 loc) 543 B
const { PythonShell } = require('python-shell'); const path = require('path'); function runOCR(imagePath, options = {}) { const { gpu = false, lang = ['en'], } = options; return new Promise((resolve, reject) => { const pyshellOptions = { scriptPath: __dirname, args: [imagePath, gpu, ...lang], }; PythonShell.run('ocr.py', pyshellOptions, (err, results) => { if (err) return reject(err); resolve(results ? results : []); }); }); } module.exports = { runOCR };