Skip to content

Commit 0727c13

Browse files
added v11.5.5
1 parent f06ddf5 commit 0727c13

File tree

281 files changed

+9490
-8574
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

281 files changed

+9490
-8574
lines changed

AcuantCamera/AcuantCamera.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
D9B4821926BC4EE2001C0CEC /* BarcodeCameraViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9B4821826BC4EE2001C0CEC /* BarcodeCameraViewController.swift */; };
4444
D9B4821B26C18DC6001C0CEC /* BarcodeCameraDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9B4821A26C18DC6001C0CEC /* BarcodeCameraDelegate.swift */; };
4545
D9B4821D26C18F1D001C0CEC /* BarcodeCaptureDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9B4821C26C18F1D001C0CEC /* BarcodeCaptureDelegate.swift */; };
46+
D9D18E6E27BAA47E0048293A /* CGRectExtn.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9D18E6D27BAA47E0048293A /* CGRectExtn.swift */; };
4647
/* End PBXBuildFile section */
4748

4849
/* Begin PBXFileReference section */
@@ -84,6 +85,7 @@
8485
D9B4821826BC4EE2001C0CEC /* BarcodeCameraViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarcodeCameraViewController.swift; sourceTree = "<group>"; };
8586
D9B4821A26C18DC6001C0CEC /* BarcodeCameraDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarcodeCameraDelegate.swift; sourceTree = "<group>"; };
8687
D9B4821C26C18F1D001C0CEC /* BarcodeCaptureDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarcodeCaptureDelegate.swift; sourceTree = "<group>"; };
88+
D9D18E6D27BAA47E0048293A /* CGRectExtn.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CGRectExtn.swift; sourceTree = "<group>"; };
8789
/* End PBXFileReference section */
8890

8991
/* Begin PBXFrameworksBuildPhase section */
@@ -125,6 +127,7 @@
125127
8327AA4C2420165200B524F9 /* Camera */,
126128
8327AA4A2420099B00B524F9 /* Extension */,
127129
134F59D521FA0BA600CEDBFC /* AcuantCamera.h */,
130+
8387E1FF243284440051AF80 /* Media.xcassets */,
128131
134F59D621FA0BA600CEDBFC /* Info.plist */,
129132
);
130133
path = AcuantCamera;
@@ -165,7 +168,6 @@
165168
8327AA3C2420081100B524F9 /* OCR */,
166169
8327AA192420056700B524F9 /* AcuantMrzCaptureSession.swift */,
167170
8327AA182420056700B524F9 /* AcuantMrzCameraController.swift */,
168-
8387E1FF243284440051AF80 /* Media.xcassets */,
169171
);
170172
path = Mrz;
171173
sourceTree = "<group>";
@@ -200,6 +202,7 @@
200202
D95FF40F266FC7E30054E7B9 /* UIWindowExtn.swift */,
201203
D95FF413267177A60054E7B9 /* UILayerExtn.swift */,
202204
D95FF41526727D760054E7B9 /* StringExtn.swift */,
205+
D9D18E6D27BAA47E0048293A /* CGRectExtn.swift */,
203206
);
204207
path = Extension;
205208
sourceTree = "<group>";
@@ -330,6 +333,7 @@
330333
files = (
331334
D9B4821B26C18DC6001C0CEC /* BarcodeCameraDelegate.swift in Sources */,
332335
D95FF410266FC7E30054E7B9 /* UIWindowExtn.swift in Sources */,
336+
D9D18E6E27BAA47E0048293A /* CGRectExtn.swift in Sources */,
333337
C2743A26222DE2E700302CE7 /* CaptureConstants.swift in Sources */,
334338
8327AA452420081100B524F9 /* AcuantMrzResult.swift in Sources */,
335339
8327AA422420081100B524F9 /* AcuantMrzParser.swift in Sources */,

AcuantCamera/AcuantCamera/Camera/Barcode/BarcodeCameraViewController.swift

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ import AVFoundation
8585
}
8686

8787
private func createBarcodeLayer() -> DocumentPlaceholderLayer? {
88-
guard let barcodeImage = UIImage(named: "barcode_placement_overlay",
89-
in: Bundle(for: BarcodeCameraViewController.self),
90-
compatibleWith: nil)
91-
else {
88+
guard let barcodeImage = getPlaceholderImage() else {
9289
return nil
9390
}
9491

@@ -97,6 +94,21 @@ import AVFoundation
9794
return barcodeLayer
9895
}
9996

97+
private func getPlaceholderImage() -> UIImage? {
98+
if let image = UIImage(named: "barcode_placement_overlay",
99+
in: Bundle(for: BarcodeCameraViewController.self),
100+
compatibleWith: nil) {
101+
return image
102+
} else if let bundlePath = Bundle(for: BarcodeCameraViewController.self).path(forResource: "AcuantCameraAssets",
103+
ofType: "bundle"),
104+
let bundle = Bundle(path: bundlePath), let image = UIImage(named: "barcode_placement_overlay",
105+
in: bundle,
106+
compatibleWith: nil) {
107+
return image
108+
}
109+
return nil
110+
}
111+
100112
private func scheduleTimeoutTimer(_ timeout: Int) -> Timer {
101113
return Timer.scheduledTimer(withTimeInterval: TimeInterval(timeout), repeats: false) { [weak self] _ in
102114
guard let self = self else { return }

AcuantCamera/AcuantCamera/Camera/Document/DocumentCameraController.swift

Lines changed: 34 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,18 @@ import AcuantCommon
3636
private var currentPoints: [CGPoint]?
3737
private var options: CameraOptions!
3838
weak private var cameraCaptureDelegate: CameraCaptureDelegate?
39-
40-
private var currentState = FrameResult.NO_DOCUMENT
39+
4140
private var captureTimerState = 0.0
4241
private var isHoldSteady = false
4342
private var holdSteadyTimer: Timer!
4443

4544
private let captureTime = 1
4645
private let documentMovementThreshold = 25
47-
private let previewBoundsThreshold: CGFloat = -5
4846

4947
private var currentStateCount = 0
50-
private var nextState = FrameResult.NO_DOCUMENT
5148
private var isNavigationHidden = false
5249

53-
public class func getCameraController(delegate:CameraCaptureDelegate, cameraOptions: CameraOptions)->DocumentCameraController{
50+
public class func getCameraController(delegate: CameraCaptureDelegate, cameraOptions: CameraOptions) -> DocumentCameraController {
5451
let c = DocumentCameraController()
5552
c.cameraCaptureDelegate = delegate
5653
c.options = cameraOptions
@@ -169,7 +166,7 @@ import AcuantCommon
169166
: .resizeAspect
170167

171168
createCameraLayers()
172-
169+
173170
self.cameraPreviewView.layer.addSublayer(self.messageLayer)
174171
self.cameraPreviewView.layer.addSublayer(self.shapeLayer)
175172
self.cameraPreviewView.layer.addSublayer(self.cornerLayer)
@@ -183,20 +180,18 @@ import AcuantCommon
183180
}
184181

185182
private func createCameraLayers() {
186-
if self.messageLayer == nil {
187-
self.messageLayer = CameraTextView(autoCapture: autoCapture)
183+
if messageLayer == nil {
184+
messageLayer = CameraTextView(autoCapture: autoCapture)
188185
}
189-
self.messageLayer.setFrame(frame: self.view.frame)
190-
if self.cornerLayer == nil {
191-
self.cornerLayer = CameraCornerOverlayView(options: options)
186+
if cornerLayer == nil {
187+
cornerLayer = CameraCornerOverlayView(options: options)
192188
}
193-
self.cornerLayer.setFrame(frame: self.view.frame)
194189
if shapeLayer == nil {
195190
shapeLayer = CameraDocumentOverlayView(options: options)
196191
}
197192
}
198193

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

321-
if interval >= self.captureWaitTime - 1 {
316+
if interval >= self.captureWaitTime {
322317
self.captureSession.enableCapture()
323318
} else {
324319
self.messageLayer.string = "\(self.captureWaitTime - interval)..."
@@ -330,47 +325,32 @@ import AcuantCommon
330325
self.handleInterval()
331326
}
332327

333-
public func isDocumentMoved(newPoints: Array<CGPoint>) -> Bool{
334-
if(self.currentPoints != nil && newPoints.count == self.currentPoints!.count){
335-
for i in 0..<self.currentPoints!.count {
336-
if(Int(abs(self.currentPoints![i].x - newPoints[i].x)) > documentMovementThreshold || Int(abs(self.currentPoints![i].y - newPoints[i].y)) > documentMovementThreshold ){
337-
return true
338-
}
328+
public func isDocumentMoved(points: [CGPoint]) -> Bool {
329+
guard let currentPoints = self.currentPoints, points.count == currentPoints.count else {
330+
return false
331+
}
332+
333+
for i in 0..<currentPoints.count {
334+
if (Int(abs(currentPoints[i].x - points[i].x)) > documentMovementThreshold
335+
|| Int(abs(currentPoints[i].y - points[i].y)) > documentMovementThreshold ) {
336+
return true
339337
}
340338
}
339+
341340
return false
342341
}
343-
344-
342+
345343
private func transitionState(state: CameraState, localString: String? = nil) {
346-
if (!autoCapture) {
344+
if !autoCapture {
347345
return
348346
}
349347

350-
if(localString != nil){
351-
self.cancelCapture(state: state, message: NSLocalizedString(localString!, comment: ""))
352-
}
353-
else{
348+
if let localString = localString {
349+
self.cancelCapture(state: state, message: NSLocalizedString(localString, comment: ""))
350+
} else {
354351
self.setLookFromState(state: state)
355352
}
356353
}
357-
358-
func isInRange(point: CGPoint) -> Bool {
359-
return (point.x >= -previewBoundsThreshold && point.x <= self.cameraPreviewView.frame.width + previewBoundsThreshold)
360-
&& (point.y >= -previewBoundsThreshold && point.y <= self.cameraPreviewView.frame.height + previewBoundsThreshold)
361-
}
362-
363-
func isOutsideView(points: Array<CGPoint>?) -> Bool {
364-
if(points != nil && points?.count == 4 && autoCapture){
365-
let scaledPoints = scalePoints(points: points!)
366-
for i in scaledPoints {
367-
if(!isInRange(point: i)){
368-
return true
369-
}
370-
}
371-
}
372-
return false
373-
}
374354

375355
private func scalePoints(points: Array<CGPoint>) -> Array<CGPoint>{
376356
return [
@@ -414,7 +394,7 @@ import AcuantCommon
414394
}
415395
}
416396

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

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

434-
@objc internal func backTapped(_ sender: Any){
414+
@objc func backTapped(_ sender: Any) {
435415
self.cameraCaptureDelegate?.setCapturedImage(image: Image(), barcodeString: nil)
436416
self.navigationController?.popViewController(animated: true)
437417
}
@@ -447,11 +427,10 @@ extension DocumentCameraController: DocumentCaptureDelegate {
447427
if self.autoCapture {
448428
self.setLookFromState(state: DocumentCameraController.CameraState.Capture)
449429
self.setMessageCaptureSettings()
450-
self.messageLayer.string = NSLocalizedString("1...", comment: "")
451430
} else {
452431
self.setMessageDefaultSettings()
453-
self.messageLayer.string = NSLocalizedString("acuant_camera_capturing", comment: "")
454432
}
433+
self.messageLayer.string = NSLocalizedString("acuant_camera_capturing", comment: "")
455434
self.captured = true
456435
}
457436
}
@@ -480,29 +459,23 @@ extension DocumentCameraController: FrameAnalysisDelegate {
480459
return
481460
}
482461

483-
if isOutsideView(points: points) {
484-
self.currentState = FrameResult.DOCUMENT_NOT_IN_FRAME
485-
} else{
486-
self.currentState = frameResult
487-
}
488-
489-
switch self.currentState {
490-
case FrameResult.NO_DOCUMENT:
462+
switch frameResult {
463+
case .NO_DOCUMENT:
491464
self.transitionState(state: CameraState.Align, localString: "acuant_camera_align")
492-
case FrameResult.SMALL_DOCUMENT:
465+
case .SMALL_DOCUMENT:
493466
self.transitionState(state: CameraState.MoveCloser, localString: "acuant_camera_move_closer")
494-
case FrameResult.BAD_ASPECT_RATIO:
467+
case .BAD_ASPECT_RATIO:
495468
self.transitionState(state: CameraState.MoveCloser, localString: "acuant_camera_move_closer")
496-
case FrameResult.DOCUMENT_NOT_IN_FRAME:
469+
case .DOCUMENT_NOT_IN_FRAME:
497470
self.transitionState(state: CameraState.MoveCloser, localString: "acuant_camera_outside_view")
498-
case FrameResult.GOOD_DOCUMENT:
471+
case .GOOD_DOCUMENT:
499472
if let pts = points, pts.count == 4, autoCapture {
500473
let scaledPoints = scalePoints(points: pts)
501474
self.setPath(points: scaledPoints)
502475
if !isHoldSteady {
503476
self.transitionState(state: CameraState.Hold)
504477

505-
if self.isDocumentMoved(newPoints: scaledPoints) {
478+
if self.isDocumentMoved(points: scaledPoints) {
506479
self.cancelCapture(state: CameraState.Steady, message: NSLocalizedString("acuant_camera_hold_steady", comment: ""))
507480
} else if !self.captured {
508481
self.triggerCapture()

0 commit comments

Comments
 (0)