Skip to content

Commit

Permalink
DOT web samples release v1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
TvojTatk0 committed Jul 13, 2022
1 parent 82c536e commit 941c04e
Show file tree
Hide file tree
Showing 39 changed files with 1,012 additions and 1,623 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This repository contains integration samples of Innovatrics DOT Web Auto Capture Components in various technologies.

Version of components in samples: 3.1.2
Version of components in samples: 3.3.1

## Samples

Expand Down
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.4",
"version": "1.0.5",
"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.2.0",
"@innovatrics/dot-face-auto-capture": "3.2.0",
"@innovatrics/dot-document-auto-capture": "3.3.1",
"@innovatrics/dot-face-auto-capture": "3.3.1",
"rxjs": "~7.4.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
Expand Down
41 changes: 21 additions & 20 deletions angular-components-integration/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<div>
<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"
[imageUrl]="imageUrl"
(backBtnClick)="handleStepChange($event)"
></app-result>
<app-component-select
*ngIf="currentStep === step.SELECT_COMPONENT"
(btnClick)="handleStepChange($event)"
></app-component-select>
</div>
<div *ngIf="currentStep === step.DOCUMENT_CAPTURE">
<app-document-auto-capture
(photoTakenCallBack)="handlePhotoTaken($event)"
(onError)="handleOnError($event)"
(backBtnClick)="handleStepChange($event)">
</app-document-auto-capture>
<app-result *ngIf="imageUrl" [imageUrl]="imageUrl"></app-result>
</div>
<div *ngIf="currentStep === step.FACE_CAPTURE">
<app-face-auto-capture
(photoTakenCallBack)="handlePhotoTaken($event)"
(onError)="handleOnError($event)"
(backBtnClick)="handleStepChange($event)">
</app-face-auto-capture>
<app-result *ngIf="imageUrl" [imageUrl]="imageUrl"></app-result>
</div>
<app-component-select
*ngIf="currentStep === step.SELECT_COMPONENT"
(btnClick)="handleStepChange($event)">
</app-component-select>
</div>
2 changes: 1 addition & 1 deletion angular-components-integration/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export class AppComponent {

handleStepChange(step: Step) {
this.currentStep = step;
this.imageUrl = '';
}

handlePhotoTaken({ image, data }: PhotoTakenCbProps) {
console.log("Data: ", data);
this.imageUrl = URL.createObjectURL(image);
this.currentStep = Step.RESULT;
}

handleOnError(error: Error) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
<div>
<button
(click)="onFaceClick()"
class="select-component-btn"
>
<button (click)="onFaceClick()" class="button">
Face
</button>
<button
(click)="onDocumentClick()"
class="select-component-btn"
>
<button (click)="onDocumentClick()" class="button">
Document
</button>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<div>
<h2>Document auto capture</h2>
<button (click)="onBackClick()" class="button">
Go back
</button>
<button (click)="handleContinue()" class="button" [disabled]="isButtonDisabled">
Continue detection
</button>
<div class="container">
<x-dot-document-auto-capture id="dot-document-auto-capture"></x-dot-document-auto-capture>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit, Output, EventEmitter, NgZone } from '@angular/core';
import { PhotoTakenCbProps } from 'src/app/types';
import { PhotoTakenCbProps, Step } from 'src/app/types';
import '@innovatrics/dot-document-auto-capture';
import { HTMLDocumentCaptureElement } from '@innovatrics/auto-capture';

Expand All @@ -10,13 +10,30 @@ import { HTMLDocumentCaptureElement } from '@innovatrics/auto-capture';
export class DocumentAutoCaptureComponent implements OnInit {
@Output() photoTakenCallBack = new EventEmitter<PhotoTakenCbProps>();
@Output() onError = new EventEmitter<Error>();
@Output() backBtnClick = new EventEmitter<Step>();

constructor(private ngZone: NgZone) {}
isButtonDisabled = true;

constructor(private ngZone: NgZone) { }

ngOnInit(): void {
this.initDocumentAutoCapture();
}

onBackClick() {
this.backBtnClick.emit(Step.SELECT_COMPONENT)
}

handleContinue() {
document.dispatchEvent(
new CustomEvent('document-auto-capture', {
detail: { instruction: 'continue-detection' },
}),
);

this.isButtonDisabled = true;
}

initDocumentAutoCapture() {
const documentElement = document.getElementById(
'dot-document-auto-capture'
Expand All @@ -28,6 +45,7 @@ export class DocumentAutoCaptureComponent implements OnInit {
cameraFacing: 'environment',
detectionLayerVisible: true,
photoTakenCb: (image, data) => {
this.isButtonDisabled = false;
this.ngZone.run(() => {
this.photoTakenCallBack.emit({ image, data });
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<div>
<h2>Face auto capture</h2>
<button (click)="onBackClick()" class="button">
Go back
</button>
<button (click)="handleContinue()" class="button" [disabled]="isButtonDisabled">
Continue detection
</button>
<div class="container">
<x-dot-face-auto-capture id="dot-face-auto-capture"></x-dot-face-auto-capture>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, NgZone, OnInit, Output, EventEmitter } from '@angular/core';
import { PhotoTakenCbProps } from 'src/app/types';
import { PhotoTakenCbProps, Step } from 'src/app/types';
import '@innovatrics/dot-face-auto-capture'
import { HTMLDocumentCaptureElement } from '@innovatrics/auto-capture';

Expand All @@ -10,13 +10,30 @@ import { HTMLDocumentCaptureElement } from '@innovatrics/auto-capture';
export class FaceAutoCaptureComponent implements OnInit {
@Output() photoTakenCallBack = new EventEmitter<PhotoTakenCbProps>();
@Output() onError = new EventEmitter<Error>();
@Output() backBtnClick = new EventEmitter<Step>();

isButtonDisabled = true;

constructor(private ngzone: NgZone) { }

ngOnInit(): void {
this.initFaceAutoCapture();
}

onBackClick() {
this.backBtnClick.emit(Step.SELECT_COMPONENT)
}

handleContinue() {
document.dispatchEvent(
new CustomEvent('face-auto-capture', {
detail: { instruction: 'continue-detection' },
}),
);

this.isButtonDisabled = true;
}

initFaceAutoCapture() {
const faceElement = document.getElementById('dot-face-auto-capture') as HTMLDocumentCaptureElement | null;

Expand All @@ -25,6 +42,7 @@ export class FaceAutoCaptureComponent implements OnInit {
imageType: 'png',
cameraFacing: 'environment',
photoTakenCb: (image, data) => {
this.isButtonDisabled = false;
this.ngzone.run(() => {
this.photoTakenCallBack.emit({ image, data });
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
<div class="container">
<button
(click)="onBackClick()"
class="select-component-btn"
>
Go back
</button>
<img
[src]="imageSrc"
alt="result-image"
class="result-img"
>
</div>
<img [src]="imageSrc" alt="result-image" class="result-img">
</div>
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Component, OnChanges, Input } from '@angular/core';
import { DomSanitizer, SafeUrl } from "@angular/platform-browser";
import { Step } from 'src/app/types';

@Component({
selector: 'app-result',
templateUrl: './result.component.html',
styleUrls: ['./result.component.css']
})
export class ResultComponent implements OnInit {
export class ResultComponent implements OnChanges {
@Input() imageUrl!: string;
@Output() backBtnClick = new EventEmitter<Step>();

imageSrc: SafeUrl = '';

constructor(private domSanitizer: DomSanitizer) { }

ngOnInit(): void {
ngOnChanges(): void {
this.imageSrc = this.domSanitizer.bypassSecurityTrustUrl(this.imageUrl)
}

onBackClick() {
this.backBtnClick.emit(Step.SELECT_COMPONENT)
}

}
12 changes: 8 additions & 4 deletions angular-components-integration/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
text-align: center;
}
.container {
width: 50rem;
height: 25rem;
margin: 0 auto;
max-width: 50rem;
margin: 1rem auto;
}
.select-component-btn {
.button {
display: inline-flex;
align-items: center;
justify-content: center;
Expand All @@ -27,3 +26,8 @@
font-size: 1rem;
margin: 0 0.5rem 1rem 0.5rem;
}
.button[disabled] {
background-color: lightgrey;
color: gray;
cursor: not-allowed;
}
16 changes: 8 additions & 8 deletions angular-components-integration/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1242,10 +1242,10 @@
resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6"
integrity sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==

"@innovatrics/dot-document-auto-capture@3.2.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@innovatrics/dot-document-auto-capture/-/dot-document-auto-capture-3.2.0.tgz#4a9dec6bea44c9c93620997bc41e3871d5416302"
integrity sha512-3GaeENPU0gxgOlHLYarkmbXKm/yCMFoZ7NpPNfY8xj2rNzqIdh7wItvxJvHwXpISWkFcb5MSxXsIxK+Sw4nsdg==
"@innovatrics/dot-document-auto-capture@3.3.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@innovatrics/dot-document-auto-capture/-/dot-document-auto-capture-3.3.1.tgz#cf0eebf504f7527a5a8a68362c9aeef121fa39bc"
integrity sha512-Ug0EyQTtYYS+Sk877zfGO2hgAQVVzmWhgWO+yS7v0Hy0xOUPgTVPEO2r0k9vJlikU4JWOwoKsOb2b7KVREVi1w==
dependencies:
"@types/emscripten" "^1.39.5"
polished "^4.1.0"
Expand All @@ -1255,10 +1255,10 @@
styled-components "^5.2.1"
tar "^6.1.11"

"@innovatrics/dot-face-auto-capture@3.2.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@innovatrics/dot-face-auto-capture/-/dot-face-auto-capture-3.2.0.tgz#2b38792e6f347a04819c2158eceeb9beed119b30"
integrity sha512-GmGaAR/rhDs51wK7EC9cteB2EtNYtJA3dKB9sdpcNnJ1ra1z0EN8bse4YHMFR9Lj7H7uQAeintwIkpPk5sECGg==
"@innovatrics/dot-face-auto-capture@3.3.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@innovatrics/dot-face-auto-capture/-/dot-face-auto-capture-3.3.1.tgz#677913cb1f8858e0eec095a3561671c4e05fb527"
integrity sha512-TFcK3u+MZHmxx6kCQR2Mx2J51QUcL4vjtslPQpg3KHWqHCIOT53eS/Vceo0SwaxJeuKE5031cXZRWylvLTjswA==
dependencies:
polished "^4.1.0"
preact "^10.5.12"
Expand Down
6 changes: 5 additions & 1 deletion jquery-components-integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

## Project setup

For detection to work, `sam.wasm` must be fetchable, this means that a web server must be used for development, as `file:/// URLs` are not allowed for WebAssembly binaries.
For detection to work, `sam.wasm` must be fetchable, this means that a web server must be used for development, as `file:/// URLs` are not allowed for WebAssembly binaries.

## Development server

Run `npx http-server . -p 3000` for a dev server. Navigate then to `http://localhost:3000/` to see running jquery sample.
47 changes: 27 additions & 20 deletions jquery-components-integration/index.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="lib/main-face.js"></script>
<script src="lib/main-document.js"></script>
<script src="main.js"></script>
<title>JQuery Integration Sample</title>
</head>

<body>

<div id="app">
<h1>DOT Web Components Integration</h1>
<div><a href="#" id="selfie" class="primary">selfie</a>&nbsp;<a href="#" id="document" class="primary">document</a><br /></div>
<div id="container">
<x-dot-face-auto-capture></x-dot-face-auto-capture> <!-- initial render of the custom components, needs to be supplied props to properly start -->
<x-dot-document-auto-capture></x-dot-document-auto-capture>
</div>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="lib/index-face.js"></script>
<script src="lib/index-document.js"></script>
<script src="index.js"></script>
<title>JQuery Integration Sample</title>
</head>

<body>

<div id="app">
<h1>DOT Web Components Integration</h1>
<div>
<button id="selfie" class="button">Selfie</button>
<button id="document" class="button">Document</button>
<button disabled="true" id="continue" class="button">Continue detection</button>
</div>
<div id="container">
<x-dot-face-auto-capture></x-dot-face-auto-capture>
<!-- initial render of the custom components, needs to be supplied props to properly start -->
<x-dot-document-auto-capture></x-dot-document-auto-capture>
</div>
</body>
<div id="result"></div>
</div>
</body>

</html>
Loading

0 comments on commit 941c04e

Please sign in to comment.