Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fiin_sdk_ios
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nguyen Van An
fiin_sdk_ios
Commits
10b7da10
Commit
10b7da10
authored
Oct 16, 2020
by
Nguyen Huy Nhat Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add frame
parent
6316f203
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
221 additions
and
62 deletions
+221
-62
OCR-SDK.xcworkspace/xcuserdata/itsol.xcuserdatad/UserInterfaceState.xcuserstate
...userdata/itsol.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
OCR-SDK/SB_KYC_SDK.swift
OCR-SDK/SB_KYC_SDK.swift
+3
-3
OCR-SDK/UI/SBKCaptureCard/SBKValidateCardView.swift
OCR-SDK/UI/SBKCaptureCard/SBKValidateCardView.swift
+21
-5
OCR-SDK/UI/SBKCaptureCard/SBKValidateCardView.xib
OCR-SDK/UI/SBKCaptureCard/SBKValidateCardView.xib
+73
-17
OCR-SDK/UI/SBKRecordFace/SBKRecordFaceView.swift
OCR-SDK/UI/SBKRecordFace/SBKRecordFaceView.swift
+122
-36
OCR-SDK/UI/SBKRecordFace/SBKRecordFaceView.xib
OCR-SDK/UI/SBKRecordFace/SBKRecordFaceView.xib
+2
-1
No files found.
OCR-SDK.xcworkspace/xcuserdata/itsol.xcuserdatad/UserInterfaceState.xcuserstate
View file @
10b7da10
No preview for this file type
OCR-SDK/SB_KYC_SDK.swift
View file @
10b7da10
...
...
@@ -78,12 +78,12 @@ public class SB_KYC_SDK {
//Call API face
//input: UIImage
public
func
eKycFaceMatch
(
imageFace
:
CVPixelBuffer
,
imageCardFront
:
CVPixelBuffer
,
imageCardBack
:
CVPixelBuffer
,
completion
:
@escaping
CompletionHandle
)
{
public
func
eKycFaceMatch
(
imageFace
:
Data
,
imageCardFront
:
Data
,
imageCardBack
:
Data
,
completion
:
@escaping
CompletionHandle
)
{
SBKValidateInput
.
shared
.
validateFace
(
imageFace
:
imageFace
)
{[
weak
self
]
data
in
guard
self
!=
nil
else
{
return
}
if
data
{
Global
.
imageCard1
=
SBKValidateInput
.
shared
.
convertCVPixelToUIImage
(
pixelBuffer
:
imageCardFront
)
.
pngData
()
Global
.
imageCard2
=
SBKValidateInput
.
shared
.
convertCVPixelToUIImage
(
pixelBuffer
:
imageCardFront
)
.
pngData
()
Global
.
imageCard1
=
imageCardFront
Global
.
imageCard2
=
imageCardBack
let
imageFaceUI
=
SBKValidateInput
.
shared
.
convertCVPixelToUIImage
(
pixelBuffer
:
imageFace
)
.
pngData
()
SBOCRRequest
.
shared
.
processFace
(
image
:
imageFaceUI
!
,
pathURL
:
Global
.
url_face
,
idBack
:
""
,
idFront
:
""
)
{(
errorCode
,
data
)
->
Void
in
...
...
OCR-SDK/UI/SBKCaptureCard/SBKValidateCardView.swift
View file @
10b7da10
...
...
@@ -13,8 +13,15 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate {
let
nibName
=
"SBKValidateCardView"
var
contentView
:
UIView
?
// @IBOutlet public weak var viewCamera: UIView!
// @IBOutlet public weak var btnTakePhoto: UIButton!
@IBOutlet
public
weak
var
viewCamera
:
UIView
!
@IBOutlet
public
weak
var
btnTakePhoto
:
UIButton
!
@IBOutlet
public
weak
var
lbDescription
:
UILabel
!
@IBOutlet
public
weak
var
lbCopyright
:
UILabel
!
@IBOutlet
public
weak
var
lbStep
:
UILabel
!
@IBOutlet
public
weak
var
btnCapture
:
UIButton
!
@IBOutlet
public
weak
var
imgCaution
:
UIImageView
!
public
var
captureSession
:
AVCaptureSession
=
AVCaptureSession
()
public
var
stillImageOutput
:
AVCapturePhotoOutput
=
AVCapturePhotoOutput
()
...
...
@@ -64,6 +71,14 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate {
}
self
.
loadCamera
()
let
label
=
UILabel
()
label
.
frame
=
CGRect
(
x
:
self
.
center
.
x
-
50
,
y
:
self
.
frame
.
size
.
height
/
8
+
self
.
viewCamera
.
frame
.
origin
.
y
-
40
,
width
:
100
,
height
:
20
)
label
.
textAlignment
=
.
center
label
.
text
=
self
.
typeCamera
==
TypeCard
.
FRONT
?
"Use front"
:
"Use back"
label
.
textColor
=
UIColor
.
white
self
.
addSubview
(
label
)
}
func
loadViewFromNib
()
->
UIView
?
{
...
...
@@ -80,7 +95,7 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate {
let
topLeft
=
CGPoint
(
x
:
fWidth
/
2
-
squareWidth
/
3
,
y
:
fHeight
/
4
)
if
iconTakeCard
!=
nil
{
self
.
btn
TakePhoto
.
setImage
(
iconTakeCard
,
for
:
.
normal
)
self
.
btn
Capture
.
setImage
(
iconTakeCard
,
for
:
.
normal
)
}
if
iconFrameTopLeft
!=
nil
{
...
...
@@ -212,7 +227,7 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate {
// self.captureSession.stopRunning()
// self.captureSession.removeOutput(self.videoDataOutput)
// self.captureSession.removeOutput(self.stillImageOutput)
let
cropImage
=
self
.
cropImage
(
image
:
UIImage
(
data
:
imageData
)
!
,
rect
:
CGRect
(
x
:
UIImage
(
data
:
imageData
)
!.
size
.
width
/
20
,
y
:
UIImage
(
data
:
imageData
)
!.
size
.
height
*
6
/
20
,
width
:
self
.
viewCamera
.
frame
.
size
.
width
*
18
/
20
,
height
:
self
.
viewCamera
.
frame
.
size
.
width
*
18
*
3
/
20
/
4
),
scale
:
1.0
)
let
cropImage
=
self
.
cropImage
(
image
:
UIImage
(
data
:
imageData
)
!
,
rect
:
CGRect
(
x
:
UIImage
(
data
:
imageData
)
!.
size
.
width
/
20
,
y
:
UIImage
(
data
:
imageData
)
!.
size
.
height
*
4.5
/
20
,
width
:
self
.
viewCamera
.
frame
.
size
.
width
*
18
/
20
,
height
:
self
.
viewCamera
.
frame
.
size
.
width
*
18
*
3
/
20
/
4
),
scale
:
1.0
)
self
.
completionSuccessCardStep
(
nil
,
cropImage
!.
pngData
()
!
,
nil
)
}
...
...
@@ -249,7 +264,7 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate {
if
UIDevice
.
current
.
userInterfaceIdiom
==
.
pad
{
imageOutput
=
validateView
.
cropImage
(
image
:
imageInput
,
rect
:
CGRect
(
x
:
imageInput
.
size
.
width
/
20
,
y
:
imageInput
.
size
.
height
*
2
/
7
,
width
:
imageInput
.
size
.
width
-
imageInput
.
size
.
width
/
10
,
height
:
(
imageInput
.
size
.
width
-
imageInput
.
size
.
width
/
10
)
*
3
/
4
),
scale
:
1.0
)
}
else
{
imageOutput
=
validateView
.
cropImage
(
image
:
imageInput
,
rect
:
CGRect
(
x
:
imageInput
.
size
.
width
/
20
,
y
:
imageInput
.
size
.
height
*
2
/
7
,
width
:
imageInput
.
size
.
width
-
imageInput
.
size
.
width
/
10
,
height
:
(
imageInput
.
size
.
width
-
imageInput
.
size
.
width
/
10
)
*
3
/
4
),
scale
:
1.0
)
imageOutput
=
validateView
.
cropImage
(
image
:
imageInput
,
rect
:
CGRect
(
x
:
imageInput
.
size
.
width
/
20
,
y
:
imageInput
.
size
.
height
*
1.5
/
7
,
width
:
imageInput
.
size
.
width
-
imageInput
.
size
.
width
/
10
,
height
:
(
imageInput
.
size
.
width
-
imageInput
.
size
.
width
/
10
)
*
3
/
4
+
7
),
scale
:
1.0
)
}
let
ciimage
=
CIImage
(
image
:
imageOutput
!
)
...
...
@@ -286,6 +301,7 @@ extension SBKValidateCardView: AVCaptureVideoDataOutputSampleBufferDelegate {
self
.
completionSuccessCardStep
(
validateImageCard
,
nil
,
nil
)
self
.
statusValidateImage
=
validateImageCard
self
.
lbDescription
.
text
=
validateImageCard
.
rawValue
}
}
}
OCR-SDK/UI/SBKCaptureCard/SBKValidateCardView.xib
View file @
10b7da10
<?xml version="1.0" encoding="UTF-8"?>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.XIB"
version=
"3.0"
toolsVersion=
"1
6097.3
"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
useTraitCollections=
"YES"
useSafeAreas=
"YES"
colorMatched=
"YES"
>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.XIB"
version=
"3.0"
toolsVersion=
"1
7156
"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
useTraitCollections=
"YES"
useSafeAreas=
"YES"
colorMatched=
"YES"
>
<device
id=
"retina6_1"
orientation=
"portrait"
appearance=
"light"
/>
<dependencies>
<deployment
identifier=
"iOS"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"1
6087
"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"1
7125
"
/>
<capability
name=
"Safe area layout guides"
minToolsVersion=
"9.0"
/>
<capability
name=
"documents saved in the Xcode 8 format"
minToolsVersion=
"8.0"
/>
</dependencies>
<objects>
<placeholder
placeholderIdentifier=
"IBFilesOwner"
id=
"-1"
userLabel=
"File's Owner"
customClass=
"SBKValidateCardView"
customModule=
"SB_KYC_SDK"
customModuleProvider=
"target"
>
<connections>
<outlet
property=
"btnTakePhoto"
destination=
"MUh-i4-cOT"
id=
"XIX-vk-Xo9"
/>
<outlet
property=
"viewCamera"
destination=
"vId-Gb-QYw"
id=
"dO3-YL-g95"
/>
<outlet
property=
"btnCapture"
destination=
"0tu-Uu-aZJ"
id=
"hbb-5m-asu"
/>
<outlet
property=
"imgCaution"
destination=
"Uu0-ZS-WyV"
id=
"FwQ-r8-w9z"
/>
<outlet
property=
"lbCopyright"
destination=
"Yoc-45-cmQ"
id=
"3OV-hF-Q8k"
/>
<outlet
property=
"lbDescription"
destination=
"wnG-jG-HwA"
id=
"dai-gb-2uU"
/>
<outlet
property=
"lbStep"
destination=
"miZ-LC-N58"
id=
"nFu-j2-7oT"
/>
<outlet
property=
"viewCamera"
destination=
"lKp-BC-igm"
id=
"SQO-Z9-Rni"
/>
</connections>
</placeholder>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"-2"
customClass=
"UIResponder"
/>
...
...
@@ -19,36 +23,88 @@
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"896"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<subviews>
<view
contentMode=
"scaleToFill"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"vId-Gb-QYw"
>
<rect
key=
"frame"
x=
"0.0"
y=
"44"
width=
"414"
height=
"698"
/>
<view
contentMode=
"scaleToFill"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"bMq-BQ-SN5"
>
<rect
key=
"frame"
x=
"173.5"
y=
"731.5"
width=
"67"
height=
"20.5"
/>
<subviews>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"Step 1/3"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"miZ-LC-N58"
>
<rect
key=
"frame"
x=
"10"
y=
"3"
width=
"47"
height=
"14.5"
/>
<color
key=
"backgroundColor"
white=
"0.0"
alpha=
"0.0"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"12"
/>
<color
key=
"textColor"
white=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<nil
key=
"highlightedColor"
/>
</label>
</subviews>
<color
key=
"backgroundColor"
red=
"0.54183894399999999"
green=
"0.5419179797"
blue=
"0.54181402919999999"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB"
/>
<constraints>
<constraint
firstAttribute=
"bottom"
secondItem=
"miZ-LC-N58"
secondAttribute=
"bottom"
constant=
"3"
id=
"0lx-4s-sHT"
/>
<constraint
firstItem=
"miZ-LC-N58"
firstAttribute=
"leading"
secondItem=
"bMq-BQ-SN5"
secondAttribute=
"leading"
constant=
"10"
id=
"7aK-qy-Jmn"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"miZ-LC-N58"
secondAttribute=
"trailing"
constant=
"10"
id=
"Tib-gw-Wyo"
/>
<constraint
firstItem=
"miZ-LC-N58"
firstAttribute=
"top"
secondItem=
"bMq-BQ-SN5"
secondAttribute=
"top"
constant=
"3"
id=
"dqu-js-W96"
/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute
type=
"number"
keyPath=
"cornerRadius"
>
<integer
key=
"value"
value=
"3"
/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
<view
contentMode=
"scaleToFill"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"lKp-BC-igm"
>
<rect
key=
"frame"
x=
"0.0"
y=
"44"
width=
"414"
height=
"818"
/>
<color
key=
"backgroundColor"
white=
"0.66666666669999997"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
</view>
<button
opaque=
"NO"
contentMode=
"scaleToFill"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"MUh-i4-cOT"
>
<label
hidden=
"YES"
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"Use front"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"Yoc-45-cmQ"
>
<rect
key=
"frame"
x=
"171.5"
y=
"123.5"
width=
"71"
height=
"20.5"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"17"
/>
<color
key=
"textColor"
white=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<nil
key=
"highlightedColor"
/>
</label>
<imageView
hidden=
"YES"
clipsSubviews=
"YES"
userInteractionEnabled=
"NO"
contentMode=
"scaleAspectFit"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
image=
"Caution.png"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"Uu0-ZS-WyV"
>
<rect
key=
"frame"
x=
"147"
y=
"629"
width=
"120"
height=
"32"
/>
<constraints>
<constraint
firstAttribute=
"width"
constant=
"120"
id=
"NyR-vg-E0a"
/>
<constraint
firstAttribute=
"height"
constant=
"32"
id=
"gHe-IN-Yuj"
/>
</constraints>
</imageView>
<button
opaque=
"NO"
contentMode=
"scaleToFill"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"0tu-Uu-aZJ"
>
<rect
key=
"frame"
x=
"182"
y=
"782"
width=
"50"
height=
"50"
/>
<constraints>
<constraint
firstAttribute=
"height"
constant=
"50"
id=
"
dPQ-aO-sFP
"
/>
<constraint
firstAttribute=
"width"
constant=
"50"
id=
"
nMV-8l-zek
"
/>
<constraint
firstAttribute=
"height"
constant=
"50"
id=
"
MGa-aI-9ef
"
/>
<constraint
firstAttribute=
"width"
constant=
"50"
id=
"
hiM-7d-T1r
"
/>
</constraints>
<state
key=
"normal"
image=
"iconCap.png"
/>
<connections>
<action
selector=
"onCapturePhoto:"
destination=
"-1"
eventType=
"touchUpInside"
id=
"
bv8-Oo-gSm
"
/>
<action
selector=
"onCapturePhoto:"
destination=
"-1"
eventType=
"touchUpInside"
id=
"
Vg0-NJ-EOP
"
/>
</connections>
</button>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
" "
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"wnG-jG-HwA"
>
<rect
key=
"frame"
x=
"205"
y=
"681"
width=
"4.5"
height=
"20.5"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"17"
/>
<color
key=
"textColor"
white=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<nil
key=
"highlightedColor"
/>
</label>
</subviews>
<viewLayoutGuide
key=
"safeArea"
id=
"hB9-pv-7hU"
/>
<color
key=
"backgroundColor"
white=
"0.0"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<constraints>
<constraint
firstItem=
"MUh-i4-cOT"
firstAttribute=
"top"
secondItem=
"vId-Gb-QYw"
secondAttribute=
"bottom"
constant=
"40"
id=
"5HA-ie-rYI"
/>
<constraint
firstItem=
"vId-Gb-QYw"
firstAttribute=
"top"
secondItem=
"hB9-pv-7hU"
secondAttribute=
"top"
id=
"9yW-SW-kTY"
/>
<constraint
firstItem=
"vId-Gb-QYw"
firstAttribute=
"leading"
secondItem=
"tMz-JL-QhO"
secondAttribute=
"leading"
id=
"COE-Wm-3Sg"
/>
<constraint
firstItem=
"hB9-pv-7hU"
firstAttribute=
"bottom"
secondItem=
"MUh-i4-cOT"
secondAttribute=
"bottom"
constant=
"30"
id=
"G5T-sy-Cra"
/>
<constraint
firstItem=
"MUh-i4-cOT"
firstAttribute=
"centerX"
secondItem=
"hB9-pv-7hU"
secondAttribute=
"centerX"
id=
"RAV-Ta-Xst"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"vId-Gb-QYw"
secondAttribute=
"trailing"
id=
"U1Q-AI-Opp"
/>
<constraint
firstItem=
"bMq-BQ-SN5"
firstAttribute=
"top"
secondItem=
"wnG-jG-HwA"
secondAttribute=
"bottom"
constant=
"30"
id=
"3RZ-t3-RxF"
/>
<constraint
firstItem=
"0tu-Uu-aZJ"
firstAttribute=
"centerX"
secondItem=
"hB9-pv-7hU"
secondAttribute=
"centerX"
id=
"446-x7-rap"
/>
<constraint
firstItem=
"0tu-Uu-aZJ"
firstAttribute=
"top"
secondItem=
"bMq-BQ-SN5"
secondAttribute=
"bottom"
constant=
"30"
id=
"9ne-hi-Dep"
/>
<constraint
firstItem=
"bMq-BQ-SN5"
firstAttribute=
"centerX"
secondItem=
"hB9-pv-7hU"
secondAttribute=
"centerX"
id=
"Cej-FU-Dtq"
/>
<constraint
firstItem=
"lKp-BC-igm"
firstAttribute=
"leading"
secondItem=
"hB9-pv-7hU"
secondAttribute=
"leading"
id=
"Feg-QV-jKA"
/>
<constraint
firstItem=
"lKp-BC-igm"
firstAttribute=
"top"
secondItem=
"hB9-pv-7hU"
secondAttribute=
"top"
id=
"M7T-cU-AYs"
/>
<constraint
firstItem=
"Uu0-ZS-WyV"
firstAttribute=
"centerX"
secondItem=
"hB9-pv-7hU"
secondAttribute=
"centerX"
id=
"RJl-D9-e7j"
/>
<constraint
firstItem=
"hB9-pv-7hU"
firstAttribute=
"trailing"
secondItem=
"lKp-BC-igm"
secondAttribute=
"trailing"
id=
"V4W-de-wre"
/>
<constraint
firstItem=
"lKp-BC-igm"
firstAttribute=
"top"
secondItem=
"Yoc-45-cmQ"
secondAttribute=
"bottom"
constant=
"-100"
id=
"ZhS-dd-cGP"
/>
<constraint
firstItem=
"hB9-pv-7hU"
firstAttribute=
"bottom"
secondItem=
"lKp-BC-igm"
secondAttribute=
"bottom"
id=
"bsH-Lw-Emb"
/>
<constraint
firstItem=
"wnG-jG-HwA"
firstAttribute=
"top"
secondItem=
"Uu0-ZS-WyV"
secondAttribute=
"bottom"
constant=
"20"
id=
"eIh-l6-wou"
/>
<constraint
firstItem=
"wnG-jG-HwA"
firstAttribute=
"centerX"
secondItem=
"hB9-pv-7hU"
secondAttribute=
"centerX"
id=
"mg9-DV-NWp"
/>
<constraint
firstItem=
"Yoc-45-cmQ"
firstAttribute=
"centerX"
secondItem=
"hB9-pv-7hU"
secondAttribute=
"centerX"
id=
"qpt-JY-I2K"
/>
<constraint
firstItem=
"hB9-pv-7hU"
firstAttribute=
"bottom"
secondItem=
"0tu-Uu-aZJ"
secondAttribute=
"bottom"
constant=
"30"
id=
"zb1-xI-WE2"
/>
</constraints>
<viewLayoutGuide
key=
"safeArea"
id=
"hB9-pv-7hU"
/>
<point
key=
"canvasLocation"
x=
"133"
y=
"154"
/>
</view>
</objects>
<resources>
<image
name=
"Caution.png"
width=
"84.5"
height=
"84.5"
/>
<image
name=
"iconCap.png"
width=
"172"
height=
"172"
/>
</resources>
</document>
OCR-SDK/UI/SBKRecordFace/SBKRecordFaceView.swift
View file @
10b7da10
...
...
@@ -22,6 +22,7 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
@IBOutlet
weak
var
viewCheckStep2
:
UIView
!
@IBOutlet
weak
var
viewCheckStep3
:
UIView
!
@IBOutlet
weak
var
imageDescription
:
UIImageView
!
@IBOutlet
weak
var
stackView
:
UIStackView
!
private
let
captureSession
=
AVCaptureSession
()
private
lazy
var
previewLayer
=
AVCaptureVideoPreviewLayer
(
session
:
self
.
captureSession
)
...
...
@@ -49,6 +50,7 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
public
var
timeSpace
:
Int
=
3
public
var
zoom
:
CGFloat
=
1.0
public
var
imageStartRecord
:
UIImage
?
public
var
checkStep
:
Int
=
0
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
...
...
@@ -108,11 +110,10 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
if
let
viewWithTag
=
self
.
viewWithTag
(
1
)
{
viewWithTag
.
removeFromSuperview
()
}
let
originYLBCopyright
=
self
.
lbCopyright
.
frame
.
origin
.
y
/
896
*
self
.
bounds
.
height
let
heightLBCopyright
=
self
.
lbCopyright
.
frame
.
height
/
896
*
self
.
bounds
.
height
let
locationTop
=
originYLBCopyright
+
heightLBCopyright
+
35
let
originYLBDescription
=
self
.
lbDescription
.
frame
.
origin
.
y
/
896
*
self
.
bounds
.
height
let
locationTop
=
self
.
bounds
.
origin
.
y
+
35
let
originYLBDescription
=
self
.
stackView
.
frame
.
origin
.
y
/
896
*
self
.
bounds
.
height
let
heightOval
=
originYLBDescription
-
locationTop
...
...
@@ -153,11 +154,9 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
}
func
createOverlay
(
frame
:
CGRect
,
xOffset
:
CGFloat
,
yOffset
:
CGFloat
,
radius
:
CGFloat
)
{
let
originYLBCopyright
=
self
.
lbCopyright
.
frame
.
origin
.
y
/
896
*
self
.
bounds
.
height
let
heightLBCopyright
=
self
.
lbCopyright
.
frame
.
height
/
896
*
self
.
bounds
.
height
let
locationTop
=
originYLBCopyright
+
heightLBCopyright
+
35
let
locationTop
=
self
.
bounds
.
origin
.
y
+
35
let
originYLBDescription
=
self
.
lbDescription
.
frame
.
origin
.
y
/
896
*
self
.
bounds
.
height
let
originYLBDescription
=
self
.
stackView
.
frame
.
origin
.
y
/
896
*
self
.
bounds
.
height
let
heightOval
=
originYLBDescription
-
locationTop
...
...
@@ -211,45 +210,88 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
let
ciimage
:
CIImage
=
CIImage
(
cvPixelBuffer
:
pixelBuffer
)
let
imageView
:
UIImage
=
SBKValidateInput
.
shared
.
convertCIToUIImage
(
cmage
:
ciimage
)
if
self
.
result
!
[
0
]
<
self
.
result
!
[
1
]
{
if
statusFace
==
.
STRAIGHTFACE
&&
0
<=
self
.
timeRecord
&&
self
.
timeRecord
<
self
.
timeSpace
{
// if statusFace == .STRAIGHTFACE && 0 <= self.timeRecord && self.timeRecord < self.timeSpace {
// if self.dataImageSuccess.count == 0 {
// self.dataImageSuccess.append(imageView.pngData()!)
// }
// self.completionSuccessFaceRecordStep(.FACE_STRAIGHT, nil, nil)
// if 1 <= self.timeRecord {
// self.lbDescription.textColor = UIColor.green
// self.lbDescription.text = " ".localized()
// }
// } else if statusFace != .STRAIGHTFACE && 1 <= self.timeRecord && self.timeRecord < self.timeSpace {
// self.lbDescription.textColor = UIColor.red
// self.lbDescription.text = " ".localized()
// self.completionSuccessFaceRecordStep(.FACE_STRAIGHT_FAILD, nil, nil)
// } else if statusFace == .TORIGHT && self.timeSpace <= self.timeRecord && self.timeRecord < self.timeSpace * 2 {
// self.lbDescription.textColor = UIColor.green
// self.lbDescription.text = " ".localized()
// self.completionSuccessFaceRecordStep(.FACE_RIGHT, nil, nil)
// if self.dataImageSuccess.count == 1 {
// self.dataImageSuccess.append(imageView.pngData()!)
// }
// } else if statusFace != .TORIGHT && self.timeSpace <= self.timeRecord && self.timeRecord < self.timeSpace * 2 {
// self.lbDescription.textColor = UIColor.red
// self.lbDescription.text = " ".localized()
// self.completionSuccessFaceRecordStep(.FACE_RIGHT_FAILD, nil, nil)
// } else if statusFace == .TOLEFT && self.timeSpace * 2 <= self.timeRecord && self.timeRecord < self.timeSpace * 3 {
// self.lbDescription.textColor = UIColor.green
// self.lbDescription.text = " ".localized()
// self.completionSuccessFaceRecordStep(.FACE_LEFT, nil, nil)
// if self.dataImageSuccess.count == 2 {
// self.dataImageSuccess.append(imageView.pngData()!)
// }
// } else if statusFace != .TOLEFT && self.timeSpace * 2 <= self.timeRecord && self.timeRecord < self.timeSpace * 3 {
// self.lbDescription.textColor = UIColor.red
// self.lbDescription.text = " ".localized()
// self.completionSuccessFaceRecordStep(.FACE_LEFT_FAILD, nil, nil)
// }
if
statusFace
==
.
STRAIGHTFACE
&&
self
.
checkStep
==
0
{
if
self
.
dataImageSuccess
.
count
==
0
{
self
.
dataImageSuccess
.
append
(
imageView
.
pngData
()
!
)
}
self
.
completionSuccessFaceRecordStep
(
.
FACE_STRAIGHT
,
nil
,
nil
)
if
1
<=
self
.
timeRecord
{
self
.
lbDescription
.
textColor
=
UIColor
.
green
self
.
lbDescription
.
text
=
" "
.
localized
()
}
}
else
if
statusFace
!=
.
STRAIGHTFACE
&&
1
<=
self
.
timeRecord
&&
self
.
timeRecord
<
self
.
timeSpace
{
self
.
lbDescription
.
text
=
"Exactly"
.
localized
()
self
.
checkStep
=
1
self
.
viewCheckStep1
.
backgroundColor
=
UIColor
.
colorFromHexa
(
"#FBA02E"
)
}
else
if
statusFace
!=
.
STRAIGHTFACE
&&
self
.
checkStep
==
0
{
self
.
lbDescription
.
textColor
=
UIColor
.
red
self
.
lbDescription
.
text
=
" "
.
localized
()
self
.
lbDescription
.
text
=
"Please look straight"
.
localized
()
self
.
viewCheckStep1
.
backgroundColor
=
UIColor
.
colorFromHexa
(
"#FE3500"
)
self
.
completionSuccessFaceRecordStep
(
.
FACE_STRAIGHT_FAILD
,
nil
,
nil
)
}
else
if
statusFace
==
.
TORIGHT
&&
self
.
timeSpace
<=
self
.
timeRecord
&&
self
.
timeRecord
<
self
.
timeSpace
*
2
{
}
else
if
statusFace
==
.
TORIGHT
&&
self
.
checkStep
==
1
{
self
.
lbDescription
.
textColor
=
UIColor
.
green
self
.
lbDescription
.
text
=
" "
.
localized
()
self
.
lbDescription
.
text
=
"Exactly"
.
localized
()
self
.
checkStep
=
2
self
.
viewCheckStep2
.
backgroundColor
=
UIColor
.
colorFromHexa
(
"#FBA02E"
)
self
.
completionSuccessFaceRecordStep
(
.
FACE_RIGHT
,
nil
,
nil
)
if
self
.
dataImageSuccess
.
count
==
1
{
self
.
dataImageSuccess
.
append
(
imageView
.
pngData
()
!
)
}
}
else
if
statusFace
!=
.
TORIGHT
&&
self
.
timeSpace
<=
self
.
timeRecord
&&
self
.
timeRecord
<
self
.
timeSpace
*
2
{
}
else
if
statusFace
!=
.
TORIGHT
&&
self
.
checkStep
==
1
{
self
.
lbDescription
.
textColor
=
UIColor
.
red
self
.
lbDescription
.
text
=
"
"
.
localized
()
self
.
lbDescription
.
text
=
"
Please turn to the right
"
.
localized
()
self
.
completionSuccessFaceRecordStep
(
.
FACE_RIGHT_FAILD
,
nil
,
nil
)
}
else
if
statusFace
==
.
TOLEFT
&&
self
.
timeSpace
*
2
<=
self
.
timeRecord
&&
self
.
timeRecord
<
self
.
timeSpace
*
3
{
self
.
viewCheckStep2
.
backgroundColor
=
UIColor
.
colorFromHexa
(
"#FE3500"
)
}
else
if
statusFace
==
.
TOLEFT
&&
self
.
checkStep
==
2
{
self
.
lbDescription
.
textColor
=
UIColor
.
green
self
.
lbDescription
.
text
=
" "
.
localized
()
self
.
lbDescription
.
text
=
"Exactly"
.
localized
()
self
.
checkStep
=
3
self
.
viewCheckStep3
.
backgroundColor
=
UIColor
.
colorFromHexa
(
"#FBA02E"
)
self
.
completionSuccessFaceRecordStep
(
.
FACE_LEFT
,
nil
,
nil
)
if
self
.
dataImageSuccess
.
count
==
2
{
self
.
dataImageSuccess
.
append
(
imageView
.
pngData
()
!
)
}
}
else
if
statusFace
!=
.
TOLEFT
&&
self
.
timeSpace
*
2
<=
self
.
timeRecord
&&
self
.
timeRecord
<
self
.
timeSpace
*
3
{
}
else
if
statusFace
!=
.
TOLEFT
&&
self
.
checkStep
==
2
{
self
.
lbDescription
.
textColor
=
UIColor
.
red
self
.
lbDescription
.
text
=
"
"
.
localized
()
self
.
lbDescription
.
text
=
"
Please turn to the left
"
.
localized
()
self
.
completionSuccessFaceRecordStep
(
.
FACE_LEFT_FAILD
,
nil
,
nil
)
self
.
viewCheckStep3
.
backgroundColor
=
UIColor
.
colorFromHexa
(
"#FE3500"
)
}
}
else
{
self
.
lbDescription
.
textColor
=
UIColor
.
red
self
.
lbDescription
.
text
=
"
"
.
localized
()
self
.
lbDescription
.
text
=
"
Incorrect face, please check!
"
.
localized
()
self
.
completionSuccessFaceRecordStep
(
.
FACE_FAKE
,
nil
,
nil
)
}
}
...
...
@@ -257,8 +299,15 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
if
result
!
[
0
]
<
result
!
[
1
]
{
DispatchQueue
.
main
.
async
{
self
.
checkStartRecord
=
true
self
.
lbDescription
.
textColor
=
UIColor
.
green
self
.
lbDescription
.
text
=
" "
.
localized
()
//"Bạn đã sẵn sàng. Hãy bắt đầu!"
self
.
lbDescription
.
textColor
=
UIColor
.
white
if
!
self
.
checkStatusRecord
{
self
.
checkStatusRecord
=
true
self
.
timeRecord
=
0
self
.
checkStep
=
0
self
.
viewCheckStep1
.
backgroundColor
=
UIColor
.
colorFromHexa
(
"#333333"
)
self
.
viewCheckStep2
.
backgroundColor
=
UIColor
.
colorFromHexa
(
"#333333"
)
self
.
viewCheckStep3
.
backgroundColor
=
UIColor
.
colorFromHexa
(
"#333333"
)
}
self
.
completionSuccessFaceRecordStep
(
.
FACE_READY
,
nil
,
nil
)
}
}
else
{
...
...
@@ -277,7 +326,7 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
self
.
startTimer
()
self
.
checkStatusRecord
=
true
self
.
timeRecord
=
0
let
image
=
UIImage
(
named
:
"player_stop"
,
in
:
Bundle
(
for
:
SBKTutorialVC
.
self
),
compatibleWith
:
nil
)
//
let image = UIImage(named: "player_stop", in: Bundle(for: SBKTutorialVC.self), compatibleWith: nil)
//self.btnRecord.setImage(imageStartRecord ?? image, for: .normal)
}
}
...
...
@@ -336,11 +385,9 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
overlayView
.
backgroundColor
=
UIColor
.
black
.
withAlphaComponent
(
0.6
)
let
path
=
CGMutablePath
()
let
originYLBCopyright
=
self
.
lbCopyright
.
frame
.
origin
.
y
/
896
*
self
.
bounds
.
height
let
heightLBCopyright
=
self
.
lbCopyright
.
frame
.
height
/
896
*
self
.
bounds
.
height
let
locationTop
=
originYLBCopyright
+
heightLBCopyright
+
35
let
locationTop
=
self
.
bounds
.
origin
.
y
+
35
let
originYLBDescription
=
self
.
lbDescription
.
frame
.
origin
.
y
/
896
*
self
.
bounds
.
height
let
originYLBDescription
=
self
.
stackView
.
frame
.
origin
.
y
/
896
*
self
.
bounds
.
height
let
heightOval
=
originYLBDescription
-
locationTop
...
...
@@ -381,6 +428,8 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
}
else
{
let
statusString
=
self
.
checkFaceRightLeft
(
landmarks
:
results
[
0
]
.
landmarks
!
)
self
.
startTimer
()
DispatchQueue
.
global
()
.
async
{
self
.
didOutput
(
pixelBuffer
:
image
,
statusFace
:
statusString
)
}
...
...
@@ -393,7 +442,7 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
self
.
completionSuccessFaceRecordStep
(
.
NO_FACE
,
nil
,
nil
)
}
else
{
self
.
lbDescription
.
textColor
=
UIColor
.
red
self
.
lbDescription
.
text
=
"
"
.
localized
()
self
.
lbDescription
.
text
=
"
Incorrect face, please check!
"
.
localized
()
DispatchQueue
.
global
()
.
async
{
self
.
didOutput
(
pixelBuffer
:
image
,
statusFace
:
.
ERROR
)
...
...
@@ -415,10 +464,6 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
try
?
imageRequestHandler
.
perform
([
faceDetectionRequest
])
}
func
startTimer
()
{
timer
=
Timer
.
scheduledTimer
(
timeInterval
:
1.0
,
target
:
self
,
selector
:
#selector(
setLableRecord(timer:)
)
,
userInfo
:
nil
,
repeats
:
true
)
}
func
resetRecord
()
{
self
.
numberPass
=
0
self
.
numberTrue
=
0
...
...
@@ -479,6 +524,47 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
}
func
startTimer
()
{
switch
self
.
checkStep
{
case
0
:
self
.
imageDescription
.
image
=
UIImage
(
named
:
"Scan-3@2x"
,
in
:
Bundle
(
for
:
SBKTutorialVC
.
self
),
compatibleWith
:
nil
)
self
.
lbDescription
.
textColor
=
UIColor
.
white
self
.
completionSuccessFaceRecordStep
(
nil
,
.
STEP_FACE_STRAIGHT
,
nil
)
self
.
lbDescription
.
text
=
"Please look straight"
.
localized
()
//"vui lòng nhìn thẳng"
case
1
:
self
.
imageDescription
.
image
=
UIImage
(
named
:
"Scan-5@2x"
,
in
:
Bundle
(
for
:
SBKTutorialVC
.
self
),
compatibleWith
:
nil
)
self
.
lbDescription
.
textColor
=
UIColor
.
white
self
.
completionSuccessFaceRecordStep
(
nil
,
.
STEP_FACE_RIGHT
,
nil
)
self
.
lbDescription
.
text
=
"Please turn to the right"
.
localized
()
//"Quay sang phải"
case
2
:
self
.
imageDescription
.
image
=
UIImage
(
named
:
"Scan-4@2x"
,
in
:
Bundle
(
for
:
SBKTutorialVC
.
self
),
compatibleWith
:
nil
)
self
.
lbDescription
.
textColor
=
UIColor
.
white
self
.
completionSuccessFaceRecordStep
(
nil
,
.
STEP_FACE_LEFT
,
nil
)
self
.
lbDescription
.
text
=
"Please turn to the left"
.
localized
()
//"Quay sang trái"
case
3
:
if
self
.
dataImageSuccess
.
count
>
2
{
DispatchQueue
.
main
.
async
{
let
data
:
[
String
:
Any
]
=
[
"imagestraight"
:
self
.
dataImageSuccess
[
0
],
"imageRight"
:
self
.
dataImageSuccess
[
1
],
"imageLeft"
:
self
.
dataImageSuccess
[
2
],
]
self
.
completionSuccessFaceRecordStep
(
nil
,
nil
,
data
)
self
.
timeRecord
=
0
self
.
resetRecord
()
self
.
timer
.
invalidate
()
}
}
else
{
self
.
lbDescription
.
textColor
=
UIColor
.
red
self
.
lbDescription
.
text
=
"Unsatisfactory, please try again!"
.
localized
()
//"Chưa đạt yêu cầu, hãy thử lại!"
self
.
completionSuccessFaceRecordStep
(
.
INVALID
,
nil
,
nil
)
}
default
:
break
}
}
func
resizeImageFace
(
pixelBuffer
:
CVPixelBuffer
)
->
CVPixelBuffer
{
let
validateView
=
SBKValidateInput
.
shared
let
imageInput
=
validateView
.
convertCVPixelToUIImage
(
pixelBuffer
:
pixelBuffer
)
...
...
OCR-SDK/UI/SBKRecordFace/SBKRecordFaceView.xib
View file @
10b7da10
...
...
@@ -13,6 +13,7 @@
<connections>
<outlet
property=
"imageDescription"
destination=
"qAP-z1-ph6"
id=
"4WK-9l-Hhw"
/>
<outlet
property=
"lbDescription"
destination=
"l4S-dU-FVT"
id=
"7qE-CY-e4c"
/>
<outlet
property=
"stackView"
destination=
"lfu-gT-avH"
id=
"UPQ-PC-13s"
/>
<outlet
property=
"viewBackground"
destination=
"vtt-nP-K7e"
id=
"p2H-QE-FHN"
/>
<outlet
property=
"viewCheckStep1"
destination=
"Ikb-Rh-oGt"
id=
"gg1-L1-h5k"
/>
<outlet
property=
"viewCheckStep2"
destination=
"q10-fa-3fY"
id=
"YaT-X4-UMq"
/>
...
...
@@ -57,7 +58,7 @@
<subviews>
<view
contentMode=
"scaleToFill"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"Ikb-Rh-oGt"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"68"
height=
"6"
/>
<color
key=
"backgroundColor"
red=
"0.20000000000000001"
green=
"0.20000000000000001"
blue=
"0.20000000000000001"
alpha=
"1"
colorSpace=
"c
ustom"
customColorSpace=
"s
RGB"
/>
<color
key=
"backgroundColor"
red=
"0.20000000000000001"
green=
"0.20000000000000001"
blue=
"0.20000000000000001"
alpha=
"1"
colorSpace=
"c
alibrated
RGB"
/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute
type=
"number"
keyPath=
"cornerRadius"
>
<integer
key=
"value"
value=
"3"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment