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: configurable image resolution for barcode scanning #220

Closed
3 of 7 tasks
jkorrek opened this issue Jan 7, 2025 · 2 comments
Closed
3 of 7 tasks

feat: configurable image resolution for barcode scanning #220

jkorrek opened this issue Jan 7, 2025 · 2 comments

Comments

@jkorrek
Copy link
Contributor

jkorrek commented Jan 7, 2025

Plugin(s)

  • Barcode Scanning
  • Face Detection
  • Face Mesh Detection
  • Selfie Segmentation
  • Translation

Current problem

I am having trouble scanning certain barcodes or datamatrix, especially on android. This seems to happen when trying to scan smaller barcodes.

After investigating a bit, I found out, that no targetResolution is specified for the android implementation. The ImageAnalysis class will use 640x480 as a default.
The iOS implementation uses AVCaptureSession.Preset.hd1280x720.

The mlkit guidelines recommend 1280x780 or 1920x1080.

After increasing the resolution for the android implementation, scanning the "problematic" codes was going much better.

Preferred solution

The image resolution used for detection should be either configurable. Maybe not on an "pixel perfect" level, but rather an enum with values corresponding to 1280x780, 1920x1080, ...

Alternative options

If this should not be configurable, maybe setting a higher default resolution for android (also to 1280x780 maybe?) would be a good idea.

Additional context

I would be happy to provide a PR, if one of my suggestions would be acceptable.

Before submitting

@robingenz
Copy link
Member

Great idea. Feel free to create a PR. I suggest the following types:

export interface StartScanOptions {
  formats?: BarcodeFormat[];
  lensFacing?: LensFacing;
  resolution?: Resolution;
}

export enum Resolution {
  '640x480' = 0,
  '1280x720' = 1,
  '1920x1080' = 2
}

@robingenz
Copy link
Member

Closed by #221

robingenz added a commit that referenced this issue Jan 27, 2025
* chore(changeset): enter prerelease mode

* chore: changeset pre exit

* chore: enter prerelease mode

* ci: run on `next` branch

* docs: add changeset

* docs: remove changeset

* fix!: update `GoogleMLKit` pods to version `6.0.0` on iOS (#179)

* fix: update `GoogleMLKit` pods to version `6.0.0` on iOS

* revert

* chore(ios): set minimum deployment target to 16

* chiore(translation): increase deployment target

* chore(translation): set minimum deployment target to 15.5

* docs

* docs: update changeset

* docs: mention `next` tag

* chore(release): publish (next) (#196)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* fix: update `GoogleMLKit` pods to version `7.0.0` (#202)

* fix: increase deployment target to `15.5`

* docs

* fix(ios): update `GoogleMLKit` pods to version `7.0.0`

* chore: update `package-lock.json`

* chore(release): publish (next) (#203)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* feat(barcode-scanning): support all barcode types (#206)

* feat(barcode-scanning): extend definitions.ts with new properties

* Update packages/barcode-scanning/src/definitions.ts

* Update .changeset/mighty-comics-whisper.md

* feat(barcode-scanning): suggested changes

* feat(barcode-scanning): support all barcode types on android

* chore(): remove additional null checks

* feat(barcode-scanning): ios implementation

* chore(barcode-scanning): use if let to avoid the force unwrap

* chore(barcode-scanning): fix force unwrap

---------

Co-authored-by: Robin Genz <[email protected]>

* refactor(barcode-scanning): prefix interfaces with `Barcode`

* fix(barcode-scanning): convert `end` and `start` to ISO 8601 string

* chore(barcode-scanning): remove deprecated warnings for torch methods (#209)

* fix(barcode-scanning): remove deprecated warnings for torch methods

Close robingenz/capacitor-mlkit-plugin-demo#27

* Delete .changeset/stupid-trains-change.md

* docs: run `docgen`

* feat(barcode-scanning): add compatibility for the Torch plugin (#210)

* feat(barcode-scanning): add compatibility for the Torch plugin

* Revert "chore(barcode-scanning): remove deprecated warnings for torch methods (#209)"

This reverts commit 3492c0e.

* chore(release): publish (next) (#207)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* chore(deps): update `@capacitor/docgen`

* feat(barcode-scanning): add option for image resolution (#220) (#221)

* docs(barcode-scanning): update `BREAKING.md`

* chore(barcode-scanning): update `definitions.ts`

* ci: add step to install CocoaPods dependencies

* chore: add missing `ios:pod:install` script

* fix(barcode-scanning): resize the barcode scanner view when the device orientation changes (#224)

* chore(release): publish (next) (#222)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

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

Include raw cornerPoints for all methods except startScan.

* fix(barcode-scanning): use queue for synchronizing the session configuration and start operations of the `scan(...)` method

* fix: DispatchQueue for synchronizing the session configuration and start operations

* fix: npm run changeset

* fix: remove duplicated empty line

* Update .changeset/forty-avocados-allow.md

Co-authored-by: Robin Genz <[email protected]>

* fix: resolve conflicts against next

* fix: init captureSession before captureSessionQueue.sync

* Update .changeset/forty-avocados-allow.md

* fix: init sessionPreset, captureDevice

---------

Co-authored-by: Robin Genz <[email protected]>

* fix(barcode-scanning): destroy the preview view when the scan stops (#227)

* fix(barcode-scanning): destroy the preview view when the scan stops

* test

* style: format

* wip

* wip

* wip

* wip

* docs(barcode-scanning): update `README.md`

* refactor!: remove deprecated code (#229)

* docs: update `README.md`

* chore: update native dependencies (#230)

* chore: update native dependencies

Increment all dependencies to the latest available version.

* chore: update native dependencies

Run fmt script.

* chore: update native dependencies

Generate changeset.

* chore: update native dependencies

Fix version of mlkitBarcodeScanningVersion.

* chore: update native dependencies

Fix typos and requested changes.

* feat!: update to Capacitor 7 (#232)

* feat!: update to Capacitor 7

* ci

* chore: update `package-lock.json`

* wip: prettier

* chore: add gradle wrapper

* chore(deps): update `androidxEspressoCoreVersion` version

* chore(changeset): exit pre release

* revert: chore(changeset): exit pre release

This reverts commit 23707a0.

* chore(release): publish (next) (#226)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* chore(changeset): exit pre release

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Mert Yıldırır <[email protected]>
Co-authored-by: Johannes Korrek <[email protected]>
Co-authored-by: Ehsan Barooni <[email protected]>
Co-authored-by: Jaime Caso <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants