Add OCR, add configuration

This commit is contained in:
reis
2022-11-11 17:29:15 +00:00
parent 9962e4fe68
commit d70fcde227
7 changed files with 146 additions and 71 deletions

23
server/events/ocr.js Normal file
View File

@@ -0,0 +1,23 @@
import { recognize } from 'node-tesseract-ocr';
import { serialize } from 'bson';
export default async function runOCR(client, eventData) {
const config = {
lang: 'eng',
oem: 3,
psm: 3,
};
const ocrText = await recognize(eventData.url, config);
const jsonData = {
op: 6,
id: eventData.id,
ocrText
};
const bsonData = serialize(jsonData);
client.write(bsonData);
return;
}