Implement OCR
This commit is contained in:
parent
e36007ef50
commit
4aa533ad71
10
main.cjs
10
main.cjs
@ -210,13 +210,12 @@ function getMatchingPhrase(inputString, targetCharacter) {
|
||||
console.log(message.attachments);
|
||||
message.attachments.forEach(i => {
|
||||
if (i.contentType.includes("image")) {
|
||||
//(async () => {
|
||||
const worker = createWorker('eng');
|
||||
const ret = worker.recognize(i.proxyURL);
|
||||
(async () => {
|
||||
const worker = await createWorker('eng');
|
||||
const ret = await worker.recognize(i.proxyURL);
|
||||
console.log("OCR Results: " + ret.data.text);
|
||||
checkString = ret.data.text;
|
||||
worker.terminate();
|
||||
//})();
|
||||
await worker.terminate();
|
||||
console.log("Checking OCR contents...");
|
||||
if (checkLoop(message, checkString)) {
|
||||
return;
|
||||
@ -224,6 +223,7 @@ function getMatchingPhrase(inputString, targetCharacter) {
|
||||
checkString = checkString.replace(/[^a-zA-Z0-9]/g, '');
|
||||
checkLoop(message, checkString);
|
||||
}
|
||||
})();
|
||||
});
|
||||
}
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user