Tesseract.js 507 B

12345678910111213141516171819202122
  1. const createWorker = require('./createWorker');
  2. const recognize = async (image, langs, options) => {
  3. const worker = await createWorker(langs, 1, options);
  4. return worker.recognize(image)
  5. .finally(async () => {
  6. await worker.terminate();
  7. });
  8. };
  9. const detect = async (image, options) => {
  10. const worker = await createWorker('osd', 0, options);
  11. return worker.detect(image)
  12. .finally(async () => {
  13. await worker.terminate();
  14. });
  15. };
  16. module.exports = {
  17. recognize,
  18. detect,
  19. };