Skip to content

Commit

Permalink
added v11.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
sMaltsevAcuant committed Mar 3, 2022
1 parent f06ddf5 commit 0727c13
Show file tree
Hide file tree
Showing 281 changed files with 9,490 additions and 8,574 deletions.
6 changes: 5 additions & 1 deletion AcuantCamera/AcuantCamera.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
D9B4821926BC4EE2001C0CEC /* BarcodeCameraViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9B4821826BC4EE2001C0CEC /* BarcodeCameraViewController.swift */; };
D9B4821B26C18DC6001C0CEC /* BarcodeCameraDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9B4821A26C18DC6001C0CEC /* BarcodeCameraDelegate.swift */; };
D9B4821D26C18F1D001C0CEC /* BarcodeCaptureDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9B4821C26C18F1D001C0CEC /* BarcodeCaptureDelegate.swift */; };
D9D18E6E27BAA47E0048293A /* CGRectExtn.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9D18E6D27BAA47E0048293A /* CGRectExtn.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -84,6 +85,7 @@
D9B4821826BC4EE2001C0CEC /* BarcodeCameraViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarcodeCameraViewController.swift; sourceTree = "<group>"; };
D9B4821A26C18DC6001C0CEC /* BarcodeCameraDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarcodeCameraDelegate.swift; sourceTree = "<group>"; };
D9B4821C26C18F1D001C0CEC /* BarcodeCaptureDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarcodeCaptureDelegate.swift; sourceTree = "<group>"; };
D9D18E6D27BAA47E0048293A /* CGRectExtn.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CGRectExtn.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -125,6 +127,7 @@
8327AA4C2420165200B524F9 /* Camera */,
8327AA4A2420099B00B524F9 /* Extension */,
134F59D521FA0BA600CEDBFC /* AcuantCamera.h */,
8387E1FF243284440051AF80 /* Media.xcassets */,
134F59D621FA0BA600CEDBFC /* Info.plist */,
);
path = AcuantCamera;
Expand Down Expand Up @@ -165,7 +168,6 @@
8327AA3C2420081100B524F9 /* OCR */,
8327AA192420056700B524F9 /* AcuantMrzCaptureSession.swift */,
8327AA182420056700B524F9 /* AcuantMrzCameraController.swift */,
8387E1FF243284440051AF80 /* Media.xcassets */,
);
path = Mrz;
sourceTree = "<group>";
Expand Down Expand Up @@ -200,6 +202,7 @@
D95FF40F266FC7E30054E7B9 /* UIWindowExtn.swift */,
D95FF413267177A60054E7B9 /* UILayerExtn.swift */,
D95FF41526727D760054E7B9 /* StringExtn.swift */,
D9D18E6D27BAA47E0048293A /* CGRectExtn.swift */,
);
path = Extension;
sourceTree = "<group>";
Expand Down Expand Up @@ -330,6 +333,7 @@
files = (
D9B4821B26C18DC6001C0CEC /* BarcodeCameraDelegate.swift in Sources */,
D95FF410266FC7E30054E7B9 /* UIWindowExtn.swift in Sources */,
D9D18E6E27BAA47E0048293A /* CGRectExtn.swift in Sources */,
C2743A26222DE2E700302CE7 /* CaptureConstants.swift in Sources */,
8327AA452420081100B524F9 /* AcuantMrzResult.swift in Sources */,
8327AA422420081100B524F9 /* AcuantMrzParser.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ import AVFoundation
}

private func createBarcodeLayer() -> DocumentPlaceholderLayer? {
guard let barcodeImage = UIImage(named: "barcode_placement_overlay",
in: Bundle(for: BarcodeCameraViewController.self),
compatibleWith: nil)
else {
guard let barcodeImage = getPlaceholderImage() else {
return nil
}

Expand All @@ -97,6 +94,21 @@ import AVFoundation
return barcodeLayer
}

private func getPlaceholderImage() -> UIImage? {
if let image = UIImage(named: "barcode_placement_overlay",
in: Bundle(for: BarcodeCameraViewController.self),
compatibleWith: nil) {
return image
} else if let bundlePath = Bundle(for: BarcodeCameraViewController.self).path(forResource: "AcuantCameraAssets",
ofType: "bundle"),
let bundle = Bundle(path: bundlePath), let image = UIImage(named: "barcode_placement_overlay",
in: bundle,
compatibleWith: nil) {
return image
}
return nil
}

private func scheduleTimeoutTimer(_ timeout: Int) -> Timer {
return Timer.scheduledTimer(withTimeInterval: TimeInterval(timeout), repeats: false) { [weak self] _ in
guard let self = self else { return }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,18 @@ import AcuantCommon
private var currentPoints: [CGPoint]?
private var options: CameraOptions!
weak private var cameraCaptureDelegate: CameraCaptureDelegate?

private var currentState = FrameResult.NO_DOCUMENT

private var captureTimerState = 0.0
private var isHoldSteady = false
private var holdSteadyTimer: Timer!

private let captureTime = 1
private let documentMovementThreshold = 25
private let previewBoundsThreshold: CGFloat = -5

private var currentStateCount = 0
private var nextState = FrameResult.NO_DOCUMENT
private var isNavigationHidden = false

public class func getCameraController(delegate:CameraCaptureDelegate, cameraOptions: CameraOptions)->DocumentCameraController{
public class func getCameraController(delegate: CameraCaptureDelegate, cameraOptions: CameraOptions) -> DocumentCameraController {
let c = DocumentCameraController()
c.cameraCaptureDelegate = delegate
c.options = cameraOptions
Expand Down Expand Up @@ -169,7 +166,7 @@ import AcuantCommon
: .resizeAspect

createCameraLayers()

self.cameraPreviewView.layer.addSublayer(self.messageLayer)
self.cameraPreviewView.layer.addSublayer(self.shapeLayer)
self.cameraPreviewView.layer.addSublayer(self.cornerLayer)
Expand All @@ -183,20 +180,18 @@ import AcuantCommon
}

private func createCameraLayers() {
if self.messageLayer == nil {
self.messageLayer = CameraTextView(autoCapture: autoCapture)
if messageLayer == nil {
messageLayer = CameraTextView(autoCapture: autoCapture)
}
self.messageLayer.setFrame(frame: self.view.frame)
if self.cornerLayer == nil {
self.cornerLayer = CameraCornerOverlayView(options: options)
if cornerLayer == nil {
cornerLayer = CameraCornerOverlayView(options: options)
}
self.cornerLayer.setFrame(frame: self.view.frame)
if shapeLayer == nil {
shapeLayer = CameraDocumentOverlayView(options: options)
}
}

public func rotateImage(image: UIImage) -> UIImage{
public func rotateImage(image: UIImage) -> UIImage {
if UIDevice.current.orientation == UIDeviceOrientation.landscapeRight {
return image.rotate(radians: .pi/2)!
}
Expand Down Expand Up @@ -318,7 +313,7 @@ import AcuantCommon
} else {
let interval = getInterval(time: self.captureTimerState, duration: self.captureIntervalInSeconds)

if interval >= self.captureWaitTime - 1 {
if interval >= self.captureWaitTime {
self.captureSession.enableCapture()
} else {
self.messageLayer.string = "\(self.captureWaitTime - interval)..."
Expand All @@ -330,47 +325,32 @@ import AcuantCommon
self.handleInterval()
}

public func isDocumentMoved(newPoints: Array<CGPoint>) -> Bool{
if(self.currentPoints != nil && newPoints.count == self.currentPoints!.count){
for i in 0..<self.currentPoints!.count {
if(Int(abs(self.currentPoints![i].x - newPoints[i].x)) > documentMovementThreshold || Int(abs(self.currentPoints![i].y - newPoints[i].y)) > documentMovementThreshold ){
return true
}
public func isDocumentMoved(points: [CGPoint]) -> Bool {
guard let currentPoints = self.currentPoints, points.count == currentPoints.count else {
return false
}

for i in 0..<currentPoints.count {
if (Int(abs(currentPoints[i].x - points[i].x)) > documentMovementThreshold
|| Int(abs(currentPoints[i].y - points[i].y)) > documentMovementThreshold ) {
return true
}
}

return false
}



private func transitionState(state: CameraState, localString: String? = nil) {
if (!autoCapture) {
if !autoCapture {
return
}

if(localString != nil){
self.cancelCapture(state: state, message: NSLocalizedString(localString!, comment: ""))
}
else{
if let localString = localString {
self.cancelCapture(state: state, message: NSLocalizedString(localString, comment: ""))
} else {
self.setLookFromState(state: state)
}
}

func isInRange(point: CGPoint) -> Bool {
return (point.x >= -previewBoundsThreshold && point.x <= self.cameraPreviewView.frame.width + previewBoundsThreshold)
&& (point.y >= -previewBoundsThreshold && point.y <= self.cameraPreviewView.frame.height + previewBoundsThreshold)
}

func isOutsideView(points: Array<CGPoint>?) -> Bool {
if(points != nil && points?.count == 4 && autoCapture){
let scaledPoints = scalePoints(points: points!)
for i in scaledPoints {
if(!isInRange(point: i)){
return true
}
}
}
return false
}

private func scalePoints(points: Array<CGPoint>) -> Array<CGPoint>{
return [
Expand Down Expand Up @@ -414,7 +394,7 @@ import AcuantCommon
}
}

internal func addNavigationBackButton(){
func addNavigationBackButton() {
backButton = UIButton(frame: CGRect(x: 0, y: UIScreen.main.heightOfSafeArea()*0.065, width: 90, height: 40))

var attribs : [NSAttributedString.Key : Any?] = [:]
Expand All @@ -431,7 +411,7 @@ import AcuantCommon
self.view.addSubview(backButton)
}

@objc internal func backTapped(_ sender: Any){
@objc func backTapped(_ sender: Any) {
self.cameraCaptureDelegate?.setCapturedImage(image: Image(), barcodeString: nil)
self.navigationController?.popViewController(animated: true)
}
Expand All @@ -447,11 +427,10 @@ extension DocumentCameraController: DocumentCaptureDelegate {
if self.autoCapture {
self.setLookFromState(state: DocumentCameraController.CameraState.Capture)
self.setMessageCaptureSettings()
self.messageLayer.string = NSLocalizedString("1...", comment: "")
} else {
self.setMessageDefaultSettings()
self.messageLayer.string = NSLocalizedString("acuant_camera_capturing", comment: "")
}
self.messageLayer.string = NSLocalizedString("acuant_camera_capturing", comment: "")
self.captured = true
}
}
Expand Down Expand Up @@ -480,29 +459,23 @@ extension DocumentCameraController: FrameAnalysisDelegate {
return
}

if isOutsideView(points: points) {
self.currentState = FrameResult.DOCUMENT_NOT_IN_FRAME
} else{
self.currentState = frameResult
}

switch self.currentState {
case FrameResult.NO_DOCUMENT:
switch frameResult {
case .NO_DOCUMENT:
self.transitionState(state: CameraState.Align, localString: "acuant_camera_align")
case FrameResult.SMALL_DOCUMENT:
case .SMALL_DOCUMENT:
self.transitionState(state: CameraState.MoveCloser, localString: "acuant_camera_move_closer")
case FrameResult.BAD_ASPECT_RATIO:
case .BAD_ASPECT_RATIO:
self.transitionState(state: CameraState.MoveCloser, localString: "acuant_camera_move_closer")
case FrameResult.DOCUMENT_NOT_IN_FRAME:
case .DOCUMENT_NOT_IN_FRAME:
self.transitionState(state: CameraState.MoveCloser, localString: "acuant_camera_outside_view")
case FrameResult.GOOD_DOCUMENT:
case .GOOD_DOCUMENT:
if let pts = points, pts.count == 4, autoCapture {
let scaledPoints = scalePoints(points: pts)
self.setPath(points: scaledPoints)
if !isHoldSteady {
self.transitionState(state: CameraState.Hold)

if self.isDocumentMoved(newPoints: scaledPoints) {
if self.isDocumentMoved(points: scaledPoints) {
self.cancelCapture(state: CameraState.Steady, message: NSLocalizedString("acuant_camera_hold_steady", comment: ""))
} else if !self.captured {
self.triggerCapture()
Expand Down
Loading

0 comments on commit 0727c13

Please sign in to comment.