feat: unified anchor-based ID OCR + 16KB-aligned native deps (0.6.0)#160
Open
haklyray wants to merge 4 commits into
Open
feat: unified anchor-based ID OCR + 16KB-aligned native deps (0.6.0)#160haklyray wants to merge 4 commits into
haklyray wants to merge 4 commits into
Conversation
…tion - Upgrade Gradle build files to Kotlin DSL and update dependencies - Merge simple OCR and ID scan OCR into a single unified OCR mode - Add anchor-based field extraction with per-country configs (Colombia, Venezuela, Nicaragua, Guatemala) - Normalize output fields to standard keys (documentNumber, firstName, lastName, dateOfBirth, gender) - Parse dates and gender values per-country configuration - Return both normalized fields and rawFields in OCR result - Fix portrait rotation for ID scanning (hardcode 90° instead of device-reported) - Add rect border color feedback (grey→blue→green) during scanning - Add debug overlay toggle in example app settings (enabled by default) - Remove table OCR from example app
CameraX 1.3.1 ships libimage_processing_util_jni.so with 4KB LOAD segment alignment, which Google Play rejects for SDK-35 AABs on devices with 16KB memory pages. 1.4.x publishes 16KB-aligned natives. Sentry is already on 8.0.0 in this repo and does not need a change here; the matching bump in smartscanner-capacitor's android/build.gradle is landing on chore/16kb-deps in that repo so it picks up the same Sentry 8.x at consumer build time.
…ebug-only
Three review findings on top of feat/Improvement-of-OCR that should land
before tagging 0.6.0:
1. Manual capture regression. SmartScannerActivity's R.id.manual_capture
handler called cameraProvider.unbindAll() *before* imageCapture.takePicture(),
so the use case was always unbound when takePicture ran -- onError fired,
onImageSaved never did, and the captured frame was silently dropped on every
manual capture (MRZ manual, document capture, OCR manual). Drop the unbind.
The activity's lifecycle handles cleanup on finish().
2. Cell-level OCR was creating a fresh single-thread executor per anchor
inside the per-field loop (Executors.newSingleThreadExecutor() with no
shutdown), and awaiting each field synchronously for up to 1s. For
Nicaragua / Guatemala (5+ fields) that meant up to ~5s of analyzer-thread
blocking per frame plus a handful of leaked non-daemon threads. Hoist the
executor to a lazy class field, enqueue all cell-OCR tasks during the
per-field sweep, then await all in parallel under one 2s overall timeout.
Worst case wall time is now bounded by the slowest individual recognition,
not their sum.
3. Demo app was carrying a commented-out signingConfig and an unsigned
release build type. The demo isn't published; it ships debug-only.
Removed the release block, the missingDimensionStrategy("variant","full")
no-op (core-lib has no flavor dimension), and the dead signingConfig
placeholder.
…on versions CI was failing on this branch for three reasons: 1. ./gradlew assembleRelease tried to build :app:assembleRelease, but the demo app no longer has a release buildType (it's debug-only by direction). Switched to ./gradlew :core-lib:assembleRelease :app:assembleDebug so the library still produces a release AAR while the demo builds debug-only. 2. The runner default JDK is not 21, but the build pins JavaVersion.VERSION_21 / jvmTarget = "21". Added actions/setup-java@v4 with temurin 21. 3. actions/checkout@v2, actions/cache@v2, actions/upload-artifact@v2 are end-of-life. Bumped to @v4. v4 also requires unique artifact names, so both uploads were renamed (core-lib-aar / demo-app-debug). Also dropped the signing.properties echo step -- nothing in the build files references it (legacy from when the demo app had a configured release signingConfig).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cuts
0.6.0(next minor after0.5.1). Three things:scanIDOCRCountryOptions) is byte-for-byte unchanged.libimage_processing_util_jni.sowas 4KB-aligned; 1.4.x ships 16KB. Required for SDK-35 Play uploads. Sentry is already on 8.0.0 here.Fixes since first review
cameraProvider.unbindAll()ran beforeimageCapture.takePicture()→ every manual capture failed silentlyExecutors.newSingleThreadExecutor()per anchor and awaited each field for 1s (~5s analyzer-thread block on 5-field countries, plus leaked threads)signingConfigs, and themissingDimensionStrategyno-op. Demo is debug-only by direction.Compatibility
OCRResultadds three default-valued fields. Source-compatible. Gson consumers unaffected; callers usingOCRResult.copy(...)need a recompile.Modes.SCAN_ID_OCR("manual-ocr")already marked@Deprecated; unifiedModes.OCRis the supported path.Known limitations (follow-ups)
core-lib-{debug,release}.aar. The Capacitor plugin still vendorssmartscannerlib-{debug,release}-1.0.aar— rename in your publish step.Expiry Dateregex ([0-9]{2}-[0-9]{4}) doesn't match the country-leveldateFormat = "dd/MM/yyyy", so the field returns raw"12-2030". Needs a per-field dateFormat override (API change) to fix properly.Image.ktextensions (toGrayscale,adaptiveThreshold, etc.) andOCROptions.width/height.Release
Tag
0.6.0pushed @9f6f040. Commits:6f5ad4cfeat: unified OCR with anchor-based ID scanning and country normalization0d0dde7chore: bump CameraX to 1.4.2 for 16KB page alignment9f6f040fix(ocr): parallel cell-OCR + drop unbind-before-takePicture + demo debug-only