You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
661 B
28 lines
661 B
const createWorker = require('./createWorker'); |
|
|
|
const recognize = async (image, langs, options) => { |
|
const worker = createWorker(options); |
|
await worker.load(); |
|
await worker.loadLanguage(langs); |
|
await worker.initialize(langs); |
|
return worker.recognize(image) |
|
.finally(async () => { |
|
await worker.terminate(); |
|
}); |
|
}; |
|
|
|
const detect = async (image, options) => { |
|
const worker = createWorker(options); |
|
await worker.load(); |
|
await worker.loadLanguage('osd'); |
|
await worker.initialize('osd'); |
|
return worker.detect(image) |
|
.finally(async () => { |
|
await worker.terminate(); |
|
}); |
|
}; |
|
|
|
module.exports = { |
|
recognize, |
|
detect, |
|
};
|
|
|