Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(barcode-scanning): support cornerPoints in readBarcodesFromImage #225

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilled-plums-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@capacitor-mlkit/barcode-scanning': minor
---

feat(barcode-scanning): support `cornerPoints` in `readBarcodesFromImage(...)`
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ public static JSObject createBarcodeResultForBarcode(@NonNull Barcode barcode, @
cornerPointResult.put(normalizedCornerPoints[i].y);
cornerPointsResult.put(cornerPointResult);
}
} else if (cornerPoints != null && screenSize == null) {
for (Point cornerPoint : cornerPoints) {
JSArray cornerPointResult = new JSArray();
cornerPointResult.put(cornerPoint.x);
cornerPointResult.put(cornerPoint.y);
cornerPointsResult.put(cornerPointResult);
}
}

JSObject result = new JSObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ public class BarcodeScannerHelper {
value.append(Int(cornerPoint.cgPointValue.y))
cornerPointsResult.append(value)
}
} else if let cornerPoints = barcode.cornerPoints, videoOrientation == nil {
for cornerPoint in cornerPoints {
var value = [Int]()
value.append(Int(cornerPoint.cgPointValue.x))
value.append(Int(cornerPoint.cgPointValue.y))
cornerPointsResult.append(value)
}
}

var result = JSObject()
Expand Down
Loading