Skip to content

Commit

Permalink
DOT web samples release v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
butoramatus committed May 30, 2022
1 parent 0b76976 commit 82c536e
Show file tree
Hide file tree
Showing 26 changed files with 4,939 additions and 5,047 deletions.
6 changes: 3 additions & 3 deletions angular-components-integration/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-components-integration",
"version": "1.0.3",
"version": "1.0.4",
"scripts": {
"copy-sam": "cp ./node_modules/@innovatrics/dot-document-auto-capture/sam.wasm ./src",
"ng": "ng",
Expand All @@ -19,8 +19,8 @@
"@angular/platform-browser": "~13.1.0",
"@angular/platform-browser-dynamic": "~13.1.0",
"@angular/router": "~13.1.0",
"@innovatrics/dot-document-auto-capture": "^3.1.2",
"@innovatrics/dot-face-auto-capture": "^3.1.2",
"@innovatrics/dot-document-auto-capture": "3.2.0",
"@innovatrics/dot-face-auto-capture": "3.2.0",
"rxjs": "~7.4.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
Expand Down
2 changes: 2 additions & 0 deletions angular-components-integration/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ <h1>DOT components integration</h1>
<app-document-auto-capture
*ngIf="currentStep === step.DOCUMENT_CAPTURE"
(photoTakenCallBack)="handlePhotoTaken($event)"
(onError)="handleOnError($event)"
></app-document-auto-capture>
<app-face-auto-capture
*ngIf="currentStep === step.FACE_CAPTURE"
(photoTakenCallBack)="handlePhotoTaken($event)"
(onError)="handleOnError($event)"
></app-face-auto-capture>
<app-result
*ngIf="currentStep ===step.RESULT"
Expand Down
4 changes: 4 additions & 0 deletions angular-components-integration/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ export class AppComponent {
this.imageUrl = URL.createObjectURL(image);
this.currentStep = Step.RESULT;
}

handleOnError(error: Error) {
alert(error);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { Component, OnInit, Output, EventEmitter, NgZone } from '@angular/core';
import { HTMLDocumentCaptureElement, PhotoTakenCbProps } from 'src/app/types';
import { PhotoTakenCbProps } from 'src/app/types';
import '@innovatrics/dot-document-auto-capture';
import { HTMLDocumentCaptureElement } from '@innovatrics/auto-capture';

@Component({
selector: 'app-document-auto-capture',
templateUrl: './document-auto-capture.component.html',
})
export class DocumentAutoCaptureComponent implements OnInit {
@Output() photoTakenCallBack = new EventEmitter<PhotoTakenCbProps>();
@Output() onError = new EventEmitter<Error>();

constructor(private ngZone: NgZone) {}

Expand All @@ -30,6 +32,11 @@ export class DocumentAutoCaptureComponent implements OnInit {
this.photoTakenCallBack.emit({ image, data });
});
},
onError: (error) => {
this.ngZone.run(() => {
this.onError.emit(error);
});
},
};
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { Component, NgZone, OnInit, Output, EventEmitter } from '@angular/core';
import { HTMLDocumentCaptureElement, PhotoTakenCbProps } from 'src/app/types';
import { PhotoTakenCbProps } from 'src/app/types';
import '@innovatrics/dot-face-auto-capture'
import { HTMLDocumentCaptureElement } from '@innovatrics/auto-capture';

@Component({
selector: 'app-face-auto-capture',
templateUrl: './face-auto-capture.component.html',
})
export class FaceAutoCaptureComponent implements OnInit {
@Output() photoTakenCallBack = new EventEmitter<PhotoTakenCbProps>();
@Output() onError = new EventEmitter<Error>();

constructor(private ngzone: NgZone) { }

Expand All @@ -26,7 +28,12 @@ export class FaceAutoCaptureComponent implements OnInit {
this.ngzone.run(() => {
this.photoTakenCallBack.emit({ image, data });
});
}
},
onError: (error) => {
this.ngzone.run(() => {
this.onError.emit(error);
});
},
}
}
}
Expand Down
223 changes: 2 additions & 221 deletions angular-components-integration/src/app/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { DocumentComponentData, FaceComponentData } from "@innovatrics/auto-capture";

export enum Step {
SELECT_COMPONENT,
DOCUMENT_CAPTURE,
Expand All @@ -9,224 +11,3 @@ export type PhotoTakenCbProps = {
image: Blob;
data: DocumentComponentData | FaceComponentData;
};

export enum DocumentValidationMode {
STANDARD = 'standard',
STRICT = 'strict',
}

export type DocumentPlaceholder =
| 'id-rectangle-corners-front'
| 'id-rectangle-dash-front'
| 'id-rectangle-dot-front'
| 'id-rectangle-solid-front'
| 'id-rounded-rectangle-photo-front'
| 'id-rounded-rectangle-corners-front'
| 'id-rounded-rectangle-dash-front'
| 'id-rounded-rectangle-dot-front'
| 'id-rounded-rectangle-solid-back'
| 'id-rounded-rectangle-solid-front'
| 'pass-rounded-rectangle-solid-back'
| 'pass-rounded-rectangle-solid-back-blank';

export type FacePlaceholder =
| 'circle-solid'
| 'ellipse-solid'
| 'man-solid'
| 'woman-solid'
| 'square-rounded-dash'
| 'square-rounded-solid'
| 'square-dash'
| 'square-solid';

export type FacingMode = 'environment' | 'user';

export type ImageType = 'jpeg' | 'png';

export type FaceInstructionCode =
| 'candidate_selection'
| 'face_too_close'
| 'face_too_far'
| 'face_centering'
| 'face_not_present'
| 'lighting';

export type DocumentInstructionCode =
| 'candidate_selection'
| 'document_centering'
| 'document_too_close'
| 'document_not_present'
| 'document_too_far'
| 'sharpness_too_low'
| 'brightness_too_low'
| 'brightness_too_high'
| 'hotspots_present'
| 'hold_still';

export type MediaType = 'image/jpeg' | 'image/png';

export type HTMLDocumentCaptureElement = HTMLElement & {
cameraOptions: DocumentCameraProps;
};

export type HTMLFaceCaptureElement = HTMLElement & {
cameraOptions: FaceCameraProps;
};

export type Resolution = {
width: number;
height: number;
};

export type CameraSettings = MediaTrackSettings & { deviceName?: string };

export type DocumentComponentData = {
cameraSettings: CameraSettings;
detection?: DetectedDocument;
imageResolution: Resolution;
};

export type FaceComponentData = {
cameraSettings: CameraSettings;
detection?: DetectedFace;
imageResolution: Resolution;
};

export type DocumentCallback = (
image: Blob,
data: DocumentComponentData
) => void;

export type FaceCallback = (image: Blob, data: FaceComponentData) => void;

export type CustomColors = {
placeholderColor?: string;
placeholderColorSuccess?: string;
instructionColor?: string;
instructionColorSuccess?: string;
instructionTextColor?: string;
};

export type FaceInstructions = {
candidate_selection?: string;
face_too_close?: string;
face_too_far?: string;
face_centering?: string;
face_not_present?: string;
lighting?: string;
};

export type DocumentInstructions = {
candidate_selection?: string;
document_centering?: string;
document_too_close?: string;
document_not_present?: string;
document_too_far?: string;
sharpness_too_low?: string;
brightness_too_low?: string;
brightness_too_high?: string;
hotspots_present?: string;
hold_still?: string;
};

export type DocumentThresholds = {
confidenceThreshold?: number;
placeholderErrorScoreThreshold?: number;
sharpnessThreshold?: number;
brightnessLowThreshold?: number;
brightnessHighThreshold?: number;
hotspotsScoreThreshold?: number;
outOfBoundsThreshold?: number;
documentSmallThreshold?: number;
};

export type FaceThresholds = {
faceConfidence?: number;
optimalFaceSizeLimit?: number;
optimalFaceSizeParam?: number;
faceCenterLimit?: number;
};

export type BaseCameraProps = {
imageType?: ImageType;
cameraFacing?: FacingMode;
onError?: (e: Error) => void;
samWasmUrl?: string;
};

export type DocumentCameraProps = BaseCameraProps & {
photoTakenCb: DocumentCallback;
thresholds?: DocumentThresholds;
detectionLayerVisible?: boolean;
validationMode?: DocumentValidationMode;
uiCustomisation?: {
placeholder?: {
documentPlaceholder?: DocumentPlaceholder;
customSVG?: string;
};
instructions?: DocumentInstructions;
colors?: CustomColors;
};
};

export type FaceCameraProps = BaseCameraProps & {
photoTakenCb: FaceCallback;
thresholds?: FaceThresholds;
uiCustomisation?: {
placeholder?: {
facePlaceholder?: FacePlaceholder;
customSVG?: string;
};
instructions?: FaceInstructions;
colors?: CustomColors;
};
};

export type Point = {
x: number;
y: number;
};

export type ImageParameters = {
brightness: number;
sharpness: number;
hotspots: number;
};

export type ParsedDetectedDocument = ImageParameters & {
confidence: number;
topLeft: Point;
topRight: Point;
bottomRight: Point;
bottomLeft: Point;
};

export type DetectedDocument = ParsedDetectedDocument &
ImageParameters & {
smallestEdge: number;
placeholderFitError: number;
};

export type DetectedFace = {
confidence: number;
topLeft: Point;
bottomRight: Point;
faceCenter: Point;
faceSize: number;
};

export type DocumentDebugData = {
document: DetectedDocument;
fps: number;
resolution: Resolution;
detectionTime: number;
instructionCode: DocumentInstructionCode;
};

export type FaceDebugData = {
face: DetectedFace;
fps: number;
resolution: Resolution;
detectionTime: number;
instructionCode: FaceInstructionCode;
};
Binary file modified angular-components-integration/src/sam.wasm
Binary file not shown.
Loading

0 comments on commit 82c536e

Please sign in to comment.