@mikashboks/capture-intelligence-core 0.1.0
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/cjs/__fixtures__/address-flow.fixtures.d.ts +35 -0
- package/dist/cjs/__fixtures__/address-flow.fixtures.d.ts.map +1 -0
- package/dist/cjs/__fixtures__/address-flow.fixtures.js +186 -0
- package/dist/cjs/__fixtures__/address-flow.fixtures.js.map +1 -0
- package/dist/cjs/__fixtures__/metadata-review.fixtures.d.ts +11 -0
- package/dist/cjs/__fixtures__/metadata-review.fixtures.d.ts.map +1 -0
- package/dist/cjs/__fixtures__/metadata-review.fixtures.js +69 -0
- package/dist/cjs/__fixtures__/metadata-review.fixtures.js.map +1 -0
- package/dist/cjs/address-proof.d.ts +33 -0
- package/dist/cjs/address-proof.d.ts.map +1 -0
- package/dist/cjs/address-proof.js +97 -0
- package/dist/cjs/address-proof.js.map +1 -0
- package/dist/cjs/document-classifier.d.ts +19 -0
- package/dist/cjs/document-classifier.d.ts.map +1 -0
- package/dist/cjs/document-classifier.js +213 -0
- package/dist/cjs/document-classifier.js.map +1 -0
- package/dist/cjs/flow-routing.d.ts +7 -0
- package/dist/cjs/flow-routing.d.ts.map +1 -0
- package/dist/cjs/flow-routing.js +45 -0
- package/dist/cjs/flow-routing.js.map +1 -0
- package/dist/cjs/index.d.ts +25 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +83 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/metadata-review.d.ts +10 -0
- package/dist/cjs/metadata-review.d.ts.map +1 -0
- package/dist/cjs/metadata-review.js +93 -0
- package/dist/cjs/metadata-review.js.map +1 -0
- package/dist/cjs/metrics.d.ts +115 -0
- package/dist/cjs/metrics.d.ts.map +1 -0
- package/dist/cjs/metrics.js +302 -0
- package/dist/cjs/metrics.js.map +1 -0
- package/dist/cjs/quality-checks.d.ts +170 -0
- package/dist/cjs/quality-checks.d.ts.map +1 -0
- package/dist/cjs/quality-checks.js +417 -0
- package/dist/cjs/quality-checks.js.map +1 -0
- package/dist/cjs/sobel.d.ts +61 -0
- package/dist/cjs/sobel.d.ts.map +1 -0
- package/dist/cjs/sobel.js +179 -0
- package/dist/cjs/sobel.js.map +1 -0
- package/dist/cjs/types.d.ts +98 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +38 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/__fixtures__/address-flow.fixtures.d.ts +35 -0
- package/dist/esm/__fixtures__/address-flow.fixtures.d.ts.map +1 -0
- package/dist/esm/__fixtures__/address-flow.fixtures.js +183 -0
- package/dist/esm/__fixtures__/address-flow.fixtures.js.map +1 -0
- package/dist/esm/__fixtures__/metadata-review.fixtures.d.ts +11 -0
- package/dist/esm/__fixtures__/metadata-review.fixtures.d.ts.map +1 -0
- package/dist/esm/__fixtures__/metadata-review.fixtures.js +66 -0
- package/dist/esm/__fixtures__/metadata-review.fixtures.js.map +1 -0
- package/dist/esm/address-proof.d.ts +33 -0
- package/dist/esm/address-proof.d.ts.map +1 -0
- package/dist/esm/address-proof.js +86 -0
- package/dist/esm/address-proof.js.map +1 -0
- package/dist/esm/document-classifier.d.ts +19 -0
- package/dist/esm/document-classifier.d.ts.map +1 -0
- package/dist/esm/document-classifier.js +209 -0
- package/dist/esm/document-classifier.js.map +1 -0
- package/dist/esm/flow-routing.d.ts +7 -0
- package/dist/esm/flow-routing.d.ts.map +1 -0
- package/dist/esm/flow-routing.js +41 -0
- package/dist/esm/flow-routing.js.map +1 -0
- package/dist/esm/index.d.ts +25 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +19 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/metadata-review.d.ts +10 -0
- package/dist/esm/metadata-review.d.ts.map +1 -0
- package/dist/esm/metadata-review.js +90 -0
- package/dist/esm/metadata-review.js.map +1 -0
- package/dist/esm/metrics.d.ts +115 -0
- package/dist/esm/metrics.d.ts.map +1 -0
- package/dist/esm/metrics.js +291 -0
- package/dist/esm/metrics.js.map +1 -0
- package/dist/esm/quality-checks.d.ts +170 -0
- package/dist/esm/quality-checks.d.ts.map +1 -0
- package/dist/esm/quality-checks.js +400 -0
- package/dist/esm/quality-checks.js.map +1 -0
- package/dist/esm/sobel.d.ts +61 -0
- package/dist/esm/sobel.d.ts.map +1 -0
- package/dist/esm/sobel.js +173 -0
- package/dist/esm/sobel.js.map +1 -0
- package/dist/esm/types.d.ts +98 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +35 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frame metrics computation on raw pixel arrays.
|
|
3
|
+
*
|
|
4
|
+
* DOM-free: all functions accept Uint8Array / numeric data. No
|
|
5
|
+
* HTMLVideoElement, HTMLCanvasElement, or any browser API.
|
|
6
|
+
*
|
|
7
|
+
* The caller is responsible for capturing pixel data from the video/camera
|
|
8
|
+
* source and providing the overlay region. This module computes brightness,
|
|
9
|
+
* blur (Laplacian variance), edge energy, frame-to-frame stability, and
|
|
10
|
+
* document rectangle detection.
|
|
11
|
+
*/
|
|
12
|
+
import { CAM_EDGE_PIXEL_THRESHOLD, CAM_EDGE_COVERAGE_THRESHOLD, CAM_DOC_CENTER_OFFSET_MAX, } from './types.js';
|
|
13
|
+
/* -- Greyscale conversion ------------------------------------------------- */
|
|
14
|
+
/**
|
|
15
|
+
* Convert an RGBA pixel buffer to greyscale in-place into a pre-allocated
|
|
16
|
+
* output array. Uses fixed-point ITU-R BT.601 weights.
|
|
17
|
+
*
|
|
18
|
+
* @param rgba - RGBA pixel buffer (length = pixelCount * 4)
|
|
19
|
+
* @param out - Pre-allocated Uint8Array to write greyscale values into
|
|
20
|
+
* @param pixelCount - Total pixel count (width * height)
|
|
21
|
+
*/
|
|
22
|
+
export function rgbaToGreyInPlace(rgba, out, pixelCount) {
|
|
23
|
+
for (let i = 0; i < pixelCount; i++) {
|
|
24
|
+
const p = i * 4;
|
|
25
|
+
out[i] = (rgba[p] * 77 + rgba[p + 1] * 150 + rgba[p + 2] * 29) >> 8;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/* -- Brightness ----------------------------------------------------------- */
|
|
29
|
+
/**
|
|
30
|
+
* Compute average brightness within a rectangular sub-region of a greyscale
|
|
31
|
+
* image. The region is defined as fractional overlay coordinates [0..1].
|
|
32
|
+
*
|
|
33
|
+
* @param grey - Greyscale pixel array
|
|
34
|
+
* @param w - Image width
|
|
35
|
+
* @param h - Image height
|
|
36
|
+
* @param region - Overlay region in fractional coordinates
|
|
37
|
+
*/
|
|
38
|
+
export function computeBrightness(grey, w, h, region) {
|
|
39
|
+
const bx1 = Math.max(0, Math.round(region.x1 * w));
|
|
40
|
+
const by1 = Math.max(0, Math.round(region.y1 * h));
|
|
41
|
+
const bx2 = Math.min(w, Math.round(region.x2 * w));
|
|
42
|
+
const by2 = Math.min(h, Math.round(region.y2 * h));
|
|
43
|
+
let brightSum = 0;
|
|
44
|
+
let brightCount = 0;
|
|
45
|
+
for (let by = by1; by < by2; by++) {
|
|
46
|
+
for (let bx = bx1; bx < bx2; bx++) {
|
|
47
|
+
brightSum += grey[by * w + bx];
|
|
48
|
+
brightCount++;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return brightCount > 0 ? brightSum / brightCount : 0;
|
|
52
|
+
}
|
|
53
|
+
/* -- Blur (Laplacian variance) -------------------------------------------- */
|
|
54
|
+
/**
|
|
55
|
+
* Compute Laplacian variance for sharpness detection.
|
|
56
|
+
* Higher values indicate sharper images.
|
|
57
|
+
*
|
|
58
|
+
* @param grey - Greyscale pixel array
|
|
59
|
+
* @param w - Image width
|
|
60
|
+
* @param h - Image height
|
|
61
|
+
*/
|
|
62
|
+
export function computeLaplacianVariance(grey, w, h) {
|
|
63
|
+
let lapSum = 0;
|
|
64
|
+
let lapCount = 0;
|
|
65
|
+
for (let ly = 1; ly < h - 1; ly++) {
|
|
66
|
+
for (let lx = 1; lx < w - 1; lx++) {
|
|
67
|
+
const ci = ly * w + lx;
|
|
68
|
+
const lap = -4 * grey[ci] + grey[ci - w] + grey[ci + w] + grey[ci - 1] + grey[ci + 1];
|
|
69
|
+
lapSum += lap * lap;
|
|
70
|
+
lapCount++;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return lapCount > 0 ? lapSum / lapCount : 0;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Compute Laplacian variance using floating-point greyscale values.
|
|
77
|
+
* Used for static image quality checks where Float32Array precision is
|
|
78
|
+
* preferred.
|
|
79
|
+
*
|
|
80
|
+
* @param grey - Floating-point greyscale pixel array
|
|
81
|
+
* @param w - Image width
|
|
82
|
+
* @param h - Image height
|
|
83
|
+
*/
|
|
84
|
+
export function computeLaplacianVarianceFloat(grey, w, h) {
|
|
85
|
+
let lapSum = 0;
|
|
86
|
+
let lapCount = 0;
|
|
87
|
+
for (let ly = 1; ly < h - 1; ly++) {
|
|
88
|
+
for (let lx = 1; lx < w - 1; lx++) {
|
|
89
|
+
const lap = -4 * grey[ly * w + lx] +
|
|
90
|
+
grey[(ly - 1) * w + lx] +
|
|
91
|
+
grey[(ly + 1) * w + lx] +
|
|
92
|
+
grey[ly * w + lx - 1] +
|
|
93
|
+
grey[ly * w + lx + 1];
|
|
94
|
+
lapSum += lap * lap;
|
|
95
|
+
lapCount++;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return lapCount > 0 ? lapSum / lapCount : 0;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Compute Sobel edge energy within an overlay sub-region of a greyscale image.
|
|
102
|
+
*
|
|
103
|
+
* @param grey - Greyscale pixel array
|
|
104
|
+
* @param w - Full image width
|
|
105
|
+
* @param h - Full image height
|
|
106
|
+
* @param region - Overlay region in fractional coordinates
|
|
107
|
+
*/
|
|
108
|
+
export function computeEdgeEnergy(grey, w, h, region) {
|
|
109
|
+
const rx1 = Math.max(1, Math.round(region.x1 * w));
|
|
110
|
+
const ry1 = Math.max(1, Math.round(region.y1 * h));
|
|
111
|
+
const rx2 = Math.min(w - 2, Math.round(region.x2 * w));
|
|
112
|
+
const ry2 = Math.min(h - 2, Math.round(region.y2 * h));
|
|
113
|
+
const regionW = Math.max(1, rx2 - rx1);
|
|
114
|
+
const regionH = Math.max(1, ry2 - ry1);
|
|
115
|
+
const rowEnergy = new Float32Array(regionH);
|
|
116
|
+
const colEnergy = new Float32Array(regionW);
|
|
117
|
+
let edgeSum = 0;
|
|
118
|
+
let edgeCount = 0;
|
|
119
|
+
let strongEdgeCount = 0;
|
|
120
|
+
for (let ey = ry1; ey < ry2; ey++) {
|
|
121
|
+
for (let ex = rx1; ex < rx2; ex++) {
|
|
122
|
+
const ei = ey * w + ex;
|
|
123
|
+
const gx2 = -grey[ei - w - 1] +
|
|
124
|
+
grey[ei - w + 1] -
|
|
125
|
+
2 * grey[ei - 1] +
|
|
126
|
+
2 * grey[ei + 1] -
|
|
127
|
+
grey[ei + w - 1] +
|
|
128
|
+
grey[ei + w + 1];
|
|
129
|
+
const gy2 = -grey[ei - w - 1] -
|
|
130
|
+
2 * grey[ei - w] -
|
|
131
|
+
grey[ei - w + 1] +
|
|
132
|
+
grey[ei + w - 1] +
|
|
133
|
+
2 * grey[ei + w] +
|
|
134
|
+
grey[ei + w + 1];
|
|
135
|
+
const mag2 = Math.abs(gx2) + Math.abs(gy2);
|
|
136
|
+
const rRow = ey - ry1;
|
|
137
|
+
const rCol = ex - rx1;
|
|
138
|
+
if (rRow >= 0 && rRow < regionH)
|
|
139
|
+
rowEnergy[rRow] += mag2;
|
|
140
|
+
if (rCol >= 0 && rCol < regionW)
|
|
141
|
+
colEnergy[rCol] += mag2;
|
|
142
|
+
edgeSum += mag2;
|
|
143
|
+
edgeCount++;
|
|
144
|
+
if (mag2 > CAM_EDGE_PIXEL_THRESHOLD)
|
|
145
|
+
strongEdgeCount++;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
avgEdge: edgeCount > 0 ? edgeSum / edgeCount : 0,
|
|
150
|
+
edgeCoverage: edgeCount > 0 ? strongEdgeCount / edgeCount : 0,
|
|
151
|
+
rowEnergy,
|
|
152
|
+
colEnergy,
|
|
153
|
+
regionW,
|
|
154
|
+
regionH,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/* -- Document rectangle detection ----------------------------------------- */
|
|
158
|
+
/**
|
|
159
|
+
* Detect a document rectangle within edge energy profiles.
|
|
160
|
+
*
|
|
161
|
+
* @returns Area ratio, aspect ratio, and center offset of the detected region.
|
|
162
|
+
*/
|
|
163
|
+
export function detectDocumentRect(rowEnergy, colEnergy, regionW, regionH) {
|
|
164
|
+
let docAreaRatio = 0;
|
|
165
|
+
let docAspectRatio = 0;
|
|
166
|
+
let docCenterOffset = 1;
|
|
167
|
+
const energyThreshold = 0.24;
|
|
168
|
+
let rowMax = 0, colMax = 0;
|
|
169
|
+
for (let ri = 0; ri < regionH; ri++)
|
|
170
|
+
if (rowEnergy[ri] > rowMax)
|
|
171
|
+
rowMax = rowEnergy[ri];
|
|
172
|
+
for (let ci2 = 0; ci2 < regionW; ci2++)
|
|
173
|
+
if (colEnergy[ci2] > colMax)
|
|
174
|
+
colMax = colEnergy[ci2];
|
|
175
|
+
if (rowMax > 0 && colMax > 0) {
|
|
176
|
+
let docTop = 0, docBot = regionH - 1, docLeft = 0, docRight = regionW - 1;
|
|
177
|
+
for (let rt = 0; rt < regionH - 1; rt++) {
|
|
178
|
+
if (rowEnergy[rt] / rowMax > energyThreshold) {
|
|
179
|
+
docTop = rt;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
for (let rb = regionH - 1; rb > docTop; rb--) {
|
|
184
|
+
if (rowEnergy[rb] / rowMax > energyThreshold) {
|
|
185
|
+
docBot = rb;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
for (let cl = 0; cl < regionW - 1; cl++) {
|
|
190
|
+
if (colEnergy[cl] / colMax > energyThreshold) {
|
|
191
|
+
docLeft = cl;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
for (let cr = regionW - 1; cr > docLeft; cr--) {
|
|
196
|
+
if (colEnergy[cr] / colMax > energyThreshold) {
|
|
197
|
+
docRight = cr;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const docW = docRight - docLeft + 1;
|
|
202
|
+
const docH = docBot - docTop + 1;
|
|
203
|
+
if (docW > 2 && docH > 2) {
|
|
204
|
+
docAreaRatio = (docW * docH) / (regionW * regionH);
|
|
205
|
+
docAspectRatio = docW / docH;
|
|
206
|
+
const docCenterX = (docLeft + docRight) / 2;
|
|
207
|
+
const docCenterY = (docTop + docBot) / 2;
|
|
208
|
+
const regionCenterX = regionW / 2;
|
|
209
|
+
const regionCenterY = regionH / 2;
|
|
210
|
+
docCenterOffset = Math.max(Math.abs(docCenterX - regionCenterX) / regionW, Math.abs(docCenterY - regionCenterY) / regionH);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return { docAreaRatio, docAspectRatio, docCenterOffset };
|
|
214
|
+
}
|
|
215
|
+
/* -- Frame-to-frame difference (stability) -------------------------------- */
|
|
216
|
+
/**
|
|
217
|
+
* Compute mean absolute difference between two greyscale frames.
|
|
218
|
+
* Returns 999 if no previous frame is available.
|
|
219
|
+
*
|
|
220
|
+
* @param current - Current greyscale frame
|
|
221
|
+
* @param previous - Previous greyscale frame (or null if first frame)
|
|
222
|
+
*/
|
|
223
|
+
export function computeFrameDiff(current, previous) {
|
|
224
|
+
if (!previous || previous.length !== current.length)
|
|
225
|
+
return 999;
|
|
226
|
+
let diffSum = 0;
|
|
227
|
+
for (let di = 0; di < current.length; di++) {
|
|
228
|
+
diffSum += Math.abs(current[di] - previous[di]);
|
|
229
|
+
}
|
|
230
|
+
return diffSum / current.length;
|
|
231
|
+
}
|
|
232
|
+
/* -- Full frame analysis -------------------------------------------------- */
|
|
233
|
+
/**
|
|
234
|
+
* Compute all frame metrics from a greyscale image and an overlay region.
|
|
235
|
+
* This is the DOM-free equivalent of `camAnalyzeFrame()`.
|
|
236
|
+
*
|
|
237
|
+
* @param grey - Greyscale pixel array (w * h bytes)
|
|
238
|
+
* @param w - Image width
|
|
239
|
+
* @param h - Image height
|
|
240
|
+
* @param region - Overlay region in fractional coordinates
|
|
241
|
+
* @param prevGreyData - Previous frame's greyscale data (for stability), or null
|
|
242
|
+
* @returns FrameMetrics for the frame
|
|
243
|
+
*/
|
|
244
|
+
export function analyzeFrame(grey, w, h, region, prevGreyData) {
|
|
245
|
+
// 1. Brightness
|
|
246
|
+
const brightness = computeBrightness(grey, w, h, region);
|
|
247
|
+
// 2. Blur (Laplacian variance)
|
|
248
|
+
const blurScore = computeLaplacianVariance(grey, w, h);
|
|
249
|
+
// 3. Edge energy
|
|
250
|
+
const edgeResult = computeEdgeEnergy(grey, w, h, region);
|
|
251
|
+
// 4. Document rectangle detection
|
|
252
|
+
const docRect = detectDocumentRect(edgeResult.rowEnergy, edgeResult.colEnergy, edgeResult.regionW, edgeResult.regionH);
|
|
253
|
+
// 5. Frame-to-frame difference (stability)
|
|
254
|
+
const frameDiff = computeFrameDiff(grey, prevGreyData);
|
|
255
|
+
return {
|
|
256
|
+
brightness,
|
|
257
|
+
blurScore,
|
|
258
|
+
edgeEnergy: edgeResult.avgEdge,
|
|
259
|
+
frameDiff,
|
|
260
|
+
docAreaRatio: docRect.docAreaRatio,
|
|
261
|
+
docAspectRatio: docRect.docAspectRatio,
|
|
262
|
+
docCenterOffset: docRect.docCenterOffset,
|
|
263
|
+
edgeCoverage: edgeResult.edgeCoverage,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/* -- Document shape match per overlay variant ----------------------------- */
|
|
267
|
+
/**
|
|
268
|
+
* Check whether frame metrics indicate a document-like shape for the given
|
|
269
|
+
* overlay variant. DOM-free: the overlay variant is passed as a value.
|
|
270
|
+
*
|
|
271
|
+
* @param metrics - Computed frame metrics
|
|
272
|
+
* @param variant - Overlay variant ('card', 'passport', or 'a4')
|
|
273
|
+
*/
|
|
274
|
+
export function looksLikeDocument(metrics, variant) {
|
|
275
|
+
const areaRatio = metrics.docAreaRatio || 0;
|
|
276
|
+
const aspectRatio = metrics.docAspectRatio || 0;
|
|
277
|
+
const centerOffset = metrics.docCenterOffset || 1;
|
|
278
|
+
const edgeCoverage = metrics.edgeCoverage || 0;
|
|
279
|
+
if (centerOffset > CAM_DOC_CENTER_OFFSET_MAX || edgeCoverage < CAM_EDGE_COVERAGE_THRESHOLD) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
if (variant === 'a4') {
|
|
283
|
+
return areaRatio > 0.2 && areaRatio < 0.98 && aspectRatio > 0.45 && aspectRatio < 1.65;
|
|
284
|
+
}
|
|
285
|
+
if (variant === 'passport') {
|
|
286
|
+
return areaRatio > 0.15 && areaRatio < 0.92 && aspectRatio > 0.5 && aspectRatio < 2.0;
|
|
287
|
+
}
|
|
288
|
+
// Default (ID cards, voter IDs, driver's licences)
|
|
289
|
+
return areaRatio > 0.15 && areaRatio < 0.92 && aspectRatio > 0.5 && aspectRatio < 2.5;
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAEpB,+EAA+E;AAE/E;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAoC,EACpC,GAAe,EACf,UAAkB;IAElB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,U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
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quality checks -- threshold comparison logic and failure escalation rules.
|
|
3
|
+
*
|
|
4
|
+
* DOM-free: no HTMLElement, no document.*, no navigator.*. All functions
|
|
5
|
+
* operate on plain data (FrameMetrics, QualityCheckResults, numeric values).
|
|
6
|
+
*
|
|
7
|
+
* The DOM-coupled parts of quality-review.ts (banner updates, button state,
|
|
8
|
+
* shake animations, Svelte store, etc.) remain in the SDK. This module
|
|
9
|
+
* exposes the pure decision logic that can be reused in React Native or
|
|
10
|
+
* Node.js environments.
|
|
11
|
+
*/
|
|
12
|
+
import type { QualityCheckResults, DetectedFace, QualityBucket, ReviewDecisionOptions, ReviewMode } from './types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Map a step signature string and optional review mode to a quality bucket.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getQualityBucket(stepSig: string, reviewMode?: ReviewMode): QualityBucket | '';
|
|
17
|
+
/**
|
|
18
|
+
* Get the number of consecutive failures required before the "submit anyway"
|
|
19
|
+
* override becomes available for a given step signature.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getSubmitAnywayThreshold(stepSig: string, reviewMode?: ReviewMode): number;
|
|
22
|
+
/**
|
|
23
|
+
* Mutable failure counter state. Create one per flow session.
|
|
24
|
+
*/
|
|
25
|
+
export interface QualityFailureState {
|
|
26
|
+
document_front: number;
|
|
27
|
+
document_back: number;
|
|
28
|
+
selfie: number;
|
|
29
|
+
address_document: number;
|
|
30
|
+
address_front_door: number;
|
|
31
|
+
/** Signature of the last counted failure (prevents double-counting) */
|
|
32
|
+
lastFailedSignature: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a fresh failure state.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createQualityFailureState(): QualityFailureState;
|
|
38
|
+
/**
|
|
39
|
+
* Increment the failure counter for a bucket if this is a new failure
|
|
40
|
+
* (not a re-render of the same failed review).
|
|
41
|
+
*
|
|
42
|
+
* @param state - Mutable failure state
|
|
43
|
+
* @param stepSig - Step signature string
|
|
44
|
+
* @param failSignature - Unique signature for this failure (e.g. bucket + image src)
|
|
45
|
+
* @param anyFail - Whether any quality check actually failed
|
|
46
|
+
* @returns true if the counter was incremented
|
|
47
|
+
*/
|
|
48
|
+
export declare function countFailedReview(state: QualityFailureState, stepSig: string, failSignature: string, anyFail: boolean, reviewMode?: ReviewMode): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Check whether the submit-anyway override should be available.
|
|
51
|
+
*/
|
|
52
|
+
export declare function shouldShowSubmitAnyway(state: QualityFailureState, stepSig: string, reviewMode?: ReviewMode): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Input for running document quality checks on a static (already-captured)
|
|
55
|
+
* image. All values are pre-computed by the caller from raw pixel data.
|
|
56
|
+
*/
|
|
57
|
+
export interface DocumentQualityInput {
|
|
58
|
+
/** Average brightness (0-255), computed from RGBA -> luminance */
|
|
59
|
+
avgBrightness: number;
|
|
60
|
+
/** Laplacian variance (sharpness measure) */
|
|
61
|
+
laplacianVariance: number;
|
|
62
|
+
/** Greyscale pixel array for the document classifier */
|
|
63
|
+
grey: Uint8Array;
|
|
64
|
+
/** RGBA pixel array for the document classifier */
|
|
65
|
+
imgData: Uint8ClampedArray;
|
|
66
|
+
/** Analysis width */
|
|
67
|
+
w: number;
|
|
68
|
+
/** Analysis height */
|
|
69
|
+
h: number;
|
|
70
|
+
/** Whether corners were detected as OK by crop detection (null = unknown) */
|
|
71
|
+
cornersOk: boolean | null;
|
|
72
|
+
/** Document type for the classifier (optional) */
|
|
73
|
+
documentType?: string | null;
|
|
74
|
+
/** Whether this is an address proof document */
|
|
75
|
+
isAddressProof: boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Result of document quality checks.
|
|
79
|
+
*/
|
|
80
|
+
export interface DocumentQualityResult {
|
|
81
|
+
/** All individual check results */
|
|
82
|
+
checks: QualityCheckResults;
|
|
83
|
+
/** Whether any check explicitly failed */
|
|
84
|
+
anyFail: boolean;
|
|
85
|
+
/** Human-readable failure message (empty if all passed) */
|
|
86
|
+
failMessage: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Run quality checks on a static document image. Returns the check results
|
|
90
|
+
* and a human-readable failure message.
|
|
91
|
+
*
|
|
92
|
+
* This is the pure-logic extraction from `runQualityCheck()`. The caller
|
|
93
|
+
* handles image loading, Canvas rasterization, and UI updates.
|
|
94
|
+
*/
|
|
95
|
+
export declare function runDocumentQualityChecks(input: DocumentQualityInput): DocumentQualityResult;
|
|
96
|
+
/**
|
|
97
|
+
* Input for running selfie quality checks.
|
|
98
|
+
*/
|
|
99
|
+
export interface SelfieQualityInput {
|
|
100
|
+
/** Average brightness (0-255) */
|
|
101
|
+
avgBrightness: number;
|
|
102
|
+
/** Laplacian variance (sharpness measure) */
|
|
103
|
+
laplacianVariance: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Run basic selfie quality checks (lighting + sharpness, before face
|
|
107
|
+
* detection). Returns the `good_lighting` check result.
|
|
108
|
+
*/
|
|
109
|
+
export declare function runSelfieQualityChecks(input: SelfieQualityInput): QualityCheckResults;
|
|
110
|
+
/**
|
|
111
|
+
* Check face position and size relative to image dimensions.
|
|
112
|
+
* Returns an array of warning strings (empty = face is OK).
|
|
113
|
+
*
|
|
114
|
+
* @param faces - Detected faces
|
|
115
|
+
* @param imageWidth - Full image width
|
|
116
|
+
* @param imageHeight - Full image height
|
|
117
|
+
*/
|
|
118
|
+
export declare function checkFaceInImage(faces: DetectedFace[], imageWidth: number, imageHeight: number): string[];
|
|
119
|
+
/**
|
|
120
|
+
* Check whether a detected face is well-centered and appropriately sized
|
|
121
|
+
* for live capture (stricter than static image checks).
|
|
122
|
+
*
|
|
123
|
+
* @param face - Detected face
|
|
124
|
+
* @param videoWidth - Video frame width
|
|
125
|
+
* @param videoHeight - Video frame height
|
|
126
|
+
*/
|
|
127
|
+
export declare function isFaceCentered(face: DetectedFace, videoWidth: number, videoHeight: number): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Evaluate document quality check results and produce a prioritised failure
|
|
130
|
+
* message. Handles address-proof and ID-document modes.
|
|
131
|
+
*/
|
|
132
|
+
export declare function evaluateDocumentFailure(checks: QualityCheckResults, isAddressProof: boolean): {
|
|
133
|
+
anyFail: boolean;
|
|
134
|
+
failMessage: string;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Evaluate selfie quality check results and produce a prioritised failure
|
|
138
|
+
* message.
|
|
139
|
+
*/
|
|
140
|
+
export declare function evaluateSelfieFailure(checks: QualityCheckResults): {
|
|
141
|
+
anyFail: boolean;
|
|
142
|
+
failMessage: string;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Evaluate quality failures for a specific review mode using the same
|
|
146
|
+
* prioritization rules as the SDK review banner.
|
|
147
|
+
*/
|
|
148
|
+
export declare function evaluateReviewFailure(checks: QualityCheckResults, options: ReviewDecisionOptions): {
|
|
149
|
+
anyFail: boolean;
|
|
150
|
+
failMessage: string;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Determine whether the "next" button should be disabled based on the
|
|
154
|
+
* current quality check state.
|
|
155
|
+
*
|
|
156
|
+
* @param checks - Current quality check results
|
|
157
|
+
* @param isSelfie - Whether this is a selfie review
|
|
158
|
+
* @param isAddressProof - Whether this is an address proof review
|
|
159
|
+
* @returns Disabled reason string (empty = should be enabled)
|
|
160
|
+
*/
|
|
161
|
+
export declare function getNextButtonDisabledReason(checks: QualityCheckResults, isSelfieOrOptions: boolean | ReviewDecisionOptions, isAddressProof?: boolean): string;
|
|
162
|
+
/**
|
|
163
|
+
* Get the override button text for the submit-anyway flow.
|
|
164
|
+
*/
|
|
165
|
+
export declare function getOverrideButtonText(stepSig: string): string;
|
|
166
|
+
/**
|
|
167
|
+
* Get the override banner message based on failure count and bucket.
|
|
168
|
+
*/
|
|
169
|
+
export declare function getOverrideBannerMessage(stepSig: string, failCount: number, reviewMode?: ReviewMode): string;
|
|
170
|
+
//# sourceMappingURL=quality-checks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quality-checks.d.ts","sourceRoot":"","sources":["../../src/quality-checks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EAEZ,aAAa,EACb,qBAAqB,EACrB,UAAU,EACX,MAAM,YAAY,CAAC;AAYpB;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,UAAU,GAAE,UAAuB,GAClC,aAAa,GAAG,EAAE,CAQpB;AAID;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,MAAM,CAUzF;AAID;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,uEAAuE;IACvE,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,mBAAmB,CAS/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,mBAAmB,EAC1B,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,OAAO,EAChB,UAAU,CAAC,EAAE,UAAU,GACtB,OAAO,CAST;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,mBAAmB,EAC1B,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,UAAU,GACtB,OAAO,CAKT;AA2BD;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,kEAAkE;IAClE,aAAa,EAAE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