Implement OCR
This commit is contained in:
parent
1406378c9f
commit
2ac0ff723b
7
main.cjs
7
main.cjs
@ -206,23 +206,24 @@ function getMatchingPhrase(inputString, targetCharacter) {
|
|||||||
}
|
}
|
||||||
checkString = checkString.replace(/[^a-zA-Z0-9]/g, '');
|
checkString = checkString.replace(/[^a-zA-Z0-9]/g, '');
|
||||||
checkLoop(message, checkString);
|
checkLoop(message, checkString);
|
||||||
(async () => {
|
|
||||||
// Does the message have an attachment? Check the attachment with OCR
|
// Does the message have an attachment? Check the attachment with OCR
|
||||||
console.log(message.attachments);
|
console.log(message.attachments);
|
||||||
message.attachments.forEach(i => {
|
message.attachments.forEach(i => {
|
||||||
if (i.contentType.includes("image")) {
|
if (i.contentType.includes("image")) {
|
||||||
const worker = await createWorker('eng');
|
(async () => {
|
||||||
|
const worker = await createWorker('eng');
|
||||||
const ret = await worker.recognize(i.proxyURL);
|
const ret = await worker.recognize(i.proxyURL);
|
||||||
console.log("OCR Results: " + ret.data.text);
|
console.log("OCR Results: " + ret.data.text);
|
||||||
checkString = ret.data.text;
|
checkString = ret.data.text;
|
||||||
await worker.terminate();
|
await worker.terminate();
|
||||||
|
})();
|
||||||
if (checkLoop(message, checkString)) {
|
if (checkLoop(message, checkString)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
checkString = checkString.replace(/[^a-zA-Z0-9]/g, '');
|
checkString = checkString.replace(/[^a-zA-Z0-9]/g, '');
|
||||||
checkLoop(message, checkString);
|
checkLoop(message, checkString);
|
||||||
}
|
}
|
||||||
})();
|
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user