@regulaforensics/face-sdk 7.2.404-beta → 7.2.414-beta
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 +2 -3
- package/RNFaceSDK.podspec +2 -2
- package/android/build.gradle +2 -2
- package/android/cordova.gradle +2 -2
- package/examples/capacitor/android/app/src/main/AndroidManifest.xml +2 -2
- package/examples/capacitor/index.html +2 -7
- package/examples/capacitor/index.tsx +53 -0
- package/examples/capacitor/package.json +3 -3
- package/examples/capacitor/scripts/setup.sh +4 -2
- package/examples/capacitor/src/main.css +60 -6
- package/examples/capacitor/src/main.html +1 -1
- package/examples/capacitor/src/main.tsx +51 -87
- package/examples/ionic/angular.json +3 -3
- package/examples/ionic/config.xml +1 -1
- package/examples/ionic/index.tsx +68 -0
- package/examples/ionic/package.json +2 -2
- package/examples/ionic/src/main.css +60 -6
- package/examples/ionic/src/main.html +1 -1
- package/examples/ionic/src/{main.ts → main.tsx} +52 -97
- package/examples/ionic/tsconfig.json +3 -2
- package/examples/react_native/index.tsx +49 -7
- package/examples/react_native/package.json +9 -9
- package/examples/react_native/src/main.css +60 -6
- package/examples/react_native/src/main.html +1 -1
- package/examples/react_native/src/main.tsx +54 -77
- package/package.json +1 -1
- package/plugin.xml +2 -2
- package/test/package-lock.json +1 -1
- package/examples/cordova/.vscode/launch.json +0 -28
- package/examples/cordova/README.md +0 -25
- package/examples/cordova/config.xml +0 -26
- package/examples/cordova/package-lock.json +0 -1327
- package/examples/cordova/package.json +0 -30
- package/examples/cordova/scripts/android.sh +0 -8
- package/examples/cordova/scripts/ios.sh +0 -8
- package/examples/cordova/scripts/setup.sh +0 -8
- package/examples/cordova/www/images/logo.png +0 -0
- package/examples/cordova/www/index.html +0 -21
- package/examples/cordova/www/src/main.css +0 -83
- package/examples/cordova/www/src/main.html +0 -25
- package/examples/cordova/www/src/main.js +0 -152
- package/examples/ionic/index.ts +0 -17
- package/examples/ionic/src/images/portrait.png +0 -0
- package/examples/react_native/package-lock.json +0 -9296
- /package/examples/ionic/{src/assets → assets}/.gitkeep +0 -0
- /package/examples/ionic/{src/images → images}/icon.png +0 -0
- /package/examples/{cordova/www → ionic}/images/portrait.png +0 -0
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import { Component } from '@angular/core'
|
|
2
|
-
import { Dialogs } from '@awesome-cordova-plugins/dialogs/ngx'
|
|
3
|
-
import { File } from '@awesome-cordova-plugins/file'
|
|
4
|
-
import { Camera, DestinationType, MediaType, PictureSourceType } from '@awesome-cordova-plugins/camera/ngx'
|
|
5
|
-
import { Platform } from '@ionic/angular'
|
|
6
1
|
import { FaceSDK, MatchFacesRequest, MatchFacesImage, InitConfig, LivenessSkipStep, ImageType, LivenessStatus, LivenessConfig } from '@regulaforensics/face-sdk'
|
|
2
|
+
import { loadAssetIfExists, chooseOption, pickImage } from '../index'
|
|
3
|
+
|
|
4
|
+
var faceSdk = FaceSDK.instance
|
|
5
|
+
var image1: MatchFacesImage | null
|
|
6
|
+
var image2: MatchFacesImage | null
|
|
7
7
|
|
|
8
8
|
async function init() {
|
|
9
|
-
if (!await
|
|
9
|
+
if (!await initializeReader()) return
|
|
10
10
|
setStatus("Ready")
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
async function startFaceCapture(position: number) {
|
|
14
|
+
var image = (await faceSdk.startFaceCapture()).image
|
|
15
|
+
if (image == null) return
|
|
16
|
+
setImage("data:image/png;base64," + image.image, image.imageType, position)
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
async function startLiveness() {
|
|
14
20
|
var response = await faceSdk.startLiveness({
|
|
15
21
|
config: new LivenessConfig({
|
|
@@ -40,30 +46,15 @@ async function matchFaces() {
|
|
|
40
46
|
setStatus("Ready")
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// If 'regula.license' exists, init using license(enables offline match)
|
|
53
|
-
// otherwise init without license.
|
|
54
|
-
async function initialize() {
|
|
55
|
-
setStatus("Initializing...")
|
|
56
|
-
|
|
57
|
-
var license = await loadAssetIfExists("regula.license")
|
|
58
|
-
var config: InitConfig | undefined
|
|
59
|
-
if (license != null) config = new InitConfig(license)
|
|
60
|
-
var [success, error] = await faceSdk.initialize({ config: config })
|
|
61
|
-
|
|
62
|
-
if (!success && error != null) {
|
|
63
|
-
setStatus(error.message)
|
|
64
|
-
console.log(error.code + ": " + error.message)
|
|
49
|
+
async function getImage(position: number) {
|
|
50
|
+
var source = await chooseOption()
|
|
51
|
+
if (source == null) return
|
|
52
|
+
if (source) startFaceCapture(position)
|
|
53
|
+
else {
|
|
54
|
+
var image = await pickImage()
|
|
55
|
+
if (image == null) return
|
|
56
|
+
setImage(image, ImageType.PRINTED, position)
|
|
65
57
|
}
|
|
66
|
-
return success
|
|
67
58
|
}
|
|
68
59
|
|
|
69
60
|
function setImage(base64: string, type: number, position: number) {
|
|
@@ -80,82 +71,46 @@ function setImage(base64: string, type: number, position: number) {
|
|
|
80
71
|
}
|
|
81
72
|
}
|
|
82
73
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
setImage("data:image/png;base64," + image.image, image.imageType, position)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async function useGallery(position: number) {
|
|
91
|
-
var image = await app.camera.getPicture({
|
|
92
|
-
destinationType: DestinationType.DATA_URL,
|
|
93
|
-
mediaType: MediaType.PICTURE,
|
|
94
|
-
sourceType: PictureSourceType.PHOTOLIBRARY
|
|
95
|
-
})
|
|
96
|
-
setImage(image, ImageType.PRINTED, position)
|
|
97
|
-
}
|
|
74
|
+
// If 'regula.license' exists, init using license(enables offline match)
|
|
75
|
+
// otherwise init without license.
|
|
76
|
+
async function initializeReader() {
|
|
77
|
+
setStatus("Initializing...")
|
|
98
78
|
|
|
99
|
-
|
|
100
|
-
var
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
}
|
|
79
|
+
var license = await loadAssetIfExists("regula.license")
|
|
80
|
+
var config: InitConfig | undefined
|
|
81
|
+
if (license != null) config = new InitConfig(license)
|
|
82
|
+
var [success, error] = await faceSdk.initialize({ config: config })
|
|
104
83
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
var fileEntry = await File.getFile(dir, path, null)
|
|
109
|
-
var result = await new Promise<string | null>((resolve, _) => {
|
|
110
|
-
fileEntry.file(file => {
|
|
111
|
-
var reader = new FileReader()
|
|
112
|
-
reader.onloadend = (_) => resolve(reader.result as string)
|
|
113
|
-
reader.readAsDataURL(file)
|
|
114
|
-
}, _ => resolve(null))
|
|
115
|
-
})
|
|
116
|
-
return result
|
|
117
|
-
} catch (_) {
|
|
118
|
-
return null
|
|
84
|
+
if (error != null) {
|
|
85
|
+
setStatus(error.message)
|
|
86
|
+
console.log(error.code + ": " + error.message)
|
|
119
87
|
}
|
|
88
|
+
return success
|
|
120
89
|
}
|
|
121
90
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
91
|
+
// --------------------------------------------------------------------------------------------------------------------
|
|
92
|
+
|
|
93
|
+
export function main() {
|
|
94
|
+
document.getElementById("first-image")!.onclick = () => getImage(1)
|
|
95
|
+
document.getElementById("second-image")!.onclick = () => getImage(2)
|
|
96
|
+
document.getElementById("match-faces")!.onclick = () => matchFaces()
|
|
97
|
+
document.getElementById("start-liveness")!.onclick = () => startLiveness()
|
|
98
|
+
document.getElementById("clear-results")!.onclick = () => clearResults()
|
|
99
|
+
|
|
100
|
+
init()
|
|
101
|
+
}
|
|
126
102
|
|
|
127
|
-
var setStatus = (data: string) => document.getElementById("status")
|
|
128
|
-
var setLivenessStatus = (data: string) => document.getElementById("liveness-status")
|
|
129
|
-
var setSimilarityStatus = (data: string) => document.getElementById("similarity-status")
|
|
103
|
+
var setStatus = (data: string) => document.getElementById("status")!.innerHTML = data
|
|
104
|
+
var setLivenessStatus = (data: string) => document.getElementById("liveness-status")!.innerHTML = data
|
|
105
|
+
var setSimilarityStatus = (data: string) => document.getElementById("similarity-status")!.innerHTML = data
|
|
130
106
|
var setUiImage1 = (data: string) => (document.getElementById("first-image") as HTMLImageElement).src = data
|
|
131
107
|
var setUiImage2 = (data: string) => (document.getElementById("second-image") as HTMLImageElement).src = data
|
|
132
|
-
var
|
|
108
|
+
var clearResults = () => {
|
|
109
|
+
setStatus("Ready")
|
|
110
|
+
setSimilarityStatus("null")
|
|
111
|
+
setLivenessStatus("null")
|
|
133
112
|
setUiImage1("images/portrait.png")
|
|
134
113
|
setUiImage2("images/portrait.png")
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
@Component({
|
|
138
|
-
selector: 'app-root',
|
|
139
|
-
templateUrl: 'main.html',
|
|
140
|
-
styleUrl: 'main.css'
|
|
141
|
-
})
|
|
142
|
-
export class Main {
|
|
143
|
-
dialogs: Dialogs
|
|
144
|
-
camera: Camera
|
|
145
|
-
|
|
146
|
-
constructor(platform: Platform, dialogs: Dialogs, camera: Camera) {
|
|
147
|
-
platform.ready().then(() => {
|
|
148
|
-
this.dialogs = dialogs
|
|
149
|
-
this.camera = camera
|
|
150
|
-
app = this
|
|
151
|
-
|
|
152
|
-
document.getElementById("first-image").onclick = () => pickImage(1)
|
|
153
|
-
document.getElementById("second-image").onclick = () => pickImage(2)
|
|
154
|
-
document.getElementById("match-faces").onclick = () => matchFaces()
|
|
155
|
-
document.getElementById("start-liveness").onclick = () => startLiveness()
|
|
156
|
-
document.getElementById("clear-results").onclick = () => clearResults()
|
|
157
|
-
|
|
158
|
-
init()
|
|
159
|
-
});
|
|
160
|
-
}
|
|
114
|
+
image1 = null
|
|
115
|
+
image2 = null
|
|
161
116
|
}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { registerRootComponent } from 'expo'
|
|
2
2
|
import WebView from 'react-native-webview'
|
|
3
|
-
import
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import * as RNFS from 'react-native-fs'
|
|
5
|
+
import { Alert, Platform } from 'react-native'
|
|
6
|
+
import { launchImageLibrary } from 'react-native-image-picker'
|
|
7
|
+
import { main } from './src/main'
|
|
4
8
|
|
|
5
9
|
var webViewRef: any
|
|
6
10
|
const onclicks: any = {}
|
|
7
11
|
const onMessage = (json: any) => {
|
|
8
12
|
const event = JSON.parse(json.nativeEvent.data)
|
|
9
|
-
if (event.id === "ready")
|
|
13
|
+
if (event.id === "ready") main()
|
|
10
14
|
if (event.id === "onclick") {
|
|
11
15
|
onclicks[event.value]()
|
|
12
16
|
}
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
const document = {
|
|
16
20
|
getElementById(id: string): any {
|
|
17
21
|
return new Proxy({}, {
|
|
18
22
|
set(_, prop: string, value) {
|
|
@@ -24,29 +28,67 @@ export const document = {
|
|
|
24
28
|
}; true
|
|
25
29
|
`)
|
|
26
30
|
} else
|
|
27
|
-
webViewRef.injectJavaScript(`document.getElementById("${id}").${prop} =
|
|
31
|
+
webViewRef.injectJavaScript(`document.getElementById("${id}").${prop} = ${parseValue(value)}; true`)
|
|
28
32
|
return true
|
|
29
33
|
},
|
|
30
34
|
get(_, prop: string) {
|
|
31
35
|
if (prop === "style") return new Proxy({}, {
|
|
32
36
|
set(_, styleProp: string, value) {
|
|
33
|
-
webViewRef.injectJavaScript(`document.getElementById("${id}").style.${styleProp} =
|
|
37
|
+
webViewRef.injectJavaScript(`document.getElementById("${id}").style.${styleProp} = ${parseValue(value)}; true`)
|
|
34
38
|
return true
|
|
35
39
|
}
|
|
36
40
|
})
|
|
41
|
+
if (prop === "insertAdjacentHTML") return (position: string, html: string) => {
|
|
42
|
+
webViewRef.injectJavaScript(`document.getElementById("${id}").insertAdjacentHTML('${position}', \`${html}\`); true`)
|
|
43
|
+
return true
|
|
44
|
+
}
|
|
37
45
|
return undefined
|
|
38
|
-
}
|
|
46
|
+
}
|
|
39
47
|
}
|
|
40
48
|
)
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
51
|
|
|
52
|
+
function parseValue(value: any) {
|
|
53
|
+
if (value !== true && value !== false) return `"${value}"`
|
|
54
|
+
return value
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
(globalThis as any).document = document;
|
|
44
58
|
registerRootComponent(() =>
|
|
45
59
|
<WebView
|
|
46
60
|
ref={ref => { webViewRef = ref }}
|
|
47
61
|
onMessage={onMessage}
|
|
48
62
|
source={require("./index.html")}
|
|
49
63
|
scrollEnabled={false}
|
|
50
|
-
|
|
64
|
+
overScrollMode={'content'}
|
|
51
65
|
/>
|
|
52
66
|
)
|
|
67
|
+
|
|
68
|
+
export async function loadAssetIfExists(path: string): Promise<string | null> {
|
|
69
|
+
if (Platform.OS === 'ios') path = RNFS.MainBundlePath + "/" + path
|
|
70
|
+
var readFile = Platform.OS === 'ios' ? RNFS.readFile : RNFS.readFileRes
|
|
71
|
+
try {
|
|
72
|
+
return await readFile(path, 'base64')
|
|
73
|
+
} catch {
|
|
74
|
+
return null
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function pickImage(): Promise<string | null> {
|
|
79
|
+
var response = await launchImageLibrary({
|
|
80
|
+
mediaType: 'photo',
|
|
81
|
+
selectionLimit: 1,
|
|
82
|
+
includeBase64: true
|
|
83
|
+
})
|
|
84
|
+
return "data:image/png;base64," + response?.assets?.[0].base64!
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export async function chooseOption(): Promise<boolean | null> {
|
|
88
|
+
return new Promise<boolean | null>((resolve) => {
|
|
89
|
+
Alert.alert("Select option", "", [
|
|
90
|
+
{ text: "Use gallery", onPress: () => { resolve(false) } },
|
|
91
|
+
{ text: "Use camera", onPress: () => { resolve(true) } }
|
|
92
|
+
], { cancelable: true, onDismiss: () => resolve(null) })
|
|
93
|
+
})
|
|
94
|
+
}
|
|
@@ -8,19 +8,19 @@
|
|
|
8
8
|
"start": "expo start"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@regulaforensics/face-sdk": "7.2.
|
|
12
|
-
"@regulaforensics/face-core-basic": "7.
|
|
13
|
-
"react-native": "0.79.
|
|
11
|
+
"@regulaforensics/face-sdk": "7.2.414-beta",
|
|
12
|
+
"@regulaforensics/face-core-basic": "7.1.240-nightly",
|
|
13
|
+
"react-native": "0.79.5",
|
|
14
14
|
"react-native-fs": "2.20.0",
|
|
15
15
|
"react-native-image-picker": "8.2.1",
|
|
16
|
-
"react-native-webview": "13.
|
|
17
|
-
"@react-native/metro-config": "0.79.
|
|
16
|
+
"react-native-webview": "13.15.0",
|
|
17
|
+
"@react-native/metro-config": "0.79.5",
|
|
18
18
|
"react": "19.1.0",
|
|
19
|
-
"@types/react": "19.1.
|
|
20
|
-
"expo": "53.0.
|
|
21
|
-
"expo-dev-client": "5.
|
|
19
|
+
"@types/react": "19.1.8",
|
|
20
|
+
"expo": "53.0.20",
|
|
21
|
+
"expo-dev-client": "5.2.4",
|
|
22
22
|
"expo-custom-assets": "1.4.1",
|
|
23
|
-
"expo-build-properties": "0.14.
|
|
23
|
+
"expo-build-properties": "0.14.8",
|
|
24
24
|
"typescript": "5.8.3"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
html,
|
|
2
2
|
body {
|
|
3
|
-
|
|
3
|
+
margin: 0;
|
|
4
|
+
width: 100%;
|
|
4
5
|
height: 99vh;
|
|
5
6
|
display: flex;
|
|
7
|
+
overflow: hidden;
|
|
6
8
|
flex-direction: column;
|
|
7
9
|
}
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
/* Prevent text selection */
|
|
12
|
+
* {
|
|
13
|
+
user-select: none !important;
|
|
14
|
+
-webkit-user-select: none !important;
|
|
15
|
+
-webkit-user-drag: none !important;
|
|
16
|
+
-webkit-touch-callout: none !important;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
.column {
|
|
@@ -52,10 +56,14 @@ body {
|
|
|
52
56
|
margin-top: 13px;
|
|
53
57
|
}
|
|
54
58
|
|
|
59
|
+
.scroll {
|
|
60
|
+
flex-grow: 1;
|
|
61
|
+
overflow-y: auto;
|
|
62
|
+
}
|
|
63
|
+
|
|
55
64
|
.no-scroll {
|
|
56
65
|
flex-grow: 1;
|
|
57
66
|
overflow-y: hidden;
|
|
58
|
-
overflow-x: hidden;
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
.button {
|
|
@@ -67,6 +75,7 @@ body {
|
|
|
67
75
|
color: white;
|
|
68
76
|
border: none;
|
|
69
77
|
padding: 10px 20px;
|
|
78
|
+
justify-content: center;
|
|
70
79
|
font-size: 16px;
|
|
71
80
|
border-radius: 100px;
|
|
72
81
|
cursor: pointer;
|
|
@@ -80,4 +89,49 @@ body {
|
|
|
80
89
|
.button:active {
|
|
81
90
|
position: relative;
|
|
82
91
|
top: 1px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.text-button {
|
|
95
|
+
background: none;
|
|
96
|
+
border: none;
|
|
97
|
+
color: #2196f3;
|
|
98
|
+
font-size: 20px;
|
|
99
|
+
font-weight: bold;
|
|
100
|
+
padding: 5px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.text-button:active {
|
|
104
|
+
position: relative;
|
|
105
|
+
top: 1px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.radio {
|
|
109
|
+
align-items: baseline;
|
|
110
|
+
padding: 15px;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
input[type="checkbox"] {
|
|
114
|
+
width: 20px;
|
|
115
|
+
height: 20px;
|
|
116
|
+
border: 2px solid black;
|
|
117
|
+
background-color: white;
|
|
118
|
+
display: inline-block;
|
|
119
|
+
position: relative;
|
|
120
|
+
cursor: pointer;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.progress-bar {
|
|
124
|
+
width: 75%;
|
|
125
|
+
padding: 3px;
|
|
126
|
+
margin-top: 40px;
|
|
127
|
+
background-color: #eee;
|
|
128
|
+
border-radius: 8px;
|
|
129
|
+
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
#progress {
|
|
133
|
+
width: 0%;
|
|
134
|
+
height: 20px;
|
|
135
|
+
background-color: #4285F4;
|
|
136
|
+
border-radius: 5px;
|
|
83
137
|
}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import { document } from '../index'
|
|
2
|
-
import * as RNFS from 'react-native-fs'
|
|
3
|
-
import { Alert, Platform } from 'react-native'
|
|
4
|
-
import { launchImageLibrary } from 'react-native-image-picker'
|
|
5
1
|
import { FaceSDK, MatchFacesRequest, MatchFacesImage, InitConfig, LivenessSkipStep, ImageType, LivenessStatus, LivenessConfig } from '@regulaforensics/face-sdk'
|
|
2
|
+
import { loadAssetIfExists, chooseOption, pickImage } from '../index'
|
|
3
|
+
|
|
4
|
+
var faceSdk = FaceSDK.instance
|
|
5
|
+
var image1: MatchFacesImage | null
|
|
6
|
+
var image2: MatchFacesImage | null
|
|
6
7
|
|
|
7
8
|
async function init() {
|
|
8
|
-
if (!await
|
|
9
|
+
if (!await initializeReader()) return
|
|
9
10
|
setStatus("Ready")
|
|
10
11
|
}
|
|
11
12
|
|
|
13
|
+
async function startFaceCapture(position: number) {
|
|
14
|
+
var image = (await faceSdk.startFaceCapture()).image
|
|
15
|
+
if (image == null) return
|
|
16
|
+
setImage("data:image/png;base64," + image.image, image.imageType, position)
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
async function startLiveness() {
|
|
13
20
|
var response = await faceSdk.startLiveness({
|
|
14
21
|
config: new LivenessConfig({
|
|
@@ -19,7 +26,7 @@ async function startLiveness() {
|
|
|
19
26
|
}
|
|
20
27
|
})
|
|
21
28
|
if (response.image == null) return
|
|
22
|
-
setImage(response.image, ImageType.LIVE, 1)
|
|
29
|
+
setImage("data:image/png;base64," + response.image, ImageType.LIVE, 1)
|
|
23
30
|
setLivenessStatus(response.liveness == LivenessStatus.PASSED ? "passed" : "unknown")
|
|
24
31
|
}
|
|
25
32
|
|
|
@@ -39,18 +46,34 @@ async function matchFaces() {
|
|
|
39
46
|
setStatus("Ready")
|
|
40
47
|
}
|
|
41
48
|
|
|
42
|
-
function
|
|
43
|
-
|
|
49
|
+
async function getImage(position: number) {
|
|
50
|
+
var source = await chooseOption()
|
|
51
|
+
if (source == null) return
|
|
52
|
+
if (source) startFaceCapture(position)
|
|
53
|
+
else {
|
|
54
|
+
var image = await pickImage()
|
|
55
|
+
if (image == null) return
|
|
56
|
+
setImage(image, ImageType.PRINTED, position)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function setImage(base64: string, type: number, position: number) {
|
|
44
61
|
setSimilarityStatus("null")
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
var mfImage = new MatchFacesImage(base64, type)
|
|
63
|
+
if (position == 1) {
|
|
64
|
+
image1 = mfImage
|
|
65
|
+
setUiImage1(base64)
|
|
66
|
+
setLivenessStatus("null")
|
|
67
|
+
}
|
|
68
|
+
if (position == 2) {
|
|
69
|
+
image2 = mfImage
|
|
70
|
+
setUiImage2(base64)
|
|
71
|
+
}
|
|
49
72
|
}
|
|
50
73
|
|
|
51
74
|
// If 'regula.license' exists, init using license(enables offline match)
|
|
52
75
|
// otherwise init without license.
|
|
53
|
-
async function
|
|
76
|
+
async function initializeReader() {
|
|
54
77
|
setStatus("Initializing...")
|
|
55
78
|
|
|
56
79
|
var license = await loadAssetIfExists("regula.license")
|
|
@@ -58,82 +81,36 @@ async function initialize() {
|
|
|
58
81
|
if (license != null) config = new InitConfig(license)
|
|
59
82
|
var [success, error] = await faceSdk.initialize({ config: config })
|
|
60
83
|
|
|
61
|
-
if (
|
|
84
|
+
if (error != null) {
|
|
62
85
|
setStatus(error.message)
|
|
63
86
|
console.log(error.code + ": " + error.message)
|
|
64
87
|
}
|
|
65
88
|
return success
|
|
66
89
|
}
|
|
67
90
|
|
|
68
|
-
|
|
69
|
-
setSimilarityStatus("null")
|
|
70
|
-
var mfImage = new MatchFacesImage(base64, type)
|
|
71
|
-
if (position == 1) {
|
|
72
|
-
image1 = mfImage
|
|
73
|
-
setUiImage1("data:image/png;base64," + base64)
|
|
74
|
-
setLivenessStatus("null")
|
|
75
|
-
}
|
|
76
|
-
if (position == 2) {
|
|
77
|
-
image2 = mfImage
|
|
78
|
-
setUiImage2("data:image/png;base64," + base64)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async function useCamera(position: number) {
|
|
83
|
-
var response = await faceSdk.startFaceCapture()
|
|
84
|
-
if (response.image == null) return
|
|
85
|
-
var image = response.image
|
|
86
|
-
setImage(image.image, image.imageType, position)
|
|
87
|
-
}
|
|
91
|
+
// --------------------------------------------------------------------------------------------------------------------
|
|
88
92
|
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (response.assets == null) return
|
|
96
|
-
setImage(response.assets[0].base64!, ImageType.PRINTED, position)
|
|
97
|
-
})
|
|
98
|
-
}
|
|
93
|
+
export function main() {
|
|
94
|
+
document.getElementById("first-image")!.onclick = () => getImage(1)
|
|
95
|
+
document.getElementById("second-image")!.onclick = () => getImage(2)
|
|
96
|
+
document.getElementById("match-faces")!.onclick = () => matchFaces()
|
|
97
|
+
document.getElementById("start-liveness")!.onclick = () => startLiveness()
|
|
98
|
+
document.getElementById("clear-results")!.onclick = () => clearResults()
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
Alert.alert("Select option", "", [
|
|
102
|
-
{ text: "Use gallery", onPress: () => useGallery(position) },
|
|
103
|
-
{ text: "Use camera", onPress: () => useCamera(position) }
|
|
104
|
-
], { cancelable: true })
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
async function loadAssetIfExists(path: string): Promise<string | null> {
|
|
108
|
-
if (Platform.OS === 'ios') path = RNFS.MainBundlePath + "/" + path
|
|
109
|
-
var readFile = Platform.OS === 'ios' ? RNFS.readFile : RNFS.readFileRes
|
|
110
|
-
try {
|
|
111
|
-
return await readFile(path, 'base64')
|
|
112
|
-
} catch {
|
|
113
|
-
return null
|
|
114
|
-
}
|
|
100
|
+
init()
|
|
115
101
|
}
|
|
116
102
|
|
|
117
|
-
var
|
|
118
|
-
var
|
|
119
|
-
var
|
|
120
|
-
|
|
121
|
-
var setStatus = (data: string) => document.getElementById("status").innerHTML = data
|
|
122
|
-
var setLivenessStatus = (data: string) => document.getElementById("liveness-status").innerHTML = data
|
|
123
|
-
var setSimilarityStatus = (data: string) => document.getElementById("similarity-status").innerHTML = data
|
|
103
|
+
var setStatus = (data: string) => document.getElementById("status")!.innerHTML = data
|
|
104
|
+
var setLivenessStatus = (data: string) => document.getElementById("liveness-status")!.innerHTML = data
|
|
105
|
+
var setSimilarityStatus = (data: string) => document.getElementById("similarity-status")!.innerHTML = data
|
|
124
106
|
var setUiImage1 = (data: string) => (document.getElementById("first-image") as HTMLImageElement).src = data
|
|
125
107
|
var setUiImage2 = (data: string) => (document.getElementById("second-image") as HTMLImageElement).src = data
|
|
126
|
-
var
|
|
108
|
+
var clearResults = () => {
|
|
109
|
+
setStatus("Ready")
|
|
110
|
+
setSimilarityStatus("null")
|
|
111
|
+
setLivenessStatus("null")
|
|
127
112
|
setUiImage1("images/portrait.png")
|
|
128
113
|
setUiImage2("images/portrait.png")
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
export function onload() {
|
|
132
|
-
document.getElementById("first-image").onclick = () => pickImage(1)
|
|
133
|
-
document.getElementById("second-image").onclick = () => pickImage(2)
|
|
134
|
-
document.getElementById("match-faces").onclick = () => matchFaces()
|
|
135
|
-
document.getElementById("start-liveness").onclick = () => startLiveness()
|
|
136
|
-
document.getElementById("clear-results").onclick = () => clearResults()
|
|
137
|
-
|
|
138
|
-
init()
|
|
114
|
+
image1 = null
|
|
115
|
+
image2 = null
|
|
139
116
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regulaforensics/face-sdk",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.414-beta",
|
|
4
4
|
"description": "This is an npm module for Regula Face SDK. It allows you to easily compaire faces using your phone's camera.",
|
|
5
5
|
"main": "www/react-native/index.js",
|
|
6
6
|
"module": "www/capacitor/index.js",
|
package/plugin.xml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
-
<plugin id="@regulaforensics/face-sdk" version="7.2.
|
|
2
|
+
<plugin id="@regulaforensics/face-sdk" version="7.2.414-beta" xmlns="http://apache.org/cordova/ns/plugins/1.0">
|
|
3
3
|
<name>FaceSDK</name>
|
|
4
4
|
<description>Cordova plugin for Regula Face SDK</description>
|
|
5
5
|
<license>commercial</license>
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<source url="https://github.com/CocoaPods/Specs.git" />
|
|
30
30
|
</config>
|
|
31
31
|
<pods>
|
|
32
|
-
<pod name="
|
|
32
|
+
<pod name="FaceSDKNightly" spec="7.1.3008" />
|
|
33
33
|
</pods>
|
|
34
34
|
</podspec>
|
|
35
35
|
</platform>
|
package/test/package-lock.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Use IntelliSense to learn about possible attributes.
|
|
3
|
-
// Hover to view descriptions of existing attributes.
|
|
4
|
-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
-
"version": "0.2.0",
|
|
6
|
-
"configurations": [
|
|
7
|
-
{
|
|
8
|
-
"name": "Debug Android on emulator",
|
|
9
|
-
"type": "cordova",
|
|
10
|
-
"request": "launch",
|
|
11
|
-
"platform": "android",
|
|
12
|
-
"target": "emulator",
|
|
13
|
-
"port": 9222,
|
|
14
|
-
"sourceMaps": true,
|
|
15
|
-
"cwd": "${workspaceFolder}"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"name": "Debug Android on device",
|
|
19
|
-
"type": "cordova",
|
|
20
|
-
"request": "launch",
|
|
21
|
-
"platform": "android",
|
|
22
|
-
"target": "device",
|
|
23
|
-
"port": 9222,
|
|
24
|
-
"sourceMaps": true,
|
|
25
|
-
"cwd": "${workspaceFolder}"
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
}
|