qr-decoder-js 1.0.4 → 1.0.7
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/README.md +10 -4
- package/README_ZH.md +7 -2
- package/dist/index.d.ts +3 -3
- package/dist/qr-decoder.js +866 -575
- package/dist/qr-decoder.umd.cjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,6 +60,12 @@ Decode a QR code from RGBA image data.
|
|
|
60
60
|
|
|
61
61
|
Both methods return `Promise<DecodeResult>`.
|
|
62
62
|
|
|
63
|
+
By default, decoding uses `mode: 'aggressive'`. It tries the original image,
|
|
64
|
+
red/blue channel contrast rescue, edge sharpening, CLAHE, tilt compensation,
|
|
65
|
+
quiet-zone padding, morphology, Otsu thresholding, local adaptive thresholding,
|
|
66
|
+
and inversion. Use `mode: 'fast'` or `mode: 'balanced'` when lower latency is
|
|
67
|
+
more important than rescue coverage.
|
|
68
|
+
|
|
63
69
|
Common reader options include `tryRotate`, `tryInvert`, `tryHarder`,
|
|
64
70
|
`tryDownscale`, `tryDenoise`, `maxNumberOfSymbols`, `formats`, and
|
|
65
71
|
`characterSet`:
|
|
@@ -97,8 +103,10 @@ On failure, check `success` and read `error`:
|
|
|
97
103
|
## Browser support
|
|
98
104
|
|
|
99
105
|
The target browser must support WebAssembly, `fetch`, `TextDecoder`, and
|
|
100
|
-
`ImageData`. The package
|
|
101
|
-
|
|
106
|
+
`ImageData`. The package uses `zxing-wasm` for QR detection and native
|
|
107
|
+
`TextDecoder` for encoding fallback; it does not use Google ML Kit,
|
|
108
|
+
`compact_enc_det`, or `ced-wasm`. The package is intended for browser
|
|
109
|
+
applications and does not provide a Node.js image adapter.
|
|
102
110
|
|
|
103
111
|
## Development
|
|
104
112
|
|
|
@@ -117,5 +125,3 @@ MIT
|
|
|
117
125
|
This project uses and is inspired by:
|
|
118
126
|
|
|
119
127
|
- [zxing-wasm](https://github.com/Sec-ant/zxing-wasm) for QR code detection.
|
|
120
|
-
- [Google compact_enc_det](https://github.com/google/compact_enc_det) for character encoding detection.
|
|
121
|
-
- [ced-wasm](https://github.com/neichen/ced-wasm), a WebAssembly port of `compact_enc_det`.
|
package/README_ZH.md
CHANGED
|
@@ -58,6 +58,11 @@ const result = await decodeQRImageData(imageData);
|
|
|
58
58
|
|
|
59
59
|
两个方法都返回 `Promise<DecodeResult>`。
|
|
60
60
|
|
|
61
|
+
默认使用 `mode: 'aggressive'`,会依次尝试原图、红/蓝通道对比度增强、锐化、
|
|
62
|
+
CLAHE、倾斜校正、静区补边、形态学修复、Otsu 二值化、局部自适应二值化和反色。
|
|
63
|
+
如果更重视解码延迟而不是困难图片的检出率,可以使用 `mode: 'fast'` 或
|
|
64
|
+
`mode: 'balanced'`。
|
|
65
|
+
|
|
61
66
|
常用选项包括 `tryRotate`、`tryInvert`、`tryHarder`、`tryDownscale`、
|
|
62
67
|
`tryDenoise`、`maxNumberOfSymbols`、`formats` 和 `characterSet`:
|
|
63
68
|
|
|
@@ -94,6 +99,8 @@ interface DecodeResult {
|
|
|
94
99
|
## 浏览器要求
|
|
95
100
|
|
|
96
101
|
目标浏览器需要支持 WebAssembly、`fetch`、`TextDecoder` 和 `ImageData`。
|
|
102
|
+
二维码识别使用 `zxing-wasm`,文本编码回退使用浏览器原生 `TextDecoder`,
|
|
103
|
+
当前不使用 Google ML Kit、`compact_enc_det` 或 `ced-wasm`。
|
|
97
104
|
本包面向浏览器应用,不提供 Node.js 图片解码适配层。
|
|
98
105
|
|
|
99
106
|
## 本地开发
|
|
@@ -113,5 +120,3 @@ MIT
|
|
|
113
120
|
本项目使用或参考了以下开源项目:
|
|
114
121
|
|
|
115
122
|
- [zxing-wasm](https://github.com/Sec-ant/zxing-wasm):用于二维码识别。
|
|
116
|
-
- [Google compact_enc_det](https://github.com/google/compact_enc_det):用于文本编码检测。
|
|
117
|
-
- [ced-wasm](https://github.com/neichen/ced-wasm):`compact_enc_det` 的 WebAssembly 移植版本。
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface DecodeResult {
|
|
|
6
6
|
encoding?: string;
|
|
7
7
|
/** Detected encoding identifier. */
|
|
8
8
|
detectedEncoding?: string | null;
|
|
9
|
-
/** Preprocess version that matched
|
|
9
|
+
/** Preprocess version that matched, such as original, color rescue, adaptive binary, or inverted. */
|
|
10
10
|
version?: string;
|
|
11
11
|
error?: string;
|
|
12
12
|
}
|
|
@@ -14,8 +14,8 @@ export interface DecodeResult {
|
|
|
14
14
|
export interface ReaderOptions {
|
|
15
15
|
/** Rescue depth:
|
|
16
16
|
* - fast: original only (fastest for high-framerate video stream)
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
* - balanced: original + color rescue + sharpening + CLAHE + fast shear + center crop
|
|
18
|
+
* - aggressive: balanced + quiet-zone, dot-matrix, Otsu, adaptive binary, and inverted variants
|
|
19
19
|
*/
|
|
20
20
|
mode?: 'fast' | 'balanced' | 'aggressive';
|
|
21
21
|
formats?: string[];
|