@moveris/shared 3.8.1 → 3.8.6
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 +19 -16
- package/dist/index.d.mts +4 -7
- package/dist/index.d.ts +4 -7
- package/dist/index.js +15 -45
- package/dist/index.mjs +14 -40
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -669,14 +669,13 @@ const inOval = isFaceInOval(faceBbox, ovalRegion);
|
|
|
669
669
|
console.log(inOval.isInOval); // true/false
|
|
670
670
|
console.log(inOval.alignmentScore); // 0-1
|
|
671
671
|
|
|
672
|
-
// Calculate crop region for face
|
|
672
|
+
// Calculate crop region for face — frame-relative 20% margin on each side,
|
|
673
|
+
// matches the API server-side crop and the model training pipeline.
|
|
673
674
|
const cropRegion = calculateFaceCropRegion(faceBbox, frameWidth, frameHeight);
|
|
674
|
-
// { x, y,
|
|
675
|
-
|
|
676
|
-
//
|
|
677
|
-
|
|
678
|
-
const multiplier = calculateAdaptiveCropMultiplier(faceBox, frameWidth, frameHeight);
|
|
679
|
-
// Returns 2.5–4.0x (matched to cognito-check for ~33% face coverage in 224×224 crop)
|
|
675
|
+
// { x, y, width, height } — possibly non-square rectangle in source pixel
|
|
676
|
+
// coordinates. Callers must resize the cropped pixels to 224×224 with
|
|
677
|
+
// bilinear interpolation; non-square crops are squashed (intentional, matches
|
|
678
|
+
// cv2.resize behaviour applied server-side).
|
|
680
679
|
|
|
681
680
|
// Detect face roll (device tilt) — prefer matrix when available (more accurate under glasses/occlusion)
|
|
682
681
|
if (facialTransformationMatrix) {
|
|
@@ -700,17 +699,21 @@ const drResult = analyzeDynamicRange(rgbaPixels);
|
|
|
700
699
|
// Soft warning — do not use as a hard capture gate
|
|
701
700
|
```
|
|
702
701
|
|
|
703
|
-
#### Crop Constants (aligned with
|
|
702
|
+
#### Crop Constants (aligned with the model contract)
|
|
703
|
+
|
|
704
|
+
These constants control how face crops are generated for the `fast-check-crops` endpoint. They match the algorithm applied server-side in `m-ai-check-api` and during model training:
|
|
704
705
|
|
|
705
|
-
|
|
706
|
+
1. Detect the face. Get the bounding box in source pixel coordinates.
|
|
707
|
+
2. Expand the bbox by `FACE_CROP_FRAME_MARGIN × frameWidth/Height` on each side.
|
|
708
|
+
3. Clamp the resulting rectangle to `[0, frameWidth] × [0, frameHeight]`. The crop is **not necessarily square**.
|
|
709
|
+
4. Resize the cropped pixels to exactly `FACE_CROP_OUTPUT_SIZE × FACE_CROP_OUTPUT_SIZE` with bilinear interpolation. Non-square crops are squashed (matches `cv2.resize` server-side).
|
|
706
710
|
|
|
707
|
-
| Constant | Value
|
|
708
|
-
| -------------------------------- |
|
|
709
|
-
| `
|
|
710
|
-
| `
|
|
711
|
-
| `
|
|
712
|
-
| `
|
|
713
|
-
| `TARGET_FACE_PERCENTAGE_IN_CROP` | 0.5 | Face should occupy ~50% of 224x224 crop |
|
|
711
|
+
| Constant | Value | Description |
|
|
712
|
+
| -------------------------------- | ------ | --------------------------------------------------------------------- |
|
|
713
|
+
| `FACE_CROP_FRAME_MARGIN` | `0.2` | Margin around the face bbox, as a fraction of frame W/H, on each side |
|
|
714
|
+
| `FACE_CROP_OUTPUT_SIZE` | `224` | Required output size for the cropped face image (px) |
|
|
715
|
+
| `MAX_FACE_PERCENTAGE_IN_CROP` | `0.45` | UX guard — nudge users back when the face dominates the crop |
|
|
716
|
+
| `TARGET_FACE_PERCENTAGE_IN_CROP` | `0.33` | UX-only target framing; not a model contract |
|
|
714
717
|
|
|
715
718
|
---
|
|
716
719
|
|
package/dist/index.d.mts
CHANGED
|
@@ -362,10 +362,7 @@ declare const MIN_FACE_SIDE_MARGIN = 0.05;
|
|
|
362
362
|
declare const MIN_CAPTURE_ALIGNMENT = 0.6;
|
|
363
363
|
declare const HIGH_ALIGNMENT = 0.85;
|
|
364
364
|
declare const GOOD_ALIGNMENT = 0.5;
|
|
365
|
-
declare const
|
|
366
|
-
declare const MIN_CROP_MULTIPLIER = 2.5;
|
|
367
|
-
declare const MAX_CROP_MULTIPLIER = 4;
|
|
368
|
-
declare const FACE_CENTER_VERTICAL_OFFSET = 0.05;
|
|
365
|
+
declare const FACE_CROP_FRAME_MARGIN = 0.2;
|
|
369
366
|
declare const MIN_IDEAL_FACE_RATIO = 0.05;
|
|
370
367
|
declare const MAX_IDEAL_FACE_RATIO = 0.2;
|
|
371
368
|
declare const MIN_FACE_RATIO = 0.036;
|
|
@@ -392,12 +389,12 @@ declare const OVAL_REGION_MOBILE: OvalRegion;
|
|
|
392
389
|
declare const DEFAULT_OVAL_REGION: OvalRegion;
|
|
393
390
|
declare function isFaceInOval(faceBox: FaceBoundingBox, frameWidth: number, frameHeight: number, oval?: OvalRegion, tolerance?: number): FaceInOvalResult;
|
|
394
391
|
declare function calculateFaceAlignment(boundingBox: FaceBoundingBox, frameWidth: number, frameHeight: number): FaceAlignmentResult;
|
|
395
|
-
declare function calculateAdaptiveCropMultiplier(faceBox: FaceBoundingBox, frameWidth: number, frameHeight: number): number;
|
|
396
392
|
declare function isFaceCropFullyInFrame(faceBox: FaceBoundingBox, frameWidth: number, frameHeight: number): boolean;
|
|
397
393
|
declare function calculateFaceCropRegion(faceBox: FaceBoundingBox, frameWidth: number, frameHeight: number): {
|
|
398
394
|
x: number;
|
|
399
395
|
y: number;
|
|
400
|
-
|
|
396
|
+
width: number;
|
|
397
|
+
height: number;
|
|
401
398
|
};
|
|
402
399
|
declare function checkFrameQuality(options: {
|
|
403
400
|
faceBox?: FaceBoundingBox;
|
|
@@ -945,4 +942,4 @@ declare function collectDeviceIntelligence(opts?: {
|
|
|
945
942
|
platformVersion?: string;
|
|
946
943
|
}): Promise<DeviceIntelligence | null>;
|
|
947
944
|
|
|
948
|
-
export { ALIGNMENT_THRESHOLD_CAPTURE, ALIGNMENT_THRESHOLD_GOOD, ALIGNMENT_THRESHOLD_PERFECT, ALIGNMENT_THRESHOLD_POOR, API_ENDPOINTS, API_ERROR_CODES, API_PATHS, AUTH_CONFIG, type ApiErrorCode, BACKLIT_RATIO_THRESHOLD, BLUR_THRESHOLD_MOBILE, BaseFrameCollector, type BlurAnalysis, CAMERA_ANGLE_HIGH_RATIO, CAMERA_ANGLE_LOW_RATIO, type CameraAngleResult, type CameraCapabilities, type CameraRequirements, type CameraValidationResult, type CaptureQualityState, type CapturedFrame, type CropData, DEFAULT_BLUR_THRESHOLD, DEFAULT_CAMERA_REQUIREMENTS, DEFAULT_ENDPOINT, DEFAULT_FACE_DETECTION_TIERS, DEFAULT_GAZE_THRESHOLDS, DEFAULT_HAND_OCCLUSION_CONFIG, DEFAULT_LIVENESS_CONFIG, DEFAULT_LOCALE, DEFAULT_OVAL_REGION, DEFAULT_STABILIZER_CONFIG, DEFAULT_STATUS_MESSAGES, DYNAMIC_RANGE_WARNING_THRESHOLD, type DeprecationInfo, type DetectionResult, type DetectionSummary, type DetectorConfig, type DeviceIntelligence, type DeviceIntelligenceCamera, type DeviceIntelligenceGeo, type DeviceIntelligenceOverrides, type DynamicRangeAnalysis, ERROR_MESSAGES, ERROR_MESSAGES_ES, ES_LOCALE, EYE_LANDMARK_INDICES, EYE_QUALITY_THRESHOLDS, type ErrorResponse, type EyeQualityThresholds, type EyeRegionBounds, type EyeRegionQuality, type EyeRegionsBounds,
|
|
945
|
+
export { ALIGNMENT_THRESHOLD_CAPTURE, ALIGNMENT_THRESHOLD_GOOD, ALIGNMENT_THRESHOLD_PERFECT, ALIGNMENT_THRESHOLD_POOR, API_ENDPOINTS, API_ERROR_CODES, API_PATHS, AUTH_CONFIG, type ApiErrorCode, BACKLIT_RATIO_THRESHOLD, BLUR_THRESHOLD_MOBILE, BaseFrameCollector, type BlurAnalysis, CAMERA_ANGLE_HIGH_RATIO, CAMERA_ANGLE_LOW_RATIO, type CameraAngleResult, type CameraCapabilities, type CameraRequirements, type CameraValidationResult, type CaptureQualityState, type CapturedFrame, type CropData, DEFAULT_BLUR_THRESHOLD, DEFAULT_CAMERA_REQUIREMENTS, DEFAULT_ENDPOINT, DEFAULT_FACE_DETECTION_TIERS, DEFAULT_GAZE_THRESHOLDS, DEFAULT_HAND_OCCLUSION_CONFIG, DEFAULT_LIVENESS_CONFIG, DEFAULT_LOCALE, DEFAULT_OVAL_REGION, DEFAULT_STABILIZER_CONFIG, DEFAULT_STATUS_MESSAGES, DYNAMIC_RANGE_WARNING_THRESHOLD, type DeprecationInfo, type DetectionResult, type DetectionSummary, type DetectorConfig, type DeviceIntelligence, type DeviceIntelligenceCamera, type DeviceIntelligenceGeo, type DeviceIntelligenceOverrides, type DynamicRangeAnalysis, ERROR_MESSAGES, ERROR_MESSAGES_ES, ES_LOCALE, EYE_LANDMARK_INDICES, EYE_QUALITY_THRESHOLDS, type ErrorResponse, type EyeQualityThresholds, type EyeRegionBounds, type EyeRegionQuality, type EyeRegionsBounds, FACE_CROP_FRAME_MARGIN, FACE_CROP_OUTPUT_SIZE, FEEDBACK_MESSAGES, FRAME_BUFFER_CONFIG, FRAME_CONFIG, type FaceAlignmentResult, type FaceBoundingBox, type FaceDetectionTiers, type FaceInOvalResult, type FaceLandmarkPoint, type FaceRollResult, type FaceVisibilityResult, type FastCheckCropsRequest, type FastCheckModel, type FastCheckRequest, type FastCheckResponse, type FastCheckStreamRequest, type FastCheckStreamResponse, type FeedbackLocale, type FeedbackMessageKey, type Frame, FrameBuffer, type FrameData, type FrameQualityResult, FrameQueue, type FrameSource, GOOD_ALIGNMENT, type GazeThresholds, HIGH_ALIGNMENT, HYBRID_MODEL_CONFIGS, type HandOcclusionConfig, type HeadPose, type HealthResponse, type Hybrid150CheckRequest, type Hybrid50CheckRequest, type HybridCheckRequest, type HybridCheckResponse, type HybridFrameData, type HybridModelConfig, type JobStatus, type JobStatusResponse, LANDMARK_INDEX, LANDMARK_MAX_BOUND, LANDMARK_MIN_BOUND, LOW_LIGHT_THRESHOLD, type LandmarkValidationResult, type LightingAnalysis, LivenessApiError, type LivenessCallbacks, LivenessClient, type LivenessClientConfig, type LivenessConfig, type LivenessResult, type LivenessState, MAX_FACE_PERCENTAGE_IN_CROP, MAX_FACE_RATIO, MAX_FACE_ROLL_DEGREES, MAX_IDEAL_FACE_RATIO, MIN_CAPTURE_ALIGNMENT, MIN_FACE_AREA_RATIO, MIN_FACE_BOTTOM_MARGIN, MIN_FACE_RATIO, MIN_FACE_SIDE_MARGIN, MIN_FACE_TOP_MARGIN, MIN_IDEAL_FACE_RATIO, MIN_LANDMARK_COUNT, MODEL_CONFIGS, type ModelConfig, type ModelEntry, type ModelType, type ModelVersion, type ModelsResponse, OVAL_GUIDE_COLORS, OVAL_GUIDE_STYLES, OVAL_REGION_DESKTOP, OVAL_REGION_MOBILE, type OnErrorCallback, type OnFrameCapturedCallback, type OnProgressCallback, type OnResultCallback, type OnStateChangeCallback, type OvalGuideState, type OvalRegion, type QueueStatsResponse, RETRY_CONFIG, type RetryOptions, SHARED_SDK_PLATFORM, type StabilizationProgress, type StabilizationResult, type StabilizerConfig, type StatusMessageKey, type StreamingStatus, TARGET_FACE_PERCENTAGE_IN_CROP, VALID_FRAME_COUNTS, type Verdict, type VerifyRequest, type VerifyResponse, type VideoFrameMetadata, analyzeBlur, analyzeDynamicRange, analyzeEyeRegionBrightness, analyzeEyeRegionContrast, analyzeLighting, calculateBrightness, calculateFaceAlignment, calculateFaceCropRegion, canCaptureFrame, checkEyeRegionQuality, checkFrameQuality, collectDeviceIntelligence, decodeBase64, detectCameraAngle, detectFaceRoll, detectFaceRollFromMatrix, detectSpecularHighlights, encodeBase64, generateSessionId, getActiveModels, getApiErrorMessage, getCaptureQualityFeedback, getEyeRegionBounds, getFeedbackMessage, getMinFramesForModel, getOvalGuideState, getStatusMessage, hasEnoughFrames, isDeprecatedModel, isFaceCropFullyInFrame, isFaceFullyVisible, isFaceInOval, isRetryableError, linearRgbToLabL, retryWithBackoff, rgbaToGrayscale, sleep, srgbToLinear, toFrameData, toHybridFrameData, toLivenessResult, toLivenessResultFromStream, validateApiKey, validateFaceLandmarks, validateFrameCount, validateFrameData, validateFrameIndex, validateTimestamp, validateUUID, validateUrl };
|
package/dist/index.d.ts
CHANGED
|
@@ -362,10 +362,7 @@ declare const MIN_FACE_SIDE_MARGIN = 0.05;
|
|
|
362
362
|
declare const MIN_CAPTURE_ALIGNMENT = 0.6;
|
|
363
363
|
declare const HIGH_ALIGNMENT = 0.85;
|
|
364
364
|
declare const GOOD_ALIGNMENT = 0.5;
|
|
365
|
-
declare const
|
|
366
|
-
declare const MIN_CROP_MULTIPLIER = 2.5;
|
|
367
|
-
declare const MAX_CROP_MULTIPLIER = 4;
|
|
368
|
-
declare const FACE_CENTER_VERTICAL_OFFSET = 0.05;
|
|
365
|
+
declare const FACE_CROP_FRAME_MARGIN = 0.2;
|
|
369
366
|
declare const MIN_IDEAL_FACE_RATIO = 0.05;
|
|
370
367
|
declare const MAX_IDEAL_FACE_RATIO = 0.2;
|
|
371
368
|
declare const MIN_FACE_RATIO = 0.036;
|
|
@@ -392,12 +389,12 @@ declare const OVAL_REGION_MOBILE: OvalRegion;
|
|
|
392
389
|
declare const DEFAULT_OVAL_REGION: OvalRegion;
|
|
393
390
|
declare function isFaceInOval(faceBox: FaceBoundingBox, frameWidth: number, frameHeight: number, oval?: OvalRegion, tolerance?: number): FaceInOvalResult;
|
|
394
391
|
declare function calculateFaceAlignment(boundingBox: FaceBoundingBox, frameWidth: number, frameHeight: number): FaceAlignmentResult;
|
|
395
|
-
declare function calculateAdaptiveCropMultiplier(faceBox: FaceBoundingBox, frameWidth: number, frameHeight: number): number;
|
|
396
392
|
declare function isFaceCropFullyInFrame(faceBox: FaceBoundingBox, frameWidth: number, frameHeight: number): boolean;
|
|
397
393
|
declare function calculateFaceCropRegion(faceBox: FaceBoundingBox, frameWidth: number, frameHeight: number): {
|
|
398
394
|
x: number;
|
|
399
395
|
y: number;
|
|
400
|
-
|
|
396
|
+
width: number;
|
|
397
|
+
height: number;
|
|
401
398
|
};
|
|
402
399
|
declare function checkFrameQuality(options: {
|
|
403
400
|
faceBox?: FaceBoundingBox;
|
|
@@ -945,4 +942,4 @@ declare function collectDeviceIntelligence(opts?: {
|
|
|
945
942
|
platformVersion?: string;
|
|
946
943
|
}): Promise<DeviceIntelligence | null>;
|
|
947
944
|
|
|
948
|
-
export { ALIGNMENT_THRESHOLD_CAPTURE, ALIGNMENT_THRESHOLD_GOOD, ALIGNMENT_THRESHOLD_PERFECT, ALIGNMENT_THRESHOLD_POOR, API_ENDPOINTS, API_ERROR_CODES, API_PATHS, AUTH_CONFIG, type ApiErrorCode, BACKLIT_RATIO_THRESHOLD, BLUR_THRESHOLD_MOBILE, BaseFrameCollector, type BlurAnalysis, CAMERA_ANGLE_HIGH_RATIO, CAMERA_ANGLE_LOW_RATIO, type CameraAngleResult, type CameraCapabilities, type CameraRequirements, type CameraValidationResult, type CaptureQualityState, type CapturedFrame, type CropData, DEFAULT_BLUR_THRESHOLD, DEFAULT_CAMERA_REQUIREMENTS, DEFAULT_ENDPOINT, DEFAULT_FACE_DETECTION_TIERS, DEFAULT_GAZE_THRESHOLDS, DEFAULT_HAND_OCCLUSION_CONFIG, DEFAULT_LIVENESS_CONFIG, DEFAULT_LOCALE, DEFAULT_OVAL_REGION, DEFAULT_STABILIZER_CONFIG, DEFAULT_STATUS_MESSAGES, DYNAMIC_RANGE_WARNING_THRESHOLD, type DeprecationInfo, type DetectionResult, type DetectionSummary, type DetectorConfig, type DeviceIntelligence, type DeviceIntelligenceCamera, type DeviceIntelligenceGeo, type DeviceIntelligenceOverrides, type DynamicRangeAnalysis, ERROR_MESSAGES, ERROR_MESSAGES_ES, ES_LOCALE, EYE_LANDMARK_INDICES, EYE_QUALITY_THRESHOLDS, type ErrorResponse, type EyeQualityThresholds, type EyeRegionBounds, type EyeRegionQuality, type EyeRegionsBounds,
|
|
945
|
+
export { ALIGNMENT_THRESHOLD_CAPTURE, ALIGNMENT_THRESHOLD_GOOD, ALIGNMENT_THRESHOLD_PERFECT, ALIGNMENT_THRESHOLD_POOR, API_ENDPOINTS, API_ERROR_CODES, API_PATHS, AUTH_CONFIG, type ApiErrorCode, BACKLIT_RATIO_THRESHOLD, BLUR_THRESHOLD_MOBILE, BaseFrameCollector, type BlurAnalysis, CAMERA_ANGLE_HIGH_RATIO, CAMERA_ANGLE_LOW_RATIO, type CameraAngleResult, type CameraCapabilities, type CameraRequirements, type CameraValidationResult, type CaptureQualityState, type CapturedFrame, type CropData, DEFAULT_BLUR_THRESHOLD, DEFAULT_CAMERA_REQUIREMENTS, DEFAULT_ENDPOINT, DEFAULT_FACE_DETECTION_TIERS, DEFAULT_GAZE_THRESHOLDS, DEFAULT_HAND_OCCLUSION_CONFIG, DEFAULT_LIVENESS_CONFIG, DEFAULT_LOCALE, DEFAULT_OVAL_REGION, DEFAULT_STABILIZER_CONFIG, DEFAULT_STATUS_MESSAGES, DYNAMIC_RANGE_WARNING_THRESHOLD, type DeprecationInfo, type DetectionResult, type DetectionSummary, type DetectorConfig, type DeviceIntelligence, type DeviceIntelligenceCamera, type DeviceIntelligenceGeo, type DeviceIntelligenceOverrides, type DynamicRangeAnalysis, ERROR_MESSAGES, ERROR_MESSAGES_ES, ES_LOCALE, EYE_LANDMARK_INDICES, EYE_QUALITY_THRESHOLDS, type ErrorResponse, type EyeQualityThresholds, type EyeRegionBounds, type EyeRegionQuality, type EyeRegionsBounds, FACE_CROP_FRAME_MARGIN, FACE_CROP_OUTPUT_SIZE, FEEDBACK_MESSAGES, FRAME_BUFFER_CONFIG, FRAME_CONFIG, type FaceAlignmentResult, type FaceBoundingBox, type FaceDetectionTiers, type FaceInOvalResult, type FaceLandmarkPoint, type FaceRollResult, type FaceVisibilityResult, type FastCheckCropsRequest, type FastCheckModel, type FastCheckRequest, type FastCheckResponse, type FastCheckStreamRequest, type FastCheckStreamResponse, type FeedbackLocale, type FeedbackMessageKey, type Frame, FrameBuffer, type FrameData, type FrameQualityResult, FrameQueue, type FrameSource, GOOD_ALIGNMENT, type GazeThresholds, HIGH_ALIGNMENT, HYBRID_MODEL_CONFIGS, type HandOcclusionConfig, type HeadPose, type HealthResponse, type Hybrid150CheckRequest, type Hybrid50CheckRequest, type HybridCheckRequest, type HybridCheckResponse, type HybridFrameData, type HybridModelConfig, type JobStatus, type JobStatusResponse, LANDMARK_INDEX, LANDMARK_MAX_BOUND, LANDMARK_MIN_BOUND, LOW_LIGHT_THRESHOLD, type LandmarkValidationResult, type LightingAnalysis, LivenessApiError, type LivenessCallbacks, LivenessClient, type LivenessClientConfig, type LivenessConfig, type LivenessResult, type LivenessState, MAX_FACE_PERCENTAGE_IN_CROP, MAX_FACE_RATIO, MAX_FACE_ROLL_DEGREES, MAX_IDEAL_FACE_RATIO, MIN_CAPTURE_ALIGNMENT, MIN_FACE_AREA_RATIO, MIN_FACE_BOTTOM_MARGIN, MIN_FACE_RATIO, MIN_FACE_SIDE_MARGIN, MIN_FACE_TOP_MARGIN, MIN_IDEAL_FACE_RATIO, MIN_LANDMARK_COUNT, MODEL_CONFIGS, type ModelConfig, type ModelEntry, type ModelType, type ModelVersion, type ModelsResponse, OVAL_GUIDE_COLORS, OVAL_GUIDE_STYLES, OVAL_REGION_DESKTOP, OVAL_REGION_MOBILE, type OnErrorCallback, type OnFrameCapturedCallback, type OnProgressCallback, type OnResultCallback, type OnStateChangeCallback, type OvalGuideState, type OvalRegion, type QueueStatsResponse, RETRY_CONFIG, type RetryOptions, SHARED_SDK_PLATFORM, type StabilizationProgress, type StabilizationResult, type StabilizerConfig, type StatusMessageKey, type StreamingStatus, TARGET_FACE_PERCENTAGE_IN_CROP, VALID_FRAME_COUNTS, type Verdict, type VerifyRequest, type VerifyResponse, type VideoFrameMetadata, analyzeBlur, analyzeDynamicRange, analyzeEyeRegionBrightness, analyzeEyeRegionContrast, analyzeLighting, calculateBrightness, calculateFaceAlignment, calculateFaceCropRegion, canCaptureFrame, checkEyeRegionQuality, checkFrameQuality, collectDeviceIntelligence, decodeBase64, detectCameraAngle, detectFaceRoll, detectFaceRollFromMatrix, detectSpecularHighlights, encodeBase64, generateSessionId, getActiveModels, getApiErrorMessage, getCaptureQualityFeedback, getEyeRegionBounds, getFeedbackMessage, getMinFramesForModel, getOvalGuideState, getStatusMessage, hasEnoughFrames, isDeprecatedModel, isFaceCropFullyInFrame, isFaceFullyVisible, isFaceInOval, isRetryableError, linearRgbToLabL, retryWithBackoff, rgbaToGrayscale, sleep, srgbToLinear, toFrameData, toHybridFrameData, toLivenessResult, toLivenessResultFromStream, validateApiKey, validateFaceLandmarks, validateFrameCount, validateFrameData, validateFrameIndex, validateTimestamp, validateUUID, validateUrl };
|
package/dist/index.js
CHANGED
|
@@ -50,7 +50,7 @@ __export(index_exports, {
|
|
|
50
50
|
ES_LOCALE: () => ES_LOCALE,
|
|
51
51
|
EYE_LANDMARK_INDICES: () => EYE_LANDMARK_INDICES,
|
|
52
52
|
EYE_QUALITY_THRESHOLDS: () => EYE_QUALITY_THRESHOLDS,
|
|
53
|
-
|
|
53
|
+
FACE_CROP_FRAME_MARGIN: () => FACE_CROP_FRAME_MARGIN,
|
|
54
54
|
FACE_CROP_OUTPUT_SIZE: () => FACE_CROP_OUTPUT_SIZE,
|
|
55
55
|
FEEDBACK_MESSAGES: () => FEEDBACK_MESSAGES,
|
|
56
56
|
FRAME_BUFFER_CONFIG: () => FRAME_BUFFER_CONFIG,
|
|
@@ -60,20 +60,17 @@ __export(index_exports, {
|
|
|
60
60
|
GOOD_ALIGNMENT: () => GOOD_ALIGNMENT,
|
|
61
61
|
HIGH_ALIGNMENT: () => HIGH_ALIGNMENT,
|
|
62
62
|
HYBRID_MODEL_CONFIGS: () => HYBRID_MODEL_CONFIGS,
|
|
63
|
-
IDEAL_CROP_MULTIPLIER: () => IDEAL_CROP_MULTIPLIER,
|
|
64
63
|
LANDMARK_INDEX: () => LANDMARK_INDEX,
|
|
65
64
|
LANDMARK_MAX_BOUND: () => LANDMARK_MAX_BOUND,
|
|
66
65
|
LANDMARK_MIN_BOUND: () => LANDMARK_MIN_BOUND,
|
|
67
66
|
LOW_LIGHT_THRESHOLD: () => LOW_LIGHT_THRESHOLD,
|
|
68
67
|
LivenessApiError: () => LivenessApiError,
|
|
69
68
|
LivenessClient: () => LivenessClient,
|
|
70
|
-
MAX_CROP_MULTIPLIER: () => MAX_CROP_MULTIPLIER,
|
|
71
69
|
MAX_FACE_PERCENTAGE_IN_CROP: () => MAX_FACE_PERCENTAGE_IN_CROP,
|
|
72
70
|
MAX_FACE_RATIO: () => MAX_FACE_RATIO,
|
|
73
71
|
MAX_FACE_ROLL_DEGREES: () => MAX_FACE_ROLL_DEGREES,
|
|
74
72
|
MAX_IDEAL_FACE_RATIO: () => MAX_IDEAL_FACE_RATIO,
|
|
75
73
|
MIN_CAPTURE_ALIGNMENT: () => MIN_CAPTURE_ALIGNMENT,
|
|
76
|
-
MIN_CROP_MULTIPLIER: () => MIN_CROP_MULTIPLIER,
|
|
77
74
|
MIN_FACE_AREA_RATIO: () => MIN_FACE_AREA_RATIO,
|
|
78
75
|
MIN_FACE_BOTTOM_MARGIN: () => MIN_FACE_BOTTOM_MARGIN,
|
|
79
76
|
MIN_FACE_RATIO: () => MIN_FACE_RATIO,
|
|
@@ -95,7 +92,6 @@ __export(index_exports, {
|
|
|
95
92
|
analyzeEyeRegionBrightness: () => analyzeEyeRegionBrightness,
|
|
96
93
|
analyzeEyeRegionContrast: () => analyzeEyeRegionContrast,
|
|
97
94
|
analyzeLighting: () => analyzeLighting,
|
|
98
|
-
calculateAdaptiveCropMultiplier: () => calculateAdaptiveCropMultiplier,
|
|
99
95
|
calculateBrightness: () => calculateBrightness,
|
|
100
96
|
calculateFaceAlignment: () => calculateFaceAlignment,
|
|
101
97
|
calculateFaceCropRegion: () => calculateFaceCropRegion,
|
|
@@ -242,7 +238,7 @@ async function sleep(ms) {
|
|
|
242
238
|
}
|
|
243
239
|
|
|
244
240
|
// package.json
|
|
245
|
-
var version = "3.8.
|
|
241
|
+
var version = "3.8.6";
|
|
246
242
|
|
|
247
243
|
// src/utils/deviceIntelligence.ts
|
|
248
244
|
var IPINFO_URL = "https://ipinfo.io/json";
|
|
@@ -1786,10 +1782,7 @@ var MIN_FACE_SIDE_MARGIN = 0.05;
|
|
|
1786
1782
|
var MIN_CAPTURE_ALIGNMENT = 0.6;
|
|
1787
1783
|
var HIGH_ALIGNMENT = 0.85;
|
|
1788
1784
|
var GOOD_ALIGNMENT = 0.5;
|
|
1789
|
-
var
|
|
1790
|
-
var MIN_CROP_MULTIPLIER = 2.5;
|
|
1791
|
-
var MAX_CROP_MULTIPLIER = 4;
|
|
1792
|
-
var FACE_CENTER_VERTICAL_OFFSET = 0.05;
|
|
1785
|
+
var FACE_CROP_FRAME_MARGIN = 0.2;
|
|
1793
1786
|
var MIN_IDEAL_FACE_RATIO = 0.05;
|
|
1794
1787
|
var MAX_IDEAL_FACE_RATIO = 0.2;
|
|
1795
1788
|
var MIN_FACE_RATIO = 0.036;
|
|
@@ -1983,40 +1976,21 @@ function calculateFaceAlignment(boundingBox, frameWidth, frameHeight) {
|
|
|
1983
1976
|
tooFar: faceRatio < MIN_FACE_RATIO
|
|
1984
1977
|
};
|
|
1985
1978
|
}
|
|
1986
|
-
function calculateAdaptiveCropMultiplier(faceBox, frameWidth, frameHeight) {
|
|
1987
|
-
const faceSize = Math.max(faceBox.width, faceBox.height);
|
|
1988
|
-
const idealCropSize = faceSize * IDEAL_CROP_MULTIPLIER;
|
|
1989
|
-
const maxCropSize = Math.min(frameWidth, frameHeight);
|
|
1990
|
-
if (idealCropSize <= maxCropSize) {
|
|
1991
|
-
return IDEAL_CROP_MULTIPLIER;
|
|
1992
|
-
}
|
|
1993
|
-
const adaptiveMultiplier = maxCropSize / faceSize;
|
|
1994
|
-
return Math.max(MIN_CROP_MULTIPLIER, Math.min(MAX_CROP_MULTIPLIER, adaptiveMultiplier));
|
|
1995
|
-
}
|
|
1996
1979
|
function isFaceCropFullyInFrame(faceBox, frameWidth, frameHeight) {
|
|
1997
|
-
const
|
|
1998
|
-
const
|
|
1999
|
-
const
|
|
2000
|
-
const
|
|
2001
|
-
const faceTop = faceBox.originY - marginY;
|
|
2002
|
-
const faceRight = faceBox.originX + faceBox.width + marginX;
|
|
2003
|
-
const faceBottom = faceBox.originY + faceBox.height + marginY;
|
|
1980
|
+
const faceLeft = faceBox.originX;
|
|
1981
|
+
const faceTop = faceBox.originY;
|
|
1982
|
+
const faceRight = faceBox.originX + faceBox.width;
|
|
1983
|
+
const faceBottom = faceBox.originY + faceBox.height;
|
|
2004
1984
|
return faceLeft >= 0 && faceTop >= 0 && faceRight <= frameWidth && faceBottom <= frameHeight;
|
|
2005
1985
|
}
|
|
2006
1986
|
function calculateFaceCropRegion(faceBox, frameWidth, frameHeight) {
|
|
2007
|
-
const
|
|
2008
|
-
const
|
|
2009
|
-
const
|
|
2010
|
-
const
|
|
2011
|
-
const
|
|
2012
|
-
const
|
|
2013
|
-
|
|
2014
|
-
let cropX = centerX - cropSize / 2;
|
|
2015
|
-
let cropY = centerY - cropSize / 2;
|
|
2016
|
-
cropX = Math.max(0, Math.min(frameWidth - cropSize, cropX));
|
|
2017
|
-
cropY = Math.max(0, Math.min(frameHeight - cropSize, cropY));
|
|
2018
|
-
const finalSize = Math.min(cropSize, frameWidth - cropX, frameHeight - cropY);
|
|
2019
|
-
return { x: cropX, y: cropY, size: finalSize };
|
|
1987
|
+
const marginX = FACE_CROP_FRAME_MARGIN * frameWidth;
|
|
1988
|
+
const marginY = FACE_CROP_FRAME_MARGIN * frameHeight;
|
|
1989
|
+
const x1 = Math.max(0, faceBox.originX - marginX);
|
|
1990
|
+
const y1 = Math.max(0, faceBox.originY - marginY);
|
|
1991
|
+
const x2 = Math.min(frameWidth, faceBox.originX + faceBox.width + marginX);
|
|
1992
|
+
const y2 = Math.min(frameHeight, faceBox.originY + faceBox.height + marginY);
|
|
1993
|
+
return { x: x1, y: y1, width: x2 - x1, height: y2 - y1 };
|
|
2020
1994
|
}
|
|
2021
1995
|
function checkFrameQuality(options) {
|
|
2022
1996
|
const {
|
|
@@ -2380,7 +2354,7 @@ function checkEyeRegionQuality(pixels, thresholds = EYE_QUALITY_THRESHOLDS) {
|
|
|
2380
2354
|
ES_LOCALE,
|
|
2381
2355
|
EYE_LANDMARK_INDICES,
|
|
2382
2356
|
EYE_QUALITY_THRESHOLDS,
|
|
2383
|
-
|
|
2357
|
+
FACE_CROP_FRAME_MARGIN,
|
|
2384
2358
|
FACE_CROP_OUTPUT_SIZE,
|
|
2385
2359
|
FEEDBACK_MESSAGES,
|
|
2386
2360
|
FRAME_BUFFER_CONFIG,
|
|
@@ -2390,20 +2364,17 @@ function checkEyeRegionQuality(pixels, thresholds = EYE_QUALITY_THRESHOLDS) {
|
|
|
2390
2364
|
GOOD_ALIGNMENT,
|
|
2391
2365
|
HIGH_ALIGNMENT,
|
|
2392
2366
|
HYBRID_MODEL_CONFIGS,
|
|
2393
|
-
IDEAL_CROP_MULTIPLIER,
|
|
2394
2367
|
LANDMARK_INDEX,
|
|
2395
2368
|
LANDMARK_MAX_BOUND,
|
|
2396
2369
|
LANDMARK_MIN_BOUND,
|
|
2397
2370
|
LOW_LIGHT_THRESHOLD,
|
|
2398
2371
|
LivenessApiError,
|
|
2399
2372
|
LivenessClient,
|
|
2400
|
-
MAX_CROP_MULTIPLIER,
|
|
2401
2373
|
MAX_FACE_PERCENTAGE_IN_CROP,
|
|
2402
2374
|
MAX_FACE_RATIO,
|
|
2403
2375
|
MAX_FACE_ROLL_DEGREES,
|
|
2404
2376
|
MAX_IDEAL_FACE_RATIO,
|
|
2405
2377
|
MIN_CAPTURE_ALIGNMENT,
|
|
2406
|
-
MIN_CROP_MULTIPLIER,
|
|
2407
2378
|
MIN_FACE_AREA_RATIO,
|
|
2408
2379
|
MIN_FACE_BOTTOM_MARGIN,
|
|
2409
2380
|
MIN_FACE_RATIO,
|
|
@@ -2425,7 +2396,6 @@ function checkEyeRegionQuality(pixels, thresholds = EYE_QUALITY_THRESHOLDS) {
|
|
|
2425
2396
|
analyzeEyeRegionBrightness,
|
|
2426
2397
|
analyzeEyeRegionContrast,
|
|
2427
2398
|
analyzeLighting,
|
|
2428
|
-
calculateAdaptiveCropMultiplier,
|
|
2429
2399
|
calculateBrightness,
|
|
2430
2400
|
calculateFaceAlignment,
|
|
2431
2401
|
calculateFaceCropRegion,
|
package/dist/index.mjs
CHANGED
|
@@ -96,7 +96,7 @@ async function sleep(ms) {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
// package.json
|
|
99
|
-
var version = "3.8.
|
|
99
|
+
var version = "3.8.6";
|
|
100
100
|
|
|
101
101
|
// src/utils/deviceIntelligence.ts
|
|
102
102
|
var IPINFO_URL = "https://ipinfo.io/json";
|
|
@@ -1640,10 +1640,7 @@ var MIN_FACE_SIDE_MARGIN = 0.05;
|
|
|
1640
1640
|
var MIN_CAPTURE_ALIGNMENT = 0.6;
|
|
1641
1641
|
var HIGH_ALIGNMENT = 0.85;
|
|
1642
1642
|
var GOOD_ALIGNMENT = 0.5;
|
|
1643
|
-
var
|
|
1644
|
-
var MIN_CROP_MULTIPLIER = 2.5;
|
|
1645
|
-
var MAX_CROP_MULTIPLIER = 4;
|
|
1646
|
-
var FACE_CENTER_VERTICAL_OFFSET = 0.05;
|
|
1643
|
+
var FACE_CROP_FRAME_MARGIN = 0.2;
|
|
1647
1644
|
var MIN_IDEAL_FACE_RATIO = 0.05;
|
|
1648
1645
|
var MAX_IDEAL_FACE_RATIO = 0.2;
|
|
1649
1646
|
var MIN_FACE_RATIO = 0.036;
|
|
@@ -1837,40 +1834,21 @@ function calculateFaceAlignment(boundingBox, frameWidth, frameHeight) {
|
|
|
1837
1834
|
tooFar: faceRatio < MIN_FACE_RATIO
|
|
1838
1835
|
};
|
|
1839
1836
|
}
|
|
1840
|
-
function calculateAdaptiveCropMultiplier(faceBox, frameWidth, frameHeight) {
|
|
1841
|
-
const faceSize = Math.max(faceBox.width, faceBox.height);
|
|
1842
|
-
const idealCropSize = faceSize * IDEAL_CROP_MULTIPLIER;
|
|
1843
|
-
const maxCropSize = Math.min(frameWidth, frameHeight);
|
|
1844
|
-
if (idealCropSize <= maxCropSize) {
|
|
1845
|
-
return IDEAL_CROP_MULTIPLIER;
|
|
1846
|
-
}
|
|
1847
|
-
const adaptiveMultiplier = maxCropSize / faceSize;
|
|
1848
|
-
return Math.max(MIN_CROP_MULTIPLIER, Math.min(MAX_CROP_MULTIPLIER, adaptiveMultiplier));
|
|
1849
|
-
}
|
|
1850
1837
|
function isFaceCropFullyInFrame(faceBox, frameWidth, frameHeight) {
|
|
1851
|
-
const
|
|
1852
|
-
const
|
|
1853
|
-
const
|
|
1854
|
-
const
|
|
1855
|
-
const faceTop = faceBox.originY - marginY;
|
|
1856
|
-
const faceRight = faceBox.originX + faceBox.width + marginX;
|
|
1857
|
-
const faceBottom = faceBox.originY + faceBox.height + marginY;
|
|
1838
|
+
const faceLeft = faceBox.originX;
|
|
1839
|
+
const faceTop = faceBox.originY;
|
|
1840
|
+
const faceRight = faceBox.originX + faceBox.width;
|
|
1841
|
+
const faceBottom = faceBox.originY + faceBox.height;
|
|
1858
1842
|
return faceLeft >= 0 && faceTop >= 0 && faceRight <= frameWidth && faceBottom <= frameHeight;
|
|
1859
1843
|
}
|
|
1860
1844
|
function calculateFaceCropRegion(faceBox, frameWidth, frameHeight) {
|
|
1861
|
-
const
|
|
1862
|
-
const
|
|
1863
|
-
const
|
|
1864
|
-
const
|
|
1865
|
-
const
|
|
1866
|
-
const
|
|
1867
|
-
|
|
1868
|
-
let cropX = centerX - cropSize / 2;
|
|
1869
|
-
let cropY = centerY - cropSize / 2;
|
|
1870
|
-
cropX = Math.max(0, Math.min(frameWidth - cropSize, cropX));
|
|
1871
|
-
cropY = Math.max(0, Math.min(frameHeight - cropSize, cropY));
|
|
1872
|
-
const finalSize = Math.min(cropSize, frameWidth - cropX, frameHeight - cropY);
|
|
1873
|
-
return { x: cropX, y: cropY, size: finalSize };
|
|
1845
|
+
const marginX = FACE_CROP_FRAME_MARGIN * frameWidth;
|
|
1846
|
+
const marginY = FACE_CROP_FRAME_MARGIN * frameHeight;
|
|
1847
|
+
const x1 = Math.max(0, faceBox.originX - marginX);
|
|
1848
|
+
const y1 = Math.max(0, faceBox.originY - marginY);
|
|
1849
|
+
const x2 = Math.min(frameWidth, faceBox.originX + faceBox.width + marginX);
|
|
1850
|
+
const y2 = Math.min(frameHeight, faceBox.originY + faceBox.height + marginY);
|
|
1851
|
+
return { x: x1, y: y1, width: x2 - x1, height: y2 - y1 };
|
|
1874
1852
|
}
|
|
1875
1853
|
function checkFrameQuality(options) {
|
|
1876
1854
|
const {
|
|
@@ -2233,7 +2211,7 @@ export {
|
|
|
2233
2211
|
ES_LOCALE,
|
|
2234
2212
|
EYE_LANDMARK_INDICES,
|
|
2235
2213
|
EYE_QUALITY_THRESHOLDS,
|
|
2236
|
-
|
|
2214
|
+
FACE_CROP_FRAME_MARGIN,
|
|
2237
2215
|
FACE_CROP_OUTPUT_SIZE,
|
|
2238
2216
|
FEEDBACK_MESSAGES,
|
|
2239
2217
|
FRAME_BUFFER_CONFIG,
|
|
@@ -2243,20 +2221,17 @@ export {
|
|
|
2243
2221
|
GOOD_ALIGNMENT,
|
|
2244
2222
|
HIGH_ALIGNMENT,
|
|
2245
2223
|
HYBRID_MODEL_CONFIGS,
|
|
2246
|
-
IDEAL_CROP_MULTIPLIER,
|
|
2247
2224
|
LANDMARK_INDEX,
|
|
2248
2225
|
LANDMARK_MAX_BOUND,
|
|
2249
2226
|
LANDMARK_MIN_BOUND,
|
|
2250
2227
|
LOW_LIGHT_THRESHOLD,
|
|
2251
2228
|
LivenessApiError,
|
|
2252
2229
|
LivenessClient,
|
|
2253
|
-
MAX_CROP_MULTIPLIER,
|
|
2254
2230
|
MAX_FACE_PERCENTAGE_IN_CROP,
|
|
2255
2231
|
MAX_FACE_RATIO,
|
|
2256
2232
|
MAX_FACE_ROLL_DEGREES,
|
|
2257
2233
|
MAX_IDEAL_FACE_RATIO,
|
|
2258
2234
|
MIN_CAPTURE_ALIGNMENT,
|
|
2259
|
-
MIN_CROP_MULTIPLIER,
|
|
2260
2235
|
MIN_FACE_AREA_RATIO,
|
|
2261
2236
|
MIN_FACE_BOTTOM_MARGIN,
|
|
2262
2237
|
MIN_FACE_RATIO,
|
|
@@ -2278,7 +2253,6 @@ export {
|
|
|
2278
2253
|
analyzeEyeRegionBrightness,
|
|
2279
2254
|
analyzeEyeRegionContrast,
|
|
2280
2255
|
analyzeLighting,
|
|
2281
|
-
calculateAdaptiveCropMultiplier,
|
|
2282
2256
|
calculateBrightness,
|
|
2283
2257
|
calculateFaceAlignment,
|
|
2284
2258
|
calculateFaceCropRegion,
|