diff --git a/Sources/CodeScanner/CodeScanner.swift b/Sources/CodeScanner/CodeScanner.swift index 827069e..3d4c1d8 100644 --- a/Sources/CodeScanner/CodeScanner.swift +++ b/Sources/CodeScanner/CodeScanner.swift @@ -37,6 +37,9 @@ public struct ScanResult { /// The image of the code that was matched public let image: UIImage? + + /// The corner coordinates of the scanned code. + public let corners: [CGPoint] } /// The operating mode for CodeScannerView. diff --git a/Sources/CodeScanner/ScannerViewController.swift b/Sources/CodeScanner/ScannerViewController.swift index d56798e..dc47fa3 100644 --- a/Sources/CodeScanner/ScannerViewController.swift +++ b/Sources/CodeScanner/ScannerViewController.swift @@ -68,7 +68,13 @@ extension CodeScannerView { if qrCodeLink == "" { didFail(reason: .badOutput) } else { - let result = ScanResult(string: qrCodeLink, type: .qr, image: qrcodeImg) + let corners = [ + feature.bottomLeft, + feature.bottomRight, + feature.topRight, + feature.topLeft + ] + let result = ScanResult(string: qrCodeLink, type: .qr, image: qrcodeImg, corners: corners) found(result) } @@ -125,7 +131,7 @@ extension CodeScannerView { // Send back their simulated data, as if it was one of the types they were scanning for found(ScanResult( string: parentView.simulatedData, - type: parentView.codeTypes.first ?? .qr, image: nil + type: parentView.codeTypes.first ?? .qr, image: nil, corners: [] )) } @@ -446,7 +452,7 @@ extension CodeScannerView { isCapturing = true handler = { [self] image in - let result = ScanResult(string: stringValue, type: readableObject.type, image: image) + let result = ScanResult(string: stringValue, type: readableObject.type, image: image, corners: readableObject.corners) switch parentView.scanMode { case .once: