diff --git a/CHANGELOG.md b/CHANGELOG.md index 3501d953..8fd44910 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Bugs fixed: * [Apple] Fixed an issue which caused the scanWindow to always be present, even when reset to no value. * [Apple] Fixed an issue that caused the barcode size to report the wrong height. +* [Apple] Fixed a bug that caused the corner points to not be returned in clockwise orientation. Improvements: * Added a basic barcode overlay widget, for use with the camera preview. diff --git a/darwin/mobile_scanner/Sources/mobile_scanner/MobileScannerPlugin.swift b/darwin/mobile_scanner/Sources/mobile_scanner/MobileScannerPlugin.swift index 6904f37e..e8d7c0ba 100644 --- a/darwin/mobile_scanner/Sources/mobile_scanner/MobileScannerPlugin.swift +++ b/darwin/mobile_scanner/Sources/mobile_scanner/MobileScannerPlugin.swift @@ -814,11 +814,12 @@ extension VNBarcodeObservation { let bottomRightY = (1 - bottomRight.y) * CGFloat(imageHeight) let bottomLeftY = (1 - bottomLeft.y) * CGFloat(imageHeight) let data = [ + // Clockwise, starting from the top-left corner. "corners": [ - ["x": bottomLeftX, "y": bottomLeftY], ["x": topLeftX, "y": topLeftY], ["x": topRightX, "y": topRightY], ["x": bottomRightX, "y": bottomRightY], + ["x": bottomLeftX, "y": bottomLeftY], ], "format": symbology.toInt ?? -1, "rawValue": payloadStringValue ?? "", diff --git a/lib/src/objects/barcode.dart b/lib/src/objects/barcode.dart index 907756be..ea9aa03d 100644 --- a/lib/src/objects/barcode.dart +++ b/lib/src/objects/barcode.dart @@ -102,10 +102,16 @@ class Barcode { /// The contact information that is embedded in the barcode. final ContactInfo? contactInfo; - /// The four corner points of the barcode, - /// in clockwise order, starting with the top-left point. + /// The corner points of the barcode. /// - /// Due to the possible perspective distortions, this is not necessarily a rectangle. + /// On Android, iOS and MacOS, this is a list of four points, + /// in clockwise direction, starting with the top left. + /// + /// On the web, the amount of points and their order + /// is dependent on the type of barcode that was detected. + /// + /// Due to the possible perspective distortions, + /// the points do not necessarily form a rectangle. /// /// This list is empty if the corners can not be determined. final List corners; diff --git a/lib/src/web/zxing/result.dart b/lib/src/web/zxing/result.dart index dd43b09f..903b6214 100644 --- a/lib/src/web/zxing/result.dart +++ b/lib/src/web/zxing/result.dart @@ -75,6 +75,8 @@ extension type Result(JSObject _) implements JSObject { /// Convert this result to a [Barcode]. Barcode get toBarcode { + // The order of the points is dependent on the type of barcode. + // Don't do a manual correction here, but leave it up to the reader implementation. final List corners = resultPoints; return Barcode(