docs(companion): verify the zxing-cpp integration sketch online
The QR-decoder option doc was written on an offline machine with the Maven coordinates and wrapper API flagged as from-memory. Verified against Maven Central + the wrapper source: artifact is io.github.zxing-cpp:android:3.1.1 (current release), Format.QR_CODE is nested inside BarcodeReader (not a top-level BarcodeFormat), options are a constructor-argument data class, and read(ImageProxy) handles the Y-plane/cropRect/rotation itself. Sketch updated accordingly; the option itself stays NOT-actioned pending the move-to-the-code decision trigger.
This commit is contained in:
@@ -88,29 +88,29 @@ proprietary and Play-Services-backed.
|
|||||||
|
|
||||||
## Integration sketch
|
## Integration sketch
|
||||||
|
|
||||||
> ⚠️ Coordinates and API surface below are from memory and were **not**
|
> Verified 2026-08-31 against Maven Central and the wrapper source
|
||||||
> verified against Maven Central — the machine this was written on had no
|
> (`wrappers/android/zxingcpp/src/main/java/zxingcpp/BarcodeReader.kt` at
|
||||||
> network. Confirm the current artifact version and wrapper API on the first
|
> `io.github.zxing-cpp:android:3.1.1`, the current release). Coordinates and
|
||||||
> online Gradle sync before trusting the snippet.
|
> API below are what the published artifact actually ships.
|
||||||
|
|
||||||
`Android/app/build.gradle.kts`:
|
`Android/app/build.gradle.kts`:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
// Replaces com.google.zxing:core for the live-camera path.
|
// Replaces com.google.zxing:core for the live-camera path.
|
||||||
implementation("io.github.zxing-cpp:android:<pin-exact-version>")
|
implementation("io.github.zxing-cpp:android:3.1.1")
|
||||||
```
|
```
|
||||||
|
|
||||||
`QrCodeAnalyzer` collapses to roughly:
|
`QrCodeAnalyzer` collapses to roughly:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
private val reader = BarcodeReader().apply {
|
private val reader = BarcodeReader(
|
||||||
options = BarcodeReader.Options(
|
options = BarcodeReader.Options(
|
||||||
formats = setOf(BarcodeFormat.QR_CODE),
|
formats = setOf(BarcodeReader.Format.QR_CODE),
|
||||||
tryHarder = true,
|
tryHarder = true,
|
||||||
tryRotate = true,
|
tryRotate = true,
|
||||||
tryInvert = true,
|
tryInvert = true,
|
||||||
)
|
)
|
||||||
}
|
)
|
||||||
|
|
||||||
override fun analyze(image: ImageProxy) {
|
override fun analyze(image: ImageProxy) {
|
||||||
try {
|
try {
|
||||||
@@ -121,6 +121,15 @@ override fun analyze(image: ImageProxy) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
API notes from the published wrapper: `BarcodeReader.read(ImageProxy)` takes
|
||||||
|
the CameraX `YUV_420_888` frame directly (it reads the Y plane + cropRect +
|
||||||
|
rotation itself — the manual crop/copy machinery really can go); options are
|
||||||
|
one constructor-argument data class; `Format.QR_CODE` is nested inside
|
||||||
|
`BarcodeReader` (not a top-level `BarcodeFormat`); results carry `text`,
|
||||||
|
`contentType`, `position` — and `lastReadTime` gives the per-call decode time
|
||||||
|
in ms, useful to measure the claimed 5–10× while evaluating. Keep
|
||||||
|
`com.google.zxing:core` for the still-image path regardless (below).
|
||||||
|
|
||||||
Keep `com.google.zxing:core` for now regardless: the still-image path
|
Keep `com.google.zxing:core` for now regardless: the still-image path
|
||||||
(`decodeQrFromUri` in `WalletQrScannerModal.kt`, used by "Upload image") and
|
(`decodeQrFromUri` in `WalletQrScannerModal.kt`, used by "Upload image") and
|
||||||
`prewarmQrScanner` both use it, and neither is on the hot path.
|
`prewarmQrScanner` both use it, and neither is on the hot path.
|
||||||
|
|||||||
Reference in New Issue
Block a user