@anytestforpm/ocr 1.3.2 → 1.3.4
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/ocr.js +7 -7
- package/package.json +1 -1
package/ocr.js
CHANGED
|
@@ -6,14 +6,14 @@ var md5 = require('md5');
|
|
|
6
6
|
var configData = null; //configuration file returned by API
|
|
7
7
|
|
|
8
8
|
const OCR_LANGUAGE_MAP = {
|
|
9
|
-
|
|
9
|
+
TH: "vie",
|
|
10
10
|
ID: "ind",
|
|
11
11
|
IN: "hin",
|
|
12
12
|
BR: "por",
|
|
13
13
|
EN: "eng",
|
|
14
14
|
MM: "mya+eng",
|
|
15
15
|
PK: "eng",
|
|
16
|
-
|
|
16
|
+
VN: "tha+eng",
|
|
17
17
|
PH: "eng",
|
|
18
18
|
NG: "eng"
|
|
19
19
|
}
|
|
@@ -131,11 +131,11 @@ export const recognizeOCR = async (ImageUrl) => {
|
|
|
131
131
|
await worker.initialize(OCR_LANGUAGE_MAP[configData.region]);
|
|
132
132
|
|
|
133
133
|
//OCR辨識結果的內文
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
let result = await worker.recognize(ImageUrl);
|
|
135
|
+
let resText = String(result.data.text);
|
|
136
|
+
if (configData.region === "VN") {
|
|
137
|
+
resText = resText.replace(" ","");
|
|
138
|
+
}
|
|
139
139
|
console.log("OCR Text >>> ", resText);
|
|
140
140
|
|
|
141
141
|
//比對不合法的關鍵字
|