@aspiresys/visor 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ocr.js +2 -1
- package/dist/text.js +3 -2
- package/package.json +1 -1
package/dist/ocr.js
CHANGED
|
@@ -70,7 +70,8 @@ async function extractTextFromRegion(region) {
|
|
|
70
70
|
const result = await worker.recognize(processed, {}, {
|
|
71
71
|
blocks: true,
|
|
72
72
|
hocr: true,
|
|
73
|
-
tsv: true
|
|
73
|
+
tsv: true,
|
|
74
|
+
tessedit_char_whitelist: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.:/@ "
|
|
74
75
|
});
|
|
75
76
|
(0, logger_1.log)("[OCR] Extracted Text:");
|
|
76
77
|
(0, logger_1.log)(result.data.text);
|
package/dist/text.js
CHANGED
|
@@ -43,8 +43,9 @@ async function findText(text, region) {
|
|
|
43
43
|
for (const key in lineGroups) {
|
|
44
44
|
const words = lineGroups[key];
|
|
45
45
|
words.sort((a, b) => a.x - b.x);
|
|
46
|
-
const combinedText = words.map(w => w.text).join(" ");
|
|
47
|
-
|
|
46
|
+
//const combinedText = words.map(w => w.text).join(" ");
|
|
47
|
+
const combinedText = words.map(w => w.text).join(" ").replace(/\s+/g, " ").trim();
|
|
48
|
+
if (combinedText.toLowerCase().replace(/[^a-z0-9 ]/gi, "").includes(text.toLowerCase().replace(/[^a-z0-9 ]/gi, ""))) {
|
|
48
49
|
const minX = Math.min(...words.map(w => w.x));
|
|
49
50
|
const minY = Math.min(...words.map(w => w.y));
|
|
50
51
|
const maxX = Math.max(...words.map(w => w.x + w.width));
|