Skip to content

Commit fb237d0

Browse files
added 11.5.7
1 parent 4ad05da commit fb237d0

File tree

181 files changed

+223581
-602
lines changed

Some content is hidden

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

181 files changed

+223581
-602
lines changed

AcuantCamera/AcuantCamera/Camera/Barcode/BarcodeCameraViewController.swift

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ import AVFoundation
6666
coordinator.animate(alongsideTransition: { [weak self] context in
6767
guard let self = self else { return }
6868

69-
self.rotateCameraPreview(to: self.view.window?.interfaceOrientation)
69+
let newFrame = CGRect(origin: self.view.frame.origin, size: size)
70+
self.rotateCameraPreview(to: self.view.window?.interfaceOrientation, frame: newFrame)
7071
})
7172
}
7273

@@ -77,10 +78,6 @@ import AVFoundation
7778
messageLayer.foregroundColorCapture = capturingColor
7879
messageLayer.backgroundColorCapture = UIColor.black.cgColor
7980
messageLayer.textSizeCapture = 30
80-
messageLayer.defaultWidth = 320
81-
messageLayer.defaultHeight = 40
82-
messageLayer.captureWidth = 320
83-
messageLayer.captureHeight = 40
8481
return messageLayer
8582
}
8683

@@ -149,7 +146,7 @@ import AVFoundation
149146
private func attachSession() {
150147
let captureDevice = AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .back)!
151148
captureSession = BarcodeCaptureSession(captureDevice: captureDevice, delegate: self)
152-
cameraPreviewView = CameraPreviewView(frame: view.bounds, captureSession: captureSession)
149+
cameraPreviewView = CameraPreviewView(frame: view.frame, captureSession: captureSession)
153150
cameraPreviewView.videoPreviewLayer.videoGravity = .resizeAspectFill
154151

155152
if let barcodeLayer = barcodeLayer {
@@ -164,7 +161,7 @@ import AVFoundation
164161
}
165162

166163
captureSession.start {
167-
self.rotateCameraPreview(to: self.view.window?.interfaceOrientation)
164+
self.rotateCameraPreview(to: self.view.window?.interfaceOrientation, frame: self.view.frame)
168165
}
169166
}
170167

@@ -173,31 +170,31 @@ import AVFoundation
173170
cameraPreviewView.removeFromSuperview()
174171
}
175172

176-
private func rotateCameraPreview(to interfaceOrientation: UIInterfaceOrientation?) {
173+
private func rotateCameraPreview(to interfaceOrientation: UIInterfaceOrientation?, frame: CGRect) {
177174
guard let connection = cameraPreviewView.videoPreviewLayer.connection,
178175
connection.isVideoOrientationSupported,
179176
let orientation = interfaceOrientation else {
180177
return
181178
}
182179

183-
cameraPreviewView.frame = view.bounds
180+
cameraPreviewView.frame = frame
184181
connection.videoOrientation = orientation.videoOrientation ?? .portrait
185182
cameraPreviewView.clearAccessibilityElements()
186183

187184
if orientation.isLandscape {
188185
messageLayer.transform = CATransform3DIdentity
189-
messageLayer.setFrame(frame: view.bounds)
186+
messageLayer.setFrame(frame: frame)
190187
barcodeLayer?.transform = CATransform3DIdentity
191-
barcodeLayer?.setFrame(frame: view.bounds)
188+
barcodeLayer?.setFrame(frame: frame)
192189
} else {
193190
if CATransform3DIsIdentity(messageLayer.transform) {
194191
messageLayer.rotate(angle: 90)
195192
}
196193
if let barcodeLayer = barcodeLayer, CATransform3DIsIdentity(barcodeLayer.transform) {
197-
barcodeLayer.setFrame(frame: view.bounds)
194+
barcodeLayer.setFrame(frame: frame)
198195
barcodeLayer.rotate(angle: 90)
199196
}
200-
messageLayer.setVerticalDefaultSettings(frame: view.bounds)
197+
messageLayer.setVerticalDefaultSettings(frame: frame)
201198
}
202199
cameraPreviewView.videoPreviewLayer.removeAllAnimations()
203200
}
@@ -264,12 +261,12 @@ extension BarcodeCameraViewController: BarcodeCaptureDelegate {
264261
public func captured(barcode: String?) {
265262
guard let barcode = barcode, afterCaptureTimer == nil else { return }
266263

264+
messageLayer.string = NSLocalizedString("acuant_camera_capturing", comment: "")
267265
if let orientation = view.window?.interfaceOrientation, orientation.isPortrait {
268266
messageLayer.setVerticalCaptureSettings(frame: view.bounds)
269267
} else {
270268
messageLayer.setCaptureSettings(frame: view.bounds)
271269
}
272-
messageLayer.string = NSLocalizedString("acuant_camera_capturing", comment: "")
273270
afterCaptureTimer = Timer.scheduledTimer(withTimeInterval: TimeInterval(options.timeInMsPerDigit/1000),
274271
repeats: false) { [weak self] _ in
275272
guard let self = self else { return }

AcuantCamera/AcuantCamera/Camera/CameraOptions.swift

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@
99
import Foundation
1010
import UIKit
1111

12-
@objcMembers public class CameraOptions : NSObject{
12+
@objcMembers public class CameraOptions: NSObject {
1313

1414
public let timeInMsPerDigit: Int
1515
public let digitsToShow: Int
1616
public let allowBox: Bool
1717
public let autoCapture: Bool
18-
public let hideNavigationBar : Bool
19-
public let bracketLengthInHorizontal : Int
18+
public let hideNavigationBar: Bool
19+
public let bracketLengthInHorizontal: Int
2020
public let bracketLengthInVertical: Int
21-
public let defaultBracketMarginWidth : CGFloat
22-
public let defaultBracketMarginHeight : CGFloat
21+
public let defaultBracketMarginWidth: CGFloat
22+
public let defaultBracketMarginHeight: CGFloat
2323
public let colorHold: CGColor
2424
public let colorCapturing: CGColor
25+
public let colorReposition: CGColor
2526
public let colorBracketAlign: CGColor
2627
public let colorBracketCloser: CGColor
2728
public let colorBracketHold: CGColor
@@ -31,22 +32,22 @@ import UIKit
3132

3233
public init(timeInMsPerDigit: Int = 900,
3334
digitsToShow: Int = 2,
34-
allowBox : Bool = true,
35-
autoCapture : Bool = true,
36-
hideNavigationBar : Bool = true,
37-
bracketLengthInHorizontal : Int = 80,
38-
bracketLengthInVertical : Int = 50,
39-
defaultBracketMarginWidth : CGFloat = 0.5,
40-
defaultBracketMarginHeight : CGFloat = 0.6,
35+
allowBox: Bool = true,
36+
autoCapture: Bool = true,
37+
hideNavigationBar: Bool = true,
38+
bracketLengthInHorizontal: Int = 80,
39+
bracketLengthInVertical: Int = 50,
40+
defaultBracketMarginWidth: CGFloat = 0.5,
41+
defaultBracketMarginHeight: CGFloat = 0.6,
4142
colorHold: CGColor = UIColor.yellow.cgColor,
4243
colorCapturing: CGColor = UIColor.green.cgColor,
44+
colorReposition: CGColor = UIColor.red.cgColor,
4345
colorBracketAlign: CGColor = UIColor.black.cgColor,
4446
colorBracketCloser: CGColor = UIColor.red.cgColor,
4547
colorBracketHold: CGColor = UIColor.yellow.cgColor,
4648
colorBracketCapture: CGColor = UIColor.green.cgColor,
4749
defaultImageUrl: String = "",
4850
showBackButton: Bool = true) {
49-
5051
self.timeInMsPerDigit = timeInMsPerDigit
5152
self.digitsToShow = digitsToShow
5253
self.allowBox = allowBox
@@ -58,6 +59,7 @@ import UIKit
5859
self.defaultBracketMarginHeight = defaultBracketMarginHeight
5960
self.colorHold = colorHold
6061
self.colorCapturing = colorCapturing
62+
self.colorReposition = colorReposition
6163
self.colorBracketAlign = colorBracketAlign
6264
self.colorBracketCloser = colorBracketCloser
6365
self.colorBracketHold = colorBracketHold

AcuantCamera/AcuantCamera/Camera/Document/Delegate/DocumentCaptureDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ import UIKit
1111

1212
@objc public protocol DocumentCaptureDelegate {
1313
func readyToCapture()
14-
func documentCaptured(image:UIImage, barcodeString:String?)
14+
func documentCaptured(image: UIImage, barcodeString: String?)
1515
}

AcuantCamera/AcuantCamera/Camera/Document/DocumentCameraController.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ import AcuantCommon
109109
coordinator.animate(alongsideTransition: { [weak self] context in
110110
guard let self = self else { return }
111111

112-
self.rotateCameraPreview(to: self.view.window?.interfaceOrientation)
112+
let newFrame = CGRect(origin: self.view.frame.origin, size: size)
113+
self.rotateCameraPreview(to: self.view.window?.interfaceOrientation, frame: newFrame)
113114
})
114115
}
115116

@@ -160,7 +161,7 @@ import AcuantCommon
160161
autoCaptureDelegate: self,
161162
captureDevice: captureDevice)
162163
self.captureSession.start()
163-
cameraPreviewView = CameraPreviewView(frame: view.bounds, captureSession: captureSession)
164+
cameraPreviewView = CameraPreviewView(frame: view.frame, captureSession: captureSession)
164165
cameraPreviewView.videoPreviewLayer.videoGravity = UIDevice.current.userInterfaceIdiom == .pad
165166
? .resizeAspectFill
166167
: .resizeAspect
@@ -172,7 +173,7 @@ import AcuantCommon
172173
self.cameraPreviewView.layer.addSublayer(self.cornerLayer)
173174
self.view.addSubview(cameraPreviewView)
174175

175-
rotateCameraPreview(to: self.view.window?.interfaceOrientation)
176+
rotateCameraPreview(to: self.view.window?.interfaceOrientation, frame: view.frame)
176177

177178
if self.options.showBackButton {
178179
addNavigationBackButton()
@@ -198,27 +199,27 @@ import AcuantCommon
198199
return image
199200
}
200201

201-
private func rotateCameraPreview(to interfaceOrientation: UIInterfaceOrientation?) {
202+
private func rotateCameraPreview(to interfaceOrientation: UIInterfaceOrientation?, frame: CGRect) {
202203
guard let connection = cameraPreviewView.videoPreviewLayer.connection,
203204
connection.isVideoOrientationSupported,
204205
let orientation = interfaceOrientation else {
205206
return
206207
}
207208

208-
cameraPreviewView.frame = view.bounds
209+
cameraPreviewView.frame = frame
209210
connection.videoOrientation = orientation.videoOrientation ?? .portrait
210211
cameraPreviewView.clearAccessibilityElements()
211212

212213
if orientation.isLandscape {
213214
messageLayer.transform = CATransform3DIdentity
214-
messageLayer.setFrame(frame: view.bounds)
215-
cornerLayer.setHorizontalDefaultCorners(frame: view.bounds)
215+
messageLayer.setFrame(frame: frame)
216+
cornerLayer.setHorizontalDefaultCorners(frame: frame)
216217
} else {
217218
if CATransform3DIsIdentity(messageLayer.transform) {
218219
messageLayer.rotate(angle: 90)
219220
}
220-
messageLayer.setVerticalDefaultSettings(frame: view.bounds)
221-
cornerLayer.setFrame(frame: view.bounds)
221+
messageLayer.setVerticalDefaultSettings(frame: frame)
222+
cornerLayer.setFrame(frame: frame)
222223
}
223224
cameraPreviewView.videoPreviewLayer.removeAllAnimations()
224225
}
@@ -271,21 +272,21 @@ import AcuantCommon
271272
}
272273

273274
if interfaceOrientation.isLandscape {
274-
landscapeSetting(view.bounds)
275+
landscapeSetting(view.frame)
275276
} else {
276-
portraitSetting(view.bounds)
277+
portraitSetting(view.frame)
277278
}
278279
}
279280

280-
private func cancelCapture(state: CameraState, message: String){
281+
private func cancelCapture(state: CameraState, message: String) {
281282
self.setLookFromState(state: state)
282283
self.messageLayer.string = message
283284
self.triggerHoldSteady()
284285
self.captureTimerState = 0.0
285286
}
286287

287-
private func triggerHoldSteady(){
288-
if(!self.isHoldSteady && self.autoCapture){
288+
private func triggerHoldSteady() {
289+
if !self.isHoldSteady && self.autoCapture {
289290
self.isHoldSteady = true
290291
holdSteadyTimer = Timer.scheduledTimer(
291292
timeInterval: 0.1,
@@ -424,13 +425,12 @@ extension DocumentCameraController: DocumentCaptureDelegate {
424425
public func readyToCapture() {
425426
DispatchQueue.main.async {
426427
if self.messageLayer != nil {
428+
self.messageLayer.string = NSLocalizedString("acuant_camera_capturing", comment: "")
427429
if self.autoCapture {
428430
self.setLookFromState(state: DocumentCameraController.CameraState.Capture)
429-
self.setMessageCaptureSettings()
430431
} else {
431432
self.setMessageDefaultSettings()
432433
}
433-
self.messageLayer.string = NSLocalizedString("acuant_camera_capturing", comment: "")
434434
self.captured = true
435435
}
436436
}

AcuantCamera/AcuantCamera/Camera/Document/DocumentCaptureSession.swift

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ import AcuantImagePreparation
147147
var scaledPoints = [CGPoint]()
148148
var resolutionThreshold = CaptureConstants.MANDATORY_RESOLUTION_THRESHOLD_DEFAULT
149149

150-
if self.isDocumentAligned(croppedFrame.points), self.shouldShowBorder {
150+
if self.shouldShowBorder {
151151
croppedFrame.points.forEach{ point in
152152
var scaled: CGPoint = CGPoint()
153153
scaled.x = point.x/frameSize.width as CGFloat
@@ -162,21 +162,26 @@ import AcuantImagePreparation
162162
resolutionThreshold = Int(Double(frameSize.width) * smallerDocumentDPIRatio)
163163
}
164164

165-
if croppedFrame.error?.errorCode == AcuantErrorCodes.ERROR_CouldNotCrop || croppedFrame.dpi < CaptureConstants.NO_DOCUMENT_DPI_THRESHOLD {
165+
let frameRect = CGRect(origin: CGPoint(x: 0, y: 0), size: frameSize).insetBy(dx: 15, dy: 15)
166+
let detectedRect = CGRect(points: croppedFrame.points)
167+
168+
if croppedFrame.error?.errorCode == AcuantErrorCodes.ERROR_CouldNotCrop
169+
|| croppedFrame.dpi < CaptureConstants.NO_DOCUMENT_DPI_THRESHOLD
170+
|| !self.isDocumentAligned(croppedFrame.points) {
166171
return (.NO_DOCUMENT, scaledPoints)
172+
} else if !croppedFrame.isCorrectAspectRatio {
173+
return (.BAD_ASPECT_RATIO, scaledPoints)
167174
} else if croppedFrame.error?.errorCode == AcuantErrorCodes.ERROR_LowResolutionImage, croppedFrame.dpi < resolutionThreshold {
168175
return (.SMALL_DOCUMENT, scaledPoints)
169-
} else if !croppedFrame.isCorrectAspectRatio {
170-
return (.BAD_ASPECT_RATIO, scaledPoints)
171-
} else if CGRect(points: croppedFrame.points) != nil {
172-
return (.GOOD_DOCUMENT, scaledPoints)
173-
} else {
176+
} else if let rect = detectedRect, !frameRect.contains(rect) {
174177
return (.DOCUMENT_NOT_IN_FRAME, scaledPoints)
178+
} else {
179+
return (.GOOD_DOCUMENT, scaledPoints)
175180
}
176181
}
177182

178-
public func getFrameMatchThreshold(cropDuration: Double) -> Int{
179-
switch(cropDuration){
183+
public func getFrameMatchThreshold(cropDuration: Double) -> Int {
184+
switch cropDuration {
180185
case 0..<0.8:
181186
return FAST_FRAME_THRESHOLD
182187
default:

0 commit comments

Comments
 (0)