accurascan_kyc 0.1.0
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/LICENSE +20 -0
- package/README.md +635 -0
- package/accurascan-kyc.podspec +38 -0
- package/android/build.gradle +118 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +18 -0
- package/android/src/main/java/com/accurascankyc/AccurascanKycModule.java +507 -0
- package/android/src/main/java/com/accurascankyc/AccurascanKycPackage.java +28 -0
- package/android/src/main/java/com/accurascankyc/ActivityFaceMatch.java +533 -0
- package/android/src/main/java/com/accurascankyc/BorderTextView.java +82 -0
- package/android/src/main/java/com/accurascankyc/OcrActivity.java +1263 -0
- package/android/src/main/java/com/accurascankyc/OcrResultActivity.java +736 -0
- package/android/src/main/java/com/accurascankyc/ReactNativeJson.java +123 -0
- package/android/src/main/java/com/accurascankyc/UnsafeOkHttpClient.java +57 -0
- package/android/src/main/res/drawable/btn_bg_gray.xml +6 -0
- package/android/src/main/res/drawable/btn_bg_red.xml +6 -0
- package/android/src/main/res/drawable/btn_bg_trasparent_bottom.xml +6 -0
- package/android/src/main/res/drawable/flip_camera_icon.png +0 -0
- package/android/src/main/res/drawable/ic_close.xml +5 -0
- package/android/src/main/res/drawable/round_border_rect.xml +12 -0
- package/android/src/main/res/drawable/splash.png +0 -0
- package/android/src/main/res/drawable-v24/ic_launcher_foreground.png +0 -0
- package/android/src/main/res/drawable-xhdpi/bg_home.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_barcode.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_biometric.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_check.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_liveness.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_result.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_scan.png +0 -0
- package/android/src/main/res/drawable-xhdpi/img_button_overlay.png +0 -0
- package/android/src/main/res/layout/activity_ocr_result.xml +18 -0
- package/android/src/main/res/layout/activity_splash.xml +26 -0
- package/android/src/main/res/layout/custom_frame_layout.xml +144 -0
- package/android/src/main/res/layout/ocr_activity.xml +28 -0
- package/android/src/main/res/layout-land/custom_frame_layout.xml +144 -0
- package/android/src/main/res/layout-land/ocr_activity.xml +41 -0
- package/android/src/main/res/menu/menu_land_port.xml +7 -0
- package/android/src/main/res/mipmap-hdpi/logo_loign.png +0 -0
- package/android/src/main/res/mipmap-mdpi/logo_loign.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_document_verified.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/logo_loign.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/logo_loign.png +0 -0
- package/android/src/main/res/values/colors.xml +31 -0
- package/android/src/main/res/values/strings.xml +42 -0
- package/android/src/main/res/values/styles.xml +191 -0
- package/ios/AccurascanKyc-Bridging-Header.h +2 -0
- package/ios/AccurascanKyc.m +34 -0
- package/ios/AccurascanKyc.swift +649 -0
- package/ios/AccurascanKyc.xcodeproj/project.pbxproj +283 -0
- package/ios/AccurascanKyc.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/FMController.swift +587 -0
- package/ios/LVController.swift +346 -0
- package/ios/MainStoryboard_iPhone.storyboard +338 -0
- package/ios/ViewController.swift +2686 -0
- package/ios/resources/back_icon.png +0 -0
- package/ios/resources/flip_camera_icon.png +0 -0
- package/ios/resources/flip_document_icon.png +0 -0
- package/ios/resources/ic_logo.png +0 -0
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +161 -0
- package/src/index.tsx +5 -0
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
import AccuraOCR
|
|
3
|
+
import Photos
|
|
4
|
+
import PhotosUI
|
|
5
|
+
import SVProgressHUD
|
|
6
|
+
//import AccuraLiveness_fm
|
|
7
|
+
|
|
8
|
+
//View controller for face match.
|
|
9
|
+
class FMController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate,PHPickerViewControllerDelegate, UIAdaptivePresentationControllerDelegate {
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@IBOutlet var mainView: UIView!
|
|
13
|
+
|
|
14
|
+
//NEW
|
|
15
|
+
var imagePicker = UIImagePickerController()
|
|
16
|
+
var arrDocument: [UIImage] = [UIImage]()
|
|
17
|
+
var selectFirstImage = false
|
|
18
|
+
var facematch = Facematch()
|
|
19
|
+
var liveness = Liveness()
|
|
20
|
+
var gallery1 = false
|
|
21
|
+
var gallery2 = false
|
|
22
|
+
var faceMatch1 = false
|
|
23
|
+
var facematch2 = false
|
|
24
|
+
|
|
25
|
+
//OLD
|
|
26
|
+
var faceArgs:NSDictionary = [:]
|
|
27
|
+
var callBack: RCTResponseSenderBlock? = nil
|
|
28
|
+
var reactViewController:UIViewController? = nil
|
|
29
|
+
var audioPath: URL? = nil
|
|
30
|
+
var isFacematchDone = false
|
|
31
|
+
var isCalledCallBack = false
|
|
32
|
+
var win: UIWindow? = nil
|
|
33
|
+
|
|
34
|
+
func closeMe() {
|
|
35
|
+
// self.win!.rootViewController = reactViewController!
|
|
36
|
+
DispatchQueue.main.async {
|
|
37
|
+
self.dismiss(animated: true) {}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
|
43
|
+
|
|
44
|
+
return .portrait
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override func viewDidLoad() {
|
|
48
|
+
mainView.isHidden = true
|
|
49
|
+
super.viewDidLoad()
|
|
50
|
+
// print(gl.face1)
|
|
51
|
+
// print(gl.face2)
|
|
52
|
+
|
|
53
|
+
imagePicker.delegate = self
|
|
54
|
+
|
|
55
|
+
if gallery1 {
|
|
56
|
+
imageGallery1()
|
|
57
|
+
} else if gallery2{
|
|
58
|
+
imageGallery2()
|
|
59
|
+
} else if faceMatch1 {
|
|
60
|
+
imageCamera1()
|
|
61
|
+
} else if facematch2 {
|
|
62
|
+
imageCamera2()
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
override func viewDidAppear(_ animated: Bool) {
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
override func viewWillAppear(_ animated: Bool) {
|
|
72
|
+
facematch = Facematch.init()
|
|
73
|
+
liveness = Liveness.init()
|
|
74
|
+
liveness.setBlurPercentage(80)
|
|
75
|
+
liveness.setGlarePercentage(-1,-1)
|
|
76
|
+
facematch.setBackGroundColor("#C4C4C5")
|
|
77
|
+
facematch.setCloseIconColor("#000000")
|
|
78
|
+
facematch.setFeedbackBackGroundColor("#C4C4C5")
|
|
79
|
+
facematch.setFeedbackTextColor("#000000")
|
|
80
|
+
if faceArgs["setFeedbackTextSize"] != nil {
|
|
81
|
+
facematch.setFeedbackTextSize((faceArgs["setFeedbackTextSize"] as? Float)!)
|
|
82
|
+
}else{
|
|
83
|
+
facematch.setFeedbackTextSize(Float(18.0))
|
|
84
|
+
}
|
|
85
|
+
if faceArgs["setFeedBackframeMessage"] != nil {
|
|
86
|
+
facematch.setFeedBackframeMessage(faceArgs["setFeedBackframeMessage"] as! String)
|
|
87
|
+
}else{
|
|
88
|
+
facematch.setFeedBackframeMessage("Frame Your Face")
|
|
89
|
+
}
|
|
90
|
+
if faceArgs["setFeedBackAwayMessage"] != nil {
|
|
91
|
+
facematch.setFeedBackAwayMessage(faceArgs["setFeedBackAwayMessage"] as! String)
|
|
92
|
+
}else{
|
|
93
|
+
facematch.setFeedBackAwayMessage("Move Phone Away")
|
|
94
|
+
}
|
|
95
|
+
if faceArgs["setFeedBackOpenEyesMessage"] != nil {
|
|
96
|
+
facematch.setFeedBackOpenEyesMessage(faceArgs["setFeedBackOpenEyesMessage"] as! String)
|
|
97
|
+
}else{
|
|
98
|
+
facematch.setFeedBackOpenEyesMessage("Keep Open Your Eyes")
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
if faceArgs["setFeedBackCloserMessage"] != nil {
|
|
102
|
+
facematch.setFeedBackCloserMessage(faceArgs["setFeedBackCloserMessage"] as! String)
|
|
103
|
+
}else{
|
|
104
|
+
facematch.setFeedBackCloserMessage("Move Phone Closer")
|
|
105
|
+
}
|
|
106
|
+
if faceArgs["setFeedBackCenterMessage"] != nil {
|
|
107
|
+
facematch.setFeedBackCenterMessage(faceArgs["setFeedBackCenterMessage"] as! String)
|
|
108
|
+
}else{
|
|
109
|
+
facematch.setFeedBackCenterMessage("Center Your Face")
|
|
110
|
+
}
|
|
111
|
+
if faceArgs["setFeedbackMultipleFaceMessage"] != nil {
|
|
112
|
+
facematch.setFeedbackMultipleFaceMessage(faceArgs["setFeedbackMultipleFaceMessage"] as! String)
|
|
113
|
+
}else{
|
|
114
|
+
facematch.setFeedbackMultipleFaceMessage("Multiple face detected")
|
|
115
|
+
}
|
|
116
|
+
if faceArgs["setFeedBackFaceSteadymessage"] != nil {
|
|
117
|
+
facematch.setFeedBackFaceSteadymessage(faceArgs["setFeedBackFaceSteadymessage"] as! String)
|
|
118
|
+
}else{
|
|
119
|
+
facematch.setFeedBackFaceSteadymessage("Keep Your Head Straight")
|
|
120
|
+
}
|
|
121
|
+
if faceArgs["setFeedBackLowLightMessage"] != nil {
|
|
122
|
+
facematch.setFeedBackFaceSteadymessage(faceArgs["setFeedBackLowLightMessage"] as! String)
|
|
123
|
+
}else{
|
|
124
|
+
facematch.setFeedBackLowLightMessage("Low light detected")
|
|
125
|
+
}
|
|
126
|
+
if faceArgs["setFeedBackBlurFaceMessage"] != nil {
|
|
127
|
+
facematch.setFeedBackBlurFaceMessage(faceArgs["setFeedBackBlurFaceMessage"] as! String)
|
|
128
|
+
}else{
|
|
129
|
+
facematch.setFeedBackBlurFaceMessage("Blur detected over face")
|
|
130
|
+
}
|
|
131
|
+
if faceArgs["setFeedBackGlareFaceMessage"] != nil {
|
|
132
|
+
facematch.setFeedBackGlareFaceMessage(faceArgs["setFeedBackGlareFaceMessage"] as! String)
|
|
133
|
+
}else{
|
|
134
|
+
facematch.setFeedBackGlareFaceMessage("Glare detected")
|
|
135
|
+
}
|
|
136
|
+
if faceArgs["setBlurPercentage"] != nil {
|
|
137
|
+
facematch.setBlurPercentage(faceArgs["setBlurPercentage"] as! Int32)
|
|
138
|
+
}else{
|
|
139
|
+
facematch.setBlurPercentage(80) // set blure percentage -1 to remove this filter
|
|
140
|
+
}
|
|
141
|
+
if faceArgs["setGlarePercentage_0"] != nil && faceArgs["setGlarePercentage_1"] != nil {
|
|
142
|
+
facematch.setGlarePercentage(faceArgs["setGlarePercentage_0"] as! Int32, faceArgs["setGlarePercentage_1"] as! Int32)
|
|
143
|
+
}else{
|
|
144
|
+
facematch.setGlarePercentage(-1, -1)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
// facematch.setFeedbackTextSize(Float(18.0))
|
|
150
|
+
// facematch.setFeedBackframeMessage("Frame Your Face")
|
|
151
|
+
// facematch.setFeedBackAwayMessage("Move Phone Away")
|
|
152
|
+
// facematch.setFeedBackOpenEyesMessage("Keep Open Your Eyes")
|
|
153
|
+
// facematch.setFeedBackCloserMessage("Move Phone Closer")
|
|
154
|
+
// facematch.setFeedBackCenterMessage("Center Your Face")
|
|
155
|
+
// facematch.setFeedbackMultipleFaceMessage("Multiple face detected")
|
|
156
|
+
// facematch.setFeedBackFaceSteadymessage("Keep Your Head Straight")
|
|
157
|
+
// facematch.setFeedBackLowLightMessage("Low light detected")
|
|
158
|
+
// facematch.setFeedBackBlurFaceMessage("Blur detected over face")
|
|
159
|
+
// facematch.setFeedBackGlareFaceMessage("Glare detected")
|
|
160
|
+
// // 0 for clean face and 100 for Blurry face
|
|
161
|
+
// facematch.setBlurPercentage(80) // set blure percentage -1 to remove this filter
|
|
162
|
+
// // Set min and max percentage for glare
|
|
163
|
+
// facematch.setGlarePercentage(-1, -1) //set glaremin -1 to remove this filter
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@IBAction func baAtn(_ sender: UIButton) {
|
|
167
|
+
closeMe()
|
|
168
|
+
}
|
|
169
|
+
// func startFC() {
|
|
170
|
+
// let facematch = Facematch()
|
|
171
|
+
// // To customize your screen theme and feed back messages
|
|
172
|
+
// facematch.setBackGroundColor(FaceMatchConfigs.backgroundColor)
|
|
173
|
+
// if livenessConfigs["livenessBackground"] != nil {
|
|
174
|
+
// facematch.setBackGroundColor(livenessConfigs["livenessBackground"] as! String)
|
|
175
|
+
// }
|
|
176
|
+
// facematch.setCloseIconColor(LivenessConfigs.livenessCloseIconColor)
|
|
177
|
+
// if livenessConfigs["livenessCloseIconColor"] != nil {
|
|
178
|
+
// facematch.setCloseIconColor(livenessConfigs["livenessCloseIconColor"] as! String)
|
|
179
|
+
// }
|
|
180
|
+
// facematch.setFeedbackBackGroundColor(LivenessConfigs.livenessfeedbackBackground)
|
|
181
|
+
// if livenessConfigs["livenessfeedbackBackground"] != nil {
|
|
182
|
+
// facematch.setFeedbackBackGroundColor(livenessConfigs["livenessfeedbackBackground"] as! String)
|
|
183
|
+
// }
|
|
184
|
+
// facematch.setFeedbackTextColor(LivenessConfigs.livenessfeedbackTextColor)
|
|
185
|
+
// if livenessConfigs["livenessfeedbackTextColor"] != nil {
|
|
186
|
+
// facematch.setFeedbackTextColor(livenessConfigs["livenessfeedbackTextColor"] as! String)
|
|
187
|
+
// }
|
|
188
|
+
// facematch.setFeedbackTextSize(Float(LivenessConfigs.feedbackTextSize))
|
|
189
|
+
// if livenessConfigs["feedbackTextSize"] != nil {
|
|
190
|
+
// facematch.setFeedbackTextSize(livenessConfigs["feedbackTextSize"] as! Float)
|
|
191
|
+
// }
|
|
192
|
+
// facematch.setFeedBackframeMessage(LivenessConfigs.feedBackframeMessage)
|
|
193
|
+
// if livenessConfigs["feedBackframeMessage"] != nil {
|
|
194
|
+
// facematch.setFeedBackframeMessage(livenessConfigs["feedBackframeMessage"] as! String)
|
|
195
|
+
// }
|
|
196
|
+
// facematch.setFeedBackAwayMessage(LivenessConfigs.feedBackAwayMessage)
|
|
197
|
+
// if livenessConfigs["feedBackAwayMessage"] != nil {
|
|
198
|
+
// facematch.setFeedBackAwayMessage(livenessConfigs["feedBackAwayMessage"] as! String)
|
|
199
|
+
// }
|
|
200
|
+
// facematch.setFeedBackOpenEyesMessage(LivenessConfigs.feedBackOpenEyesMessage)
|
|
201
|
+
// if livenessConfigs["feedBackOpenEyesMessage"] != nil {
|
|
202
|
+
// facematch.setFeedBackOpenEyesMessage(livenessConfigs["feedBackOpenEyesMessage"] as! String)
|
|
203
|
+
// }
|
|
204
|
+
// facematch.setFeedBackCloserMessage(LivenessConfigs.feedBackCloserMessage)
|
|
205
|
+
// if livenessConfigs["feedBackCloserMessage"] != nil {
|
|
206
|
+
// facematch.setFeedBackCloserMessage(livenessConfigs["feedBackCloserMessage"] as! String)
|
|
207
|
+
// }
|
|
208
|
+
// facematch.setFeedBackCenterMessage(LivenessConfigs.feedBackCenterMessage)
|
|
209
|
+
// if livenessConfigs["feedBackCenterMessage"] != nil {
|
|
210
|
+
// facematch.setFeedBackCenterMessage(livenessConfigs["feedBackCenterMessage"] as! String)
|
|
211
|
+
// }
|
|
212
|
+
// facematch.setFeedbackMultipleFaceMessage(LivenessConfigs.feedBackMultipleFaceMessage)
|
|
213
|
+
// if livenessConfigs["feedBackMultipleFaceMessage"] != nil {
|
|
214
|
+
// facematch.setFeedbackMultipleFaceMessage(livenessConfigs["feedBackMultipleFaceMessage"] as! String)
|
|
215
|
+
// }
|
|
216
|
+
// facematch.setFeedBackFaceSteadymessage(LivenessConfigs.feedBackHeadStraightMessage)
|
|
217
|
+
// if livenessConfigs["feedBackHeadStraightMessage"] != nil {
|
|
218
|
+
// facematch.setFeedBackFaceSteadymessage(livenessConfigs["feedBackHeadStraightMessage"] as! String)
|
|
219
|
+
// }
|
|
220
|
+
// facematch.setFeedBackLowLightMessage(LivenessConfigs.feedBackLowLightMessage)
|
|
221
|
+
// if livenessConfigs["feedBackLowLightMessage"] != nil {
|
|
222
|
+
// facematch.setFeedBackLowLightMessage(livenessConfigs["feedBackLowLightMessage"] as! String)
|
|
223
|
+
// }
|
|
224
|
+
// facematch.setFeedBackBlurFaceMessage(LivenessConfigs.feedBackBlurFaceMessage)
|
|
225
|
+
// if livenessConfigs["feedBackBlurFaceMessage"] != nil {
|
|
226
|
+
// facematch.setFeedBackBlurFaceMessage(livenessConfigs["feedBackBlurFaceMessage"] as! String)
|
|
227
|
+
// }
|
|
228
|
+
// facematch.setFeedBackGlareFaceMessage(LivenessConfigs.feedBackGlareFaceMessage)
|
|
229
|
+
// if livenessConfigs["feedBackGlareFaceMessage"] != nil {
|
|
230
|
+
// facematch.setFeedBackGlareFaceMessage(livenessConfigs["feedBackGlareFaceMessage"] as! String)
|
|
231
|
+
// }
|
|
232
|
+
//// facematch.setFeedBackProcessingMessage(LivenessConfigs.feedBackProcessingMessage)
|
|
233
|
+
//// if livenessConfigs.index(forKey: "feedBackProcessingMessage") != nil {
|
|
234
|
+
//// facematch.setFeedBackProcessingMessage(livenessConfigs["feedBackProcessingMessage"] as! String)
|
|
235
|
+
//// }
|
|
236
|
+
//// facematch.isShowLogoImage(LivenessConfigs.isShowLogo)
|
|
237
|
+
//// if livenessConfigs.index(forKey: "isShowLogo") != nil {
|
|
238
|
+
//// facematch.isShowLogoImage(livenessConfigs["isShowLogo"] as! Bool)
|
|
239
|
+
//// }
|
|
240
|
+
//// facematch.setLogoImage("ic_logo.png")
|
|
241
|
+
//
|
|
242
|
+
// // 0 for clean face and 100 for Blurry face
|
|
243
|
+
// facematch.setBlurPercentage(Int32(LivenessConfigs.setBlurPercentage)) // set blure percentage -1 to remove this filter
|
|
244
|
+
//
|
|
245
|
+
// if livenessConfigs["setBlurPercentage"] != nil {
|
|
246
|
+
// facematch.setBlurPercentage(livenessConfigs["setBlurPercentage"] as! Int32)
|
|
247
|
+
// }
|
|
248
|
+
//
|
|
249
|
+
// var glarePerc0 = Int32(LivenessConfigs.setGlarePercentage_0)
|
|
250
|
+
// if livenessConfigs["setGlarePercentage_0"] != nil {
|
|
251
|
+
// glarePerc0 = livenessConfigs["setGlarePercentage_0"] as! Int32
|
|
252
|
+
// }
|
|
253
|
+
// var glarePerc1 = Int32(LivenessConfigs.setGlarePercentage_1)
|
|
254
|
+
// if livenessConfigs["setGlarePercentage_1"] != nil {
|
|
255
|
+
// glarePerc1 = livenessConfigs["setGlarePercentage_1"] as! Int32
|
|
256
|
+
// }
|
|
257
|
+
// // Set min and max percentage for glare
|
|
258
|
+
// facematch.setGlarePercentage(glarePerc0, glarePerc1) //set glaremin -1 and glaremax -1 to remove this filter
|
|
259
|
+
// // Do any additional setup after loading the view.
|
|
260
|
+
// facematch.setFacematch(self)
|
|
261
|
+
// }
|
|
262
|
+
|
|
263
|
+
func imageCamera1() {
|
|
264
|
+
DispatchQueue.main.asyncAfter(deadline: .now(), execute: {
|
|
265
|
+
self.facematch.setFacematch(self)
|
|
266
|
+
})
|
|
267
|
+
selectFirstImage = true
|
|
268
|
+
|
|
269
|
+
}
|
|
270
|
+
func imageGallery1() {
|
|
271
|
+
self.openPhotosLibrary(_isFirst: true)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
func imageCamera2() {
|
|
275
|
+
DispatchQueue.main.asyncAfter(deadline: .now(), execute: {
|
|
276
|
+
self.facematch.setFacematch(self)
|
|
277
|
+
self.view.setNeedsLayout()
|
|
278
|
+
})
|
|
279
|
+
selectFirstImage = false
|
|
280
|
+
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
func imageGallery2() {
|
|
284
|
+
self.openPhotosLibrary(_isFirst: false)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
func openPhotosLibrary(_isFirst: Bool){
|
|
288
|
+
//Check camera permission
|
|
289
|
+
let photos = PHPhotoLibrary.authorizationStatus()
|
|
290
|
+
if photos == .denied {
|
|
291
|
+
DispatchQueue.main.async {
|
|
292
|
+
let alert = UIAlertController(title: "AccuraFrame", message: "It looks like your privacy settings are preventing us from accessing your Photos", preferredStyle: .alert);
|
|
293
|
+
let defaultAction = UIAlertAction(title: "OK", style: .default) { _ in
|
|
294
|
+
if #available(iOS 10.0, *) {
|
|
295
|
+
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [:], completionHandler: nil)
|
|
296
|
+
} else {
|
|
297
|
+
UIApplication.shared.openURL(URL(string: UIApplication.openSettingsURLString)!)
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
alert.addAction(defaultAction)
|
|
301
|
+
self.present(alert, animated: true, completion: nil)
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if photos == .denied || photos == .notDetermined{
|
|
305
|
+
PHPhotoLibrary.requestAuthorization({status in
|
|
306
|
+
if status == .authorized{
|
|
307
|
+
DispatchQueue.main.async {
|
|
308
|
+
self.openGallary(_isFirst)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
}
|
|
312
|
+
})
|
|
313
|
+
}else if photos == .authorized{
|
|
314
|
+
DispatchQueue.main.async {
|
|
315
|
+
self.openGallary(_isFirst)
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
func openGallary(_ isFirst: Bool){
|
|
323
|
+
if #available(iOS 14, *) {
|
|
324
|
+
selectFirstImage = isFirst
|
|
325
|
+
// using PHPickerViewController
|
|
326
|
+
var config = PHPickerConfiguration(photoLibrary: PHPhotoLibrary.shared())
|
|
327
|
+
config.selectionLimit = 1
|
|
328
|
+
config.filter = .images
|
|
329
|
+
config.preferredAssetRepresentationMode = .current
|
|
330
|
+
let picker = PHPickerViewController(configuration: config)
|
|
331
|
+
picker.delegate = self
|
|
332
|
+
picker.presentationController?.delegate = self
|
|
333
|
+
self.present(picker, animated: true, completion: nil)
|
|
334
|
+
|
|
335
|
+
} else {
|
|
336
|
+
selectFirstImage = isFirst
|
|
337
|
+
self.imagePicker.sourceType = .photoLibrary
|
|
338
|
+
self.imagePicker.allowsEditing = false
|
|
339
|
+
self.present(self.imagePicker, animated: true, completion: nil)
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
//MARK:- Image Rotation
|
|
345
|
+
@objc func loadPhotoCaptured() {
|
|
346
|
+
let img = allImageViewsSubViews(imagePicker.viewControllers.first?.view)?.last
|
|
347
|
+
if img != nil {
|
|
348
|
+
if let imgView: UIImageView = img as? UIImageView{
|
|
349
|
+
imagePickerController(imagePicker, didFinishPickingMediaWithInfo: convertToUIImagePickerControllerInfoKeyDictionary([convertFromUIImagePickerControllerInfoKey(UIImagePickerController.InfoKey.originalImage) : imgView.image!]))
|
|
350
|
+
}
|
|
351
|
+
} else {
|
|
352
|
+
imagePicker.dismiss(animated: true)
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
func allImageViewsSubViews(_ view: UIView?) -> [AnyHashable]? {
|
|
357
|
+
var arrImageViews: [AnyHashable] = []
|
|
358
|
+
if (view is UIImageView) {
|
|
359
|
+
if let view = view {
|
|
360
|
+
arrImageViews.append(view)
|
|
361
|
+
}
|
|
362
|
+
} else {
|
|
363
|
+
for subview in view?.subviews ?? [] {
|
|
364
|
+
if let all = allImageViewsSubViews(subview) {
|
|
365
|
+
arrImageViews.append(contentsOf: all)
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return arrImageViews
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
//MARK:- ImagePicker delegate
|
|
374
|
+
func imagePickerController(_ picker: UIImagePickerController,
|
|
375
|
+
didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
|
|
376
|
+
// Local variable inserted by Swift 4.2 migrator.
|
|
377
|
+
let info = convertFromUIImagePickerControllerInfoKeyDictionary(info)
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
dismiss(animated: true, completion: nil)
|
|
381
|
+
SVProgressHUD.show(withStatus: "Loading...")
|
|
382
|
+
DispatchQueue.global(qos: .background).async {
|
|
383
|
+
guard var originalImage = info[convertFromUIImagePickerControllerInfoKey(UIImagePickerController.InfoKey.originalImage)] as? UIImage else { return }
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
//Image Resize
|
|
387
|
+
let ratio = CGFloat(originalImage.size.width) / originalImage.size.height
|
|
388
|
+
originalImage = self.compressimage(with: originalImage, convertTo: CGSize(width: 600 * ratio, height: 600))!
|
|
389
|
+
|
|
390
|
+
// let compressData = UIImage(data: originalImage.jpegData(compressionQuality: 1.0)!)
|
|
391
|
+
DispatchQueue.main.asyncAfter(deadline: .now(), execute: {
|
|
392
|
+
// self.setFaceRegion(compressData!)//Set FaceMatch score
|
|
393
|
+
SVProgressHUD.dismiss()
|
|
394
|
+
})
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
@available(iOS 14, *)
|
|
400
|
+
func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
|
|
401
|
+
dismiss(animated: true, completion: nil)
|
|
402
|
+
guard !results.isEmpty else {
|
|
403
|
+
callBack!(["Failed to get Facematch. Please try again", NSNull()])
|
|
404
|
+
EngineWrapper.faceEngineClose()
|
|
405
|
+
closeMe()
|
|
406
|
+
return
|
|
407
|
+
}
|
|
408
|
+
// request image urls
|
|
409
|
+
for result in results {
|
|
410
|
+
result.itemProvider.loadObject(ofClass: UIImage.self, completionHandler: { (object, error) in
|
|
411
|
+
if let image = object as? UIImage {
|
|
412
|
+
DispatchQueue.main.async { [self] in
|
|
413
|
+
// Use UIImage
|
|
414
|
+
let ratio = CGFloat(image.size.width) / image.size.height
|
|
415
|
+
let originalImage = self.compressimage(with: image, convertTo: CGSize(width: 600 * ratio, height: 600))!
|
|
416
|
+
|
|
417
|
+
let compressData = UIImage(data: originalImage.jpegData(compressionQuality: 1.0)!)
|
|
418
|
+
lvfm.face1Detect = EngineWrapper.detectSourceFaces(compressData)
|
|
419
|
+
|
|
420
|
+
// self.setFaceRegion(compressData!)//Set FaceMatch score
|
|
421
|
+
SVProgressHUD.dismiss()
|
|
422
|
+
var result:[String:Any] = [:]
|
|
423
|
+
result["Image"] = compressData
|
|
424
|
+
if result.index(forKey: "Image") != nil {
|
|
425
|
+
let img1 = AccurascanKyc.getImageUri(img: compressData!, name: nil)
|
|
426
|
+
result["Image"] = img1
|
|
427
|
+
if(lvfm.No == 1){
|
|
428
|
+
lvfm.face1 = compressData
|
|
429
|
+
if lvfm.face1 != nil && lvfm.face2 != nil {
|
|
430
|
+
lvfm.face1Detect = EngineWrapper.detectSourceFaces(lvfm.face1)
|
|
431
|
+
lvfm.face2Detect = EngineWrapper.detectTargetFaces(lvfm.face2, feature1: lvfm.face1Detect?.feature)
|
|
432
|
+
let fmSore = EngineWrapper.identify(lvfm.face1Detect?.feature, featurebuff2: lvfm.face2Detect?.feature)
|
|
433
|
+
let twoDecimalPlaces = String(format: "%.2f", fmSore*100)//Match score Convert Float Value
|
|
434
|
+
result["score"] = twoDecimalPlaces
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
if lvfm.No == 2 {
|
|
438
|
+
lvfm.face2 = compressData
|
|
439
|
+
if lvfm.face1 != nil && lvfm.face2 != nil {
|
|
440
|
+
lvfm.face1Detect = EngineWrapper.detectSourceFaces(lvfm.face1)
|
|
441
|
+
lvfm.face2Detect = EngineWrapper.detectTargetFaces(lvfm.face2, feature1: lvfm.face1Detect?.feature)
|
|
442
|
+
let fmSore = EngineWrapper.identify(lvfm.face1Detect?.feature, featurebuff2: lvfm.face2Detect?.feature)
|
|
443
|
+
let twoDecimalPlaces = String(format: "%.2f", fmSore*100)//Match score Convert Float Value
|
|
444
|
+
result["score"] = twoDecimalPlaces
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
callBack!([NSNull(),AccurascanKyc.convertJSONString(results:result)])
|
|
448
|
+
EngineWrapper.faceEngineClose()
|
|
449
|
+
closeMe()
|
|
450
|
+
} else {
|
|
451
|
+
|
|
452
|
+
callBack!(["Failed to get Facematch. Please try again", NSNull()])
|
|
453
|
+
EngineWrapper.faceEngineClose()
|
|
454
|
+
closeMe()
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
})
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
func presentationControllerWillDismiss(_ presentationController: UIPresentationController) {
|
|
463
|
+
// print("The user began to swipe down to dismiss.")
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
|
|
467
|
+
// print("The dismissal animation finished after the user swiped down.")
|
|
468
|
+
closeMe()
|
|
469
|
+
// This is probably where you want to put your code that you want to call.
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
func facematchData(_ FaceImage: UIImage!) {
|
|
474
|
+
SVProgressHUD.show(withStatus: "Loading...")
|
|
475
|
+
DispatchQueue.global(qos: .background).async { [self] in
|
|
476
|
+
var originalImage = FaceImage
|
|
477
|
+
|
|
478
|
+
//Image Resize
|
|
479
|
+
let ratio = CGFloat(FaceImage.size.width) / originalImage!.size.height
|
|
480
|
+
originalImage = self.compressimage(with: originalImage, convertTo: CGSize(width: 600 * ratio, height: 600))!
|
|
481
|
+
var result:[String:Any] = [:]
|
|
482
|
+
let compressData = UIImage(data: FaceImage.jpegData(compressionQuality: 1.0)!)
|
|
483
|
+
// DispatchQueue.main.asyncAfter(deadline: .now(), execute: { [self] in
|
|
484
|
+
// self.setFaceRegion(compressData!)//Set FaceMatch score
|
|
485
|
+
// gl.face1Detect = EngineWrapper.detectSourceFaces(compressData)
|
|
486
|
+
SVProgressHUD.dismiss()
|
|
487
|
+
// })
|
|
488
|
+
let img1 = AccurascanKyc.getImageUri(img: compressData!, name: nil)
|
|
489
|
+
result["Image"] = img1
|
|
490
|
+
if(lvfm.No == 1){
|
|
491
|
+
lvfm.face1 = compressData
|
|
492
|
+
if lvfm.face1 != nil && lvfm.face2 != nil {
|
|
493
|
+
lvfm.face1Detect = EngineWrapper.detectSourceFaces(lvfm.face1)
|
|
494
|
+
lvfm.face2Detect = EngineWrapper.detectTargetFaces(lvfm.face2, feature1: lvfm.face1Detect?.feature)
|
|
495
|
+
let fmSore = EngineWrapper.identify(lvfm.face1Detect?.feature, featurebuff2: lvfm.face2Detect?.feature)
|
|
496
|
+
let twoDecimalPlaces = String(format: "%.2f", fmSore*100)//Match score Convert Float Value
|
|
497
|
+
result["score"] = twoDecimalPlaces
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
if lvfm.No == 2 {
|
|
501
|
+
lvfm.face2 = compressData
|
|
502
|
+
if lvfm.face1 != nil && lvfm.face2 != nil {
|
|
503
|
+
lvfm.face1Detect = EngineWrapper.detectSourceFaces(lvfm.face1)
|
|
504
|
+
lvfm.face2Detect = EngineWrapper.detectTargetFaces(lvfm.face2, feature1: lvfm.face1Detect?.feature)
|
|
505
|
+
let fmSore = EngineWrapper.identify(lvfm.face1Detect?.feature, featurebuff2: lvfm.face2Detect?.feature)
|
|
506
|
+
let twoDecimalPlaces = String(format: "%.2f", fmSore*100)//Match score Convert Float Value
|
|
507
|
+
result["score"] = twoDecimalPlaces
|
|
508
|
+
print(twoDecimalPlaces)
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
}
|
|
512
|
+
callBack!([NSNull(),AccurascanKyc.convertJSONString(results:result)])
|
|
513
|
+
EngineWrapper.faceEngineClose()
|
|
514
|
+
closeMe()
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
func compressimage(with image: UIImage?, convertTo size: CGSize) -> UIImage? {
|
|
520
|
+
UIGraphicsBeginImageContext(size)
|
|
521
|
+
image?.draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height))
|
|
522
|
+
let destImage = UIGraphicsGetImageFromCurrentImageContext()
|
|
523
|
+
UIGraphicsEndImageContext()
|
|
524
|
+
return destImage
|
|
525
|
+
}
|
|
526
|
+
fileprivate func convertFromUIImagePickerControllerInfoKeyDictionary(_ input: [UIImagePickerController.InfoKey: Any]) -> [String: Any] {
|
|
527
|
+
return Dictionary(uniqueKeysWithValues: input.map {key, value in (key.rawValue, value)})
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// Helper function inserted by Swift 4.2 migrator.
|
|
533
|
+
fileprivate func convertToUIImagePickerControllerInfoKeyDictionary(_ input: [String: Any]) -> [UIImagePickerController.InfoKey: Any] {
|
|
534
|
+
return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIImagePickerController.InfoKey(rawValue: key), value)})
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// Helper function inserted by Swift 4.2 migrator.
|
|
538
|
+
fileprivate func convertFromUIImagePickerControllerInfoKey(_ input: UIImagePickerController.InfoKey) -> String {
|
|
539
|
+
return input.rawValue
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
extension UIImage {
|
|
543
|
+
func resizeWithPercent(percentage: CGFloat) -> UIImage? {
|
|
544
|
+
let imageView = UIImageView(frame: CGRect(origin: .zero, size: CGSize(width: size.width * percentage, height: size.height * percentage)))
|
|
545
|
+
imageView.contentMode = .scaleAspectFit
|
|
546
|
+
imageView.image = self
|
|
547
|
+
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, false, scale)
|
|
548
|
+
guard let context = UIGraphicsGetCurrentContext() else { return nil }
|
|
549
|
+
imageView.layer.render(in: context)
|
|
550
|
+
guard let result = UIGraphicsGetImageFromCurrentImageContext() else { return nil }
|
|
551
|
+
UIGraphicsEndImageContext()
|
|
552
|
+
return result
|
|
553
|
+
}
|
|
554
|
+
func resizeWithWidth(width: CGFloat, height:CGFloat) -> UIImage? {
|
|
555
|
+
let imageView = UIImageView(frame: CGRect(origin: .zero, size: CGSize(width: width, height: height)))
|
|
556
|
+
imageView.contentMode = .scaleAspectFit
|
|
557
|
+
imageView.image = self
|
|
558
|
+
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, false, scale)
|
|
559
|
+
guard let context = UIGraphicsGetCurrentContext() else { return nil }
|
|
560
|
+
imageView.layer.render(in: context)
|
|
561
|
+
guard let result = UIGraphicsGetImageFromCurrentImageContext() else { return nil }
|
|
562
|
+
UIGraphicsEndImageContext()
|
|
563
|
+
return result
|
|
564
|
+
}
|
|
565
|
+
func resizeWithWidth(width: CGFloat) -> UIImage? {
|
|
566
|
+
let imageView = UIImageView(frame: CGRect(origin: .zero, size: CGSize(width: width, height: CGFloat(ceil(width/size.width * size.height)))))
|
|
567
|
+
imageView.contentMode = .scaleAspectFit
|
|
568
|
+
imageView.image = self
|
|
569
|
+
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, false, scale)
|
|
570
|
+
guard let context = UIGraphicsGetCurrentContext() else { return nil }
|
|
571
|
+
imageView.layer.render(in: context)
|
|
572
|
+
guard let result = UIGraphicsGetImageFromCurrentImageContext() else { return nil }
|
|
573
|
+
UIGraphicsEndImageContext()
|
|
574
|
+
return result
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
extension FMController: FacematchData{
|
|
581
|
+
func facematchViewDisappear() {
|
|
582
|
+
closeMe()
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
}
|
|
587
|
+
|