Commit 276686b7 authored by Itsol-AnhNguyen's avatar Itsol-AnhNguyen

add card and face view

parent 10b7da10
File added
......@@ -754,6 +754,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "itsol.OCR-SDK";
PRODUCT_NAME = SB_KYC_SDK;
SKIP_INSTALL = YES;
SUPPORTS_MACCATALYST = NO;
SWIFT_INCLUDE_PATHS = "${SRCROOT}/TensorFlowLite\n\n\nType a message\n${SRCROOT}/TensorFlowLite\n\n\nType a message${SRCROOT}/TensorFlowLite\n\n\nType a message\n";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
......@@ -786,6 +787,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "itsol.OCR-SDK";
PRODUCT_NAME = SB_KYC_SDK;
SKIP_INSTALL = YES;
SUPPORTS_MACCATALYST = NO;
SWIFT_INCLUDE_PATHS = "${SRCROOT}/TensorFlowLite\n\n\nType a message\n${SRCROOT}/TensorFlowLite\n\n\nType a message${SRCROOT}/TensorFlowLite\n\n\nType a message\n";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
......
......@@ -12,6 +12,7 @@ import UIKit
public class SB_KYC_SDK {
public static let shared = SB_KYC_SDK()
public typealias CompletionHandle = (_ data: [String: Any]?, _ cardImage: Data?, _ faceImage: Data?) -> Void
public typealias CompletionHandleMatch = (_ data: [String: Any]?) -> Void
public typealias CompletionHandleFace = (_ data: Bool) -> Void
let viewController = SBKTutorialVC(URLToken: "http://sdk.sb.gotai.ml")
......@@ -50,27 +51,20 @@ public class SB_KYC_SDK {
//Validate card
//input: UIImage
//output: Int, 0: Image fake, 1: Image front, 2: Image back, -1: error
public func eKycCardValid(image: CVPixelBuffer) -> Int {
let resultVaidate = SBKValidateInput.shared.didOutput(pixelBuffer: image)
public func eKycCardValid(image: Data) -> ValidateCard {
let dataImage = UIImage(data: image)
let imageCVPB = SBKValidateInput.shared.comvertUIImageToCVPixel(imageInput: dataImage!)
let resultVaidate = SBKValidateInput.shared.didOutput(pixelBuffer: imageCVPB)
switch resultVaidate {
case .ERROR:
return -1
case .IMAGE_FAKE:
return 0
case .IMAGE_FRONT:
return 1
case .IMAGE_BACK:
return 2
case .PASSPORT:
return 3
}
return resultVaidate
}
//Validate face
//input: UIImage
public func eKycFaceValid(image: CVPixelBuffer, completion: @escaping CompletionHandleFace){
SBKValidateInput.shared.validateFace(imageFace: image) {[weak self] data in
public func eKycFaceValid(image: Data, completion: @escaping CompletionHandleFace) {
let dataImage = UIImage(data: image)
let imageCVPB = SBKValidateInput.shared.comvertUIImageToCVPixel(imageInput: dataImage!)
SBKValidateInput.shared.validateFace(imageFace: imageCVPB) {[weak self] data in
guard self != nil else { return }
completion(data)
}
......@@ -78,26 +72,19 @@ public class SB_KYC_SDK {
//Call API face
//input: UIImage
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 {
public func eKycFaceMatch(imageFace: Data, imageCardFront: Data, imageCardBack: Data, sdkConfig: [String:Any], completion: @escaping CompletionHandleMatch) {
Global.imageCard1 = imageCardFront
Global.imageCard2 = imageCardBack
let imageFaceUI = SBKValidateInput.shared.convertCVPixelToUIImage(pixelBuffer: imageFace).pngData()
Global.language = sdkConfig["language"] as? String ?? Global.language
Global.url_face = sdkConfig["url_match"] as? String ?? Global.url_face
SBOCRRequest.shared.processFace(image: imageFaceUI! , pathURL: Global.url_face, idBack: "", idFront: "") {(errorCode,data) -> Void in
SBOCRRequest.shared.processFace(image: imageFace , pathURL: Global.url_face, idBack: "", idFront: "") {(errorCode,data) -> Void in
guard errorCode == nil else {
let error: [String: Any] = ["error": errorCode!]
completion(error, nil, nil)
completion(error)
return
}
completion(data, nil, nil)
}
} else {
let error: [String: Any] = ["error": "image faild"]
completion(error, nil, nil)
}
completion(data)
}
}
}
......@@ -237,7 +237,6 @@ class SBKCaptureCardVC: UIViewController, AVCapturePhotoCaptureDelegate {
}
}
}
}
extension SBKCaptureCardVC: AVCaptureVideoDataOutputSampleBufferDelegate {
......
......@@ -9,13 +9,9 @@
import UIKit
import AVFoundation
public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate {
open 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 lbDescription: UILabel!
@IBOutlet public weak var lbCopyright: UILabel!
......@@ -37,17 +33,18 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate {
var statusValidateImage: ValidateCard = .ERROR
var statusScreen: String = "vertical" //horizontal
public var typeCamera: TypeCard = TypeCard.FRONT
public let labelTypeCard = UILabel()
public var completionSuccessCardStep: (_ validate: ValidateCard?, _ data: Data?, _ permissionCamera: Bool?)->Void = {_,_,_ in}
public var iconTakeCard: Data = UIImage(named: "iconCap", in: Bundle(for: SBKTutorialVC.self), compatibleWith: nil)!.pngData()!
public required init?(coder aDecoder: NSCoder) {
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
public override init(frame: CGRect) {
override public init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
......@@ -71,14 +68,12 @@ 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)
self.labelTypeCard.frame = CGRect(x: self.center.x - 50, y: self.frame.size.height / 8 + self.viewCamera.frame.origin.y - 40, width: 100, height: 20)
self.labelTypeCard.textAlignment = .center
self.labelTypeCard.text = "Use front"
self.labelTypeCard.textColor = UIColor.white
self.addSubview(labelTypeCard)
}
func loadViewFromNib() -> UIView? {
......@@ -193,7 +188,7 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate {
}
//set vùng đặt thẻ
func createOverlay(frame: CGRect) -> UIView {
func createOverlay(frame: CGRect, colorBorder: CGColor = UIColor.clear.cgColor) -> UIView {
let overlayView = UIView(frame: frame)
overlayView.backgroundColor = UIColor.black.withAlphaComponent(0.6)
let path = CGMutablePath()
......@@ -206,6 +201,14 @@ public class SBKValidateCardView: UIView, AVCapturePhotoCaptureDelegate {
width: fWidth * 18 / 20, height: fWidth * 18 * 3 / 20 / 4 ),
cornerWidth: 0, cornerHeight: 0)
let borderLayer = CAShapeLayer()
borderLayer.path = path // Reuse the Bezier path
borderLayer.fillColor = UIColor.clear.cgColor
borderLayer.strokeColor = colorBorder
borderLayer.lineWidth = 5
borderLayer.frame = overlayView.bounds
overlayView.layer.addSublayer(borderLayer)
path.addRect(CGRect(origin: .zero, size: overlayView.frame.size))
let maskLayer = CAShapeLayer()
maskLayer.backgroundColor = UIColor.black.cgColor
......@@ -298,10 +301,54 @@ extension SBKValidateCardView: AVCaptureVideoDataOutputSampleBufferDelegate {
}
let validateImageCard = SBKValidateInput.shared.didOutput(pixelBuffer: self.resizeImageCard(pixelBuffer: imageFrameInput))
DispatchQueue.main.async {
if let viewWithTag = self.viewCamera.viewWithTag(11) {
viewWithTag.removeFromSuperview()
}
self.completionSuccessCardStep(validateImageCard, nil, nil)
self.statusValidateImage = validateImageCard
self.lbDescription.text = validateImageCard.rawValue
if validateImageCard == ValidateCard.IMAGE_FAKE || validateImageCard == .ERROR {
self.lbDescription.textColor = UIColor.red
self.lbDescription.text = "Incorrect card, please check!".localized()
self.imgCaution.isHidden = false
self.btnCapture.setImage(UIImage(named: "Button_Do@2x", in: Bundle(for: SBKTutorialVC.self), compatibleWith: nil), for: .normal)
let overlay = self.createOverlay(frame: self.frame, colorBorder: UIColor.red.cgColor)
overlay.tag = 11
self.viewCamera.addSubview(overlay)
}
if validateImageCard == .IMAGE_FRONT && self.typeCamera == .BACK {
self.lbDescription.textColor = UIColor.red
self.lbDescription.text = "Please put the back of the card in".localized()
self.btnCapture.setImage(UIImage(named: "Button_Do@2x", in: Bundle(for: SBKTutorialVC.self), compatibleWith: nil), for: .normal)
self.imgCaution.isHidden = false
let overlay = self.createOverlay(frame: self.frame, colorBorder: UIColor.red.cgColor)
overlay.tag = 11
self.viewCamera.addSubview(overlay)
}
if validateImageCard == .IMAGE_BACK && self.typeCamera == .FRONT {
self.lbDescription.textColor = UIColor.red
self.lbDescription.text = "Please put the front of the card in".localized()
self.btnCapture.setImage(UIImage(named: "Button_Do@2x", in: Bundle(for: SBKTutorialVC.self), compatibleWith: nil), for: .normal)
self.imgCaution.isHidden = false
let overlay = self.createOverlay(frame: self.frame, colorBorder: UIColor.red.cgColor)
overlay.tag = 11
self.viewCamera.addSubview(overlay)
}
if (self.statusValidateImage == ValidateCard.IMAGE_FRONT && self.typeCamera == .FRONT) || (self.statusValidateImage == .IMAGE_BACK && self.typeCamera == .BACK) {
self.lbDescription.textColor = .green
self.lbDescription.text = "Are you ready. Let's start!".localized()
self.imgCaution.isHidden = true
self.btnCapture.setImage(UIImage(named: "iconCap", in: Bundle(for: SBKTutorialVC.self), compatibleWith: nil), for: .normal)
let overlay = self.createOverlay(frame: self.frame, colorBorder: UIColor.blue.cgColor)
overlay.tag = 11
self.viewCamera.addSubview(overlay)
}
}
}
}
......@@ -23,8 +23,25 @@
<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="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>
<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="649" 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>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bMq-BQ-SN5">
<rect key="frame" x="173.5" y="731.5" width="67" height="20.5"/>
<rect key="frame" x="173.5" y="741.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"/>
......@@ -47,23 +64,6 @@
</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>
<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>
......@@ -76,7 +76,7 @@
</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"/>
<rect key="frame" x="205" y="701" 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"/>
......@@ -85,9 +85,9 @@
<viewLayoutGuide key="safeArea" id="hB9-pv-7hU"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="bMq-BQ-SN5" firstAttribute="top" secondItem="wnG-jG-HwA" secondAttribute="bottom" constant="30" id="3RZ-t3-RxF"/>
<constraint firstItem="bMq-BQ-SN5" firstAttribute="top" secondItem="wnG-jG-HwA" secondAttribute="bottom" constant="20" 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="0tu-Uu-aZJ" firstAttribute="top" secondItem="bMq-BQ-SN5" secondAttribute="bottom" constant="20" 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"/>
......
......@@ -157,7 +157,7 @@ class SBKRecordFace: UIViewController, AVCaptureVideoDataOutputSampleBufferDeleg
self.checkStatusRecord = true
self.timeRecord = 0
self.checkStep = 0
self.viewCheckStep1.backgroundColor = UIColor.colorFromHexa("#333333")
self.viewCheckStep1.backgroundColor = .red
self.viewCheckStep2.backgroundColor = UIColor.colorFromHexa("#333333")
self.viewCheckStep3.backgroundColor = UIColor.colorFromHexa("#333333")
}
......
......@@ -11,7 +11,7 @@ import AVFoundation
import Vision
import CoreML
public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate {
open class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDelegate {
let nibName = "SBKRecordFaceView"
var contentView:UIView?
......@@ -210,42 +210,6 @@ 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 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()!)
......@@ -259,7 +223,7 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
self.lbDescription.textColor = UIColor.red
self.lbDescription.text = "Please look straight".localized()
self.viewCheckStep1.backgroundColor = UIColor.colorFromHexa("#FE3500")
self.completionSuccessFaceRecordStep(.FACE_STRAIGHT_FAILD, nil, nil)
self.completionSuccessFaceRecordStep(.FACE_STRAIGHT_FAILED, nil, nil)
} else if statusFace == .TORIGHT && self.checkStep == 1 {
self.lbDescription.textColor = UIColor.green
self.lbDescription.text = "Exactly".localized()
......@@ -272,7 +236,7 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
} else if statusFace != .TORIGHT && self.checkStep == 1 {
self.lbDescription.textColor = UIColor.red
self.lbDescription.text = "Please turn to the right".localized()
self.completionSuccessFaceRecordStep(.FACE_RIGHT_FAILD, nil, nil)
self.completionSuccessFaceRecordStep(.FACE_RIGHT_FAILED, nil, nil)
self.viewCheckStep2.backgroundColor = UIColor.colorFromHexa("#FE3500")
} else if statusFace == .TOLEFT && self.checkStep == 2 {
self.lbDescription.textColor = UIColor.green
......@@ -286,7 +250,7 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
} else if statusFace != .TOLEFT && self.checkStep == 2 {
self.lbDescription.textColor = UIColor.red
self.lbDescription.text = "Please turn to the left".localized()
self.completionSuccessFaceRecordStep(.FACE_LEFT_FAILD, nil, nil)
self.completionSuccessFaceRecordStep(.FACE_LEFT_FAILED, nil, nil)
self.viewCheckStep3.backgroundColor = UIColor.colorFromHexa("#FE3500")
}
} else {
......@@ -304,7 +268,7 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
self.checkStatusRecord = true
self.timeRecord = 0
self.checkStep = 0
self.viewCheckStep1.backgroundColor = UIColor.colorFromHexa("#333333")
self.viewCheckStep1.backgroundColor = .red
self.viewCheckStep2.backgroundColor = UIColor.colorFromHexa("#333333")
self.viewCheckStep3.backgroundColor = UIColor.colorFromHexa("#333333")
}
......@@ -568,7 +532,7 @@ public class SBKRecordFaceView: UIView, AVCaptureVideoDataOutputSampleBufferDele
func resizeImageFace(pixelBuffer: CVPixelBuffer) -> CVPixelBuffer {
let validateView = SBKValidateInput.shared
let imageInput = validateView.convertCVPixelToUIImage(pixelBuffer: pixelBuffer)
let imageOutput = validateView.cropImageFace(image: imageInput, rect: CGRect(x: imageInput.size.width / 6, y: imageInput.size.height / 12, width: imageInput.size.width * 4 / 6, height: imageInput.size.height * 8 / 10 ), scale: 1.0)
let imageOutput = validateView.cropImageFace(image: imageInput, rect: CGRect(x: imageInput.size.width / 10, y: imageInput.size.height / 14, width: imageInput.size.width * 8 / 10, height: imageInput.size.height * 9 / 14 ), scale: 1.0)
let ciimage = CIImage(image: imageOutput!)
let eaglContext = EAGLContext(api: .openGLES2)
......
......@@ -41,11 +41,11 @@ enum StatusFace: String {
public enum ValidateFace: String {
case FACE_STRAIGHT
case FACE_STRAIGHT_FAILD
case FACE_STRAIGHT_FAILED
case FACE_RIGHT
case FACE_RIGHT_FAILD
case FACE_RIGHT_FAILED
case FACE_LEFT
case FACE_LEFT_FAILD
case FACE_LEFT_FAILED
case FACE_FAKE
case FACE_READY
case MANY_FACE
......
......@@ -41,12 +41,6 @@ class SBKValidateInput {
}
func validateFace(imageFace: CVPixelBuffer, completion: @escaping CompletionHandle) {
// let ciimage = CIImage(image: imageFace)
//
// let tmpcontext = CIContext(options: nil)
// let cgimage = tmpcontext.createCGImage(ciimage!, from: ciimage!.extent)
//
// let cvpixelImge = self.convertCGImgeToCVPixelBuffer(forImage: cgimage!)
self.detectFace(in: imageFace) { [weak self] data in
guard let `self` = self else { return }
let result = data && self.didOutputFace(pixelBuffer: imageFace)
......@@ -206,7 +200,7 @@ class SBKValidateInput {
let widthCrop = imageCap.size.width - imageCap.size.width / 4
UIGraphicsBeginImageContextWithOptions(CGSize(width: widthCrop, height: widthCrop * 4 / 3), true, 0.0)
UIGraphicsBeginImageContextWithOptions(CGSize(width: rect.width, height: rect.height), true, 0.0)
image.draw(at: CGPoint(x: -rect.origin.x / scale, y: -rect.origin.y / scale))
let croppedImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
......
......@@ -79,7 +79,6 @@ class SBOCRRequest: NSObject{
let urlPath = URL(string: pathURL)!
var request = URLRequest(url: urlPath)
print("request====", urlPath, "==", request)
request.httpMethod = "POST"
if !Global.header.isEmpty {
......
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