Commit 10b7da10 authored by Nguyen Huy Nhat Anh's avatar Nguyen Huy Nhat Anh

add frame

parent 6316f203
...@@ -78,12 +78,12 @@ public class SB_KYC_SDK { ...@@ -78,12 +78,12 @@ public class SB_KYC_SDK {
//Call API face //Call API face
//input: UIImage //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 SBKValidateInput.shared.validateFace(imageFace: imageFace) {[weak self] data in
guard self != nil else { return } guard self != nil else { return }
if data { if data {
Global.imageCard1 = SBKValidateInput.shared.convertCVPixelToUIImage(pixelBuffer: imageCardFront).pngData() Global.imageCard1 = imageCardFront
Global.imageCard2 = SBKValidateInput.shared.convertCVPixelToUIImage(pixelBuffer: imageCardFront).pngData() Global.imageCard2 = imageCardBack
let imageFaceUI = SBKValidateInput.shared.convertCVPixelToUIImage(pixelBuffer: imageFace).pngData() let imageFaceUI = SBKValidateInput.shared.convertCVPixelToUIImage(pixelBuffer: imageFace).pngData()
SBOCRRequest.shared.processFace(image: imageFaceUI! , pathURL: Global.url_face, idBack: "", idFront: "") {(errorCode,data) -> Void in SBOCRRequest.shared.processFace(image: imageFaceUI! , pathURL: Global.url_face, idBack: "", idFront: "") {(errorCode,data) -> Void in
......
...@@ -13,8 +13,15 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate { ...@@ -13,8 +13,15 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate {
let nibName = "SBKValidateCardView" let nibName = "SBKValidateCardView"
var contentView:UIView? 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 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 captureSession: AVCaptureSession = AVCaptureSession()
public var stillImageOutput: AVCapturePhotoOutput = AVCapturePhotoOutput() public var stillImageOutput: AVCapturePhotoOutput = AVCapturePhotoOutput()
...@@ -64,6 +71,14 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate { ...@@ -64,6 +71,14 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate {
} }
self.loadCamera() 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? { func loadViewFromNib() -> UIView? {
...@@ -80,7 +95,7 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate { ...@@ -80,7 +95,7 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate {
let topLeft = CGPoint(x: fWidth/2-squareWidth/3, y: fHeight/4) let topLeft = CGPoint(x: fWidth/2-squareWidth/3, y: fHeight/4)
if iconTakeCard != nil { if iconTakeCard != nil {
self.btnTakePhoto.setImage(iconTakeCard, for: .normal) self.btnCapture.setImage(iconTakeCard, for: .normal)
} }
if iconFrameTopLeft != nil { if iconFrameTopLeft != nil {
...@@ -212,8 +227,8 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate { ...@@ -212,8 +227,8 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate {
// self.captureSession.stopRunning() // self.captureSession.stopRunning()
// self.captureSession.removeOutput(self.videoDataOutput) // self.captureSession.removeOutput(self.videoDataOutput)
// self.captureSession.removeOutput(self.stillImageOutput) // 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) self.completionSuccessCardStep(nil, cropImage!.pngData()!, nil)
} }
//Xử lý ảnh hiển thị //Xử lý ảnh hiển thị
...@@ -249,7 +264,7 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate { ...@@ -249,7 +264,7 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate {
if UIDevice.current.userInterfaceIdiom == .pad { 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) 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 { } 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!) let ciimage = CIImage(image: imageOutput!)
...@@ -286,6 +301,7 @@ extension SBKValidateCardView: AVCaptureVideoDataOutputSampleBufferDelegate { ...@@ -286,6 +301,7 @@ extension SBKValidateCardView: AVCaptureVideoDataOutputSampleBufferDelegate {
self.completionSuccessCardStep(validateImageCard, nil, nil) self.completionSuccessCardStep(validateImageCard, nil, nil)
self.statusValidateImage = validateImageCard self.statusValidateImage = validateImageCard
self.lbDescription.text = validateImageCard.rawValue
} }
} }
} }
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<connections> <connections>
<outlet property="imageDescription" destination="qAP-z1-ph6" id="4WK-9l-Hhw"/> <outlet property="imageDescription" destination="qAP-z1-ph6" id="4WK-9l-Hhw"/>
<outlet property="lbDescription" destination="l4S-dU-FVT" id="7qE-CY-e4c"/> <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="viewBackground" destination="vtt-nP-K7e" id="p2H-QE-FHN"/>
<outlet property="viewCheckStep1" destination="Ikb-Rh-oGt" id="gg1-L1-h5k"/> <outlet property="viewCheckStep1" destination="Ikb-Rh-oGt" id="gg1-L1-h5k"/>
<outlet property="viewCheckStep2" destination="q10-fa-3fY" id="YaT-X4-UMq"/> <outlet property="viewCheckStep2" destination="q10-fa-3fY" id="YaT-X4-UMq"/>
...@@ -57,7 +58,7 @@ ...@@ -57,7 +58,7 @@
<subviews> <subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ikb-Rh-oGt"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ikb-Rh-oGt">
<rect key="frame" x="0.0" y="0.0" width="68" height="6"/> <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="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/>
<userDefinedRuntimeAttributes> <userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius"> <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<integer key="value" value="3"/> <integer key="value" value="3"/>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment