@mikashboks/capture-intelligence-core 0.2.4 → 0.2.5
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/document-crop-arbitration.d.ts +105 -0
- package/dist/cjs/document-crop-arbitration.d.ts.map +1 -0
- package/dist/cjs/document-crop-arbitration.js +660 -0
- package/dist/cjs/document-crop-arbitration.js.map +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +27 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/document-crop-arbitration.d.ts +105 -0
- package/dist/esm/document-crop-arbitration.d.ts.map +1 -0
- package/dist/esm/document-crop-arbitration.js +642 -0
- package/dist/esm/document-crop-arbitration.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { CaptureTrustClient, CropTrustTier } from './capture-trust.js';
|
|
2
|
+
export type DocumentCropShapeFamily = 'card-like' | 'passport-like' | 'document-page-like';
|
|
3
|
+
export type DocumentCropReviewPolicy = 'default' | 'original_only' | 'disabled_unsafe';
|
|
4
|
+
export type DocumentCropArbitrationDecision = 'default_crop' | 'original_with_overlay' | 'original_only' | 'unsafe_crop';
|
|
5
|
+
export interface DocumentCropArbitrationAssessment {
|
|
6
|
+
decision: DocumentCropArbitrationDecision;
|
|
7
|
+
policy: DocumentCropReviewPolicy;
|
|
8
|
+
score: number;
|
|
9
|
+
reason: string;
|
|
10
|
+
reviewSafe: boolean;
|
|
11
|
+
defaultSafe: boolean;
|
|
12
|
+
cropVerified: boolean;
|
|
13
|
+
cropSelectable: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface DocumentCropPoint {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
}
|
|
19
|
+
export interface DocumentCropRect {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
w: number;
|
|
23
|
+
h: number;
|
|
24
|
+
}
|
|
25
|
+
export interface DocumentCropImageSize {
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
}
|
|
29
|
+
export interface DocumentCropQuadrilateral {
|
|
30
|
+
topLeft: DocumentCropPoint;
|
|
31
|
+
topRight: DocumentCropPoint;
|
|
32
|
+
bottomRight: DocumentCropPoint;
|
|
33
|
+
bottomLeft: DocumentCropPoint;
|
|
34
|
+
}
|
|
35
|
+
export interface DocumentCropArbitrationMetadata {
|
|
36
|
+
applied?: boolean | null;
|
|
37
|
+
confidence?: number | null;
|
|
38
|
+
reason?: string | null;
|
|
39
|
+
method?: 'perspective' | 'rectangle' | 'none' | string | null;
|
|
40
|
+
scannerEngine?: string | null;
|
|
41
|
+
cropSource?: string | null;
|
|
42
|
+
cropProvenance?: string | null;
|
|
43
|
+
rect?: DocumentCropRect | null;
|
|
44
|
+
polygon?: DocumentCropQuadrilateral | null;
|
|
45
|
+
sourceImageSize?: DocumentCropImageSize | null;
|
|
46
|
+
outputImageSize?: DocumentCropImageSize | null;
|
|
47
|
+
areaRatio?: number | null;
|
|
48
|
+
aspectRatio?: number | null;
|
|
49
|
+
clamped?: boolean | null;
|
|
50
|
+
unsafeReason?: string | null;
|
|
51
|
+
cornersOk?: boolean | null;
|
|
52
|
+
cropShapeFamily?: DocumentCropShapeFamily | null;
|
|
53
|
+
cropVerified?: boolean | null;
|
|
54
|
+
cropSelectable?: boolean | null;
|
|
55
|
+
cutOffRisk?: 'low' | 'medium' | 'high' | string | null;
|
|
56
|
+
quietZoneClampLossFraction?: number | null;
|
|
57
|
+
liveRecognitionAccepted?: boolean | null;
|
|
58
|
+
liveRecognitionReason?: string | null;
|
|
59
|
+
liveRecognitionPath?: string | null;
|
|
60
|
+
liveRecognitionStrategy?: string | null;
|
|
61
|
+
liveBoundsDetector?: 'scanic' | 'kt-jscanify' | 'sobel-fallback' | string | null;
|
|
62
|
+
liveBoundsReliable?: boolean | null;
|
|
63
|
+
liveQuadPresent?: boolean | null;
|
|
64
|
+
liveQuadInsetMin?: number | null;
|
|
65
|
+
liveMrzConfidence?: number | null;
|
|
66
|
+
liveMrzCheckDigitsValid?: boolean | null;
|
|
67
|
+
liveMrzValidated?: boolean | null;
|
|
68
|
+
captureCandidateDecision?: string | null;
|
|
69
|
+
classifierConfidence?: number | null;
|
|
70
|
+
}
|
|
71
|
+
interface DocumentCropSafetyThresholds {
|
|
72
|
+
minAreaRatio: number;
|
|
73
|
+
minWidthRatio: number;
|
|
74
|
+
minHeightRatio: number;
|
|
75
|
+
maxHorizontalOutsideMarginRatio: number;
|
|
76
|
+
maxVerticalOutsideMarginRatio: number;
|
|
77
|
+
aspectMin: number;
|
|
78
|
+
aspectMax: number;
|
|
79
|
+
useNormalizedAspect?: boolean;
|
|
80
|
+
}
|
|
81
|
+
export declare const DEFAULT_CROP_CONFIDENCE_THRESHOLD = 0.8;
|
|
82
|
+
export declare const DEFAULT_RECTANGLE_CROP_CONFIDENCE_THRESHOLD = 0.88;
|
|
83
|
+
export declare const DEFAULT_SUBMIT_CROP_INSET_FLOOR_ENABLED = true;
|
|
84
|
+
export declare const DOCUMENT_CROP_ASPECT_MIN = 0.45;
|
|
85
|
+
export declare const DOCUMENT_CROP_ASPECT_MAX = 2.15;
|
|
86
|
+
export declare const CARD_LIKE_MEASURED_CROP_MIN_AREA_RATIO = 0.06;
|
|
87
|
+
export declare const QUIET_ZONE_CLAMP_CUT_OFF_RISK_LOSS = 0.8;
|
|
88
|
+
export declare const SAFE_LIVE_QUAD_INSET_MIN = 0.02;
|
|
89
|
+
export declare const isCardLikeCropAspect: (aspectRatio: number) => boolean;
|
|
90
|
+
export declare const getDocumentCropShapeFamily: (aspectRatio: number) => DocumentCropShapeFamily;
|
|
91
|
+
export declare const getDocumentCropSafetyThresholds: (aspectRatio: number, shapeFamily?: DocumentCropShapeFamily | null) => DocumentCropSafetyThresholds;
|
|
92
|
+
export declare const getDocumentCropSafetyAspectRatio: (aspectRatio: number, safetyThresholds: Pick<DocumentCropSafetyThresholds, "useNormalizedAspect">) => number;
|
|
93
|
+
export declare const isDocumentCropAspectSafe: (aspectRatio: number, safetyThresholds: Pick<DocumentCropSafetyThresholds, "aspectMin" | "aspectMax" | "useNormalizedAspect">) => boolean;
|
|
94
|
+
export declare const getMeasuredDocumentCropMinAreaRatio: (aspectRatio: number, shapeFamily?: DocumentCropShapeFamily | null) => number;
|
|
95
|
+
export declare const hasExplicitDocumentCutOffReason: (reason: string | null | undefined) => boolean;
|
|
96
|
+
export declare const hasExplicitUnsafeCaptureReason: (reason: string | null | undefined) => boolean;
|
|
97
|
+
export declare const hasCaptureDocumentCutOffEvidence: (metadata: Pick<DocumentCropArbitrationMetadata, "reason"> | null | undefined) => boolean;
|
|
98
|
+
export declare const hasMarginSafeDocumentCropEvidence: (metadata: DocumentCropArbitrationMetadata) => boolean;
|
|
99
|
+
export declare const isDocumentCropVerified: (metadata: DocumentCropArbitrationMetadata) => boolean;
|
|
100
|
+
export declare const getDocumentCropRejectedReason: (metadata: DocumentCropArbitrationMetadata) => string;
|
|
101
|
+
export declare function assessDocumentCropCandidate(croppedBase64: string, cropMetadata: DocumentCropArbitrationMetadata | undefined): DocumentCropArbitrationAssessment;
|
|
102
|
+
export declare function getDocumentCropReviewPolicy(croppedBase64: string, cropMetadata: DocumentCropArbitrationMetadata | undefined): DocumentCropReviewPolicy;
|
|
103
|
+
export declare function getDocumentCropTrustTier(croppedBase64: string, cropMetadata: DocumentCropArbitrationMetadata | undefined, client?: CaptureTrustClient): CropTrustTier;
|
|
104
|
+
export {};
|
|
105
|
+
//# sourceMappingURL=document-crop-arbitration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-crop-arbitration.d.ts","sourceRoot":"","sources":["../../src/document-crop-arbitration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAG5E,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,eAAe,GAAG,oBAAoB,CAAC;AAE3F,MAAM,MAAM,wBAAwB,GAAG,SAAS,GAAG,eAAe,GAAG,iBAAiB,CAAC;AAEvF,MAAM,MAAM,+BAA+B,GACvC,cAAc,GACd,uBAAuB,GACvB,eAAe,GACf,aAAa,CAAC;AAElB,MAAM,WAAW,iCAAiC;IAChD,QAAQ,EAAE,+BAA+B,CAAC;IAC1C,MAAM,EAAE,wBAAwB,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,gBAAgB;IAC/B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,WAAW,EAAE,iBAAiB,CAAC;IAC/B,UAAU,EAAE,iBAAiB,CAAC;CAC/B;AAED,MAAM,WAAW,+BAA+B;IAC9C,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;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