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): zoom functionality #72

Closed
1 of 3 tasks
Melynt3 opened this issue Sep 7, 2023 · 11 comments · Fixed by #112
Closed
1 of 3 tasks

feat(barcode-scanning): zoom functionality #72

Melynt3 opened this issue Sep 7, 2023 · 11 comments · Fixed by #112

Comments

@Melynt3
Copy link

Melynt3 commented Sep 7, 2023

Plugin(s)

  • Barcode Scanning
  • Face Detection
  • Translation

Current problem

Hi,

I asked about this a few days ago in a different topic, but I would like to officially request a new feature, which is zoom functionality. It's a big challenge to work with small barcodes. I encountered a problem when scanning small CODE128 codes; basically, the scanner does not read them. I was able to hardcode a workaround in the library itself by adding a zoom of 1.6f during camera initialization, but this is only a temporary solution. It would be a great feature that would make the library even more attractive.

Preferred solution

Adding a zoom based on the google barcode scanner, which is implemented in the demo version
either zoom by "enlarging the screen" or by adding a slider

Alternative options

While working on react library i occured this kind of zoom which was very intuitive and it was known to be there.
1 (3)

Additional context

No response

@sephallen
Copy link

Having the ability to set the zoom level on initialisation would be very useful.

I am also experiencing similar issues with small CODE39 barcodes, the library is not able to read the value unless you pinch to zoom around 200%.

@Melynt3
Copy link
Author

Melynt3 commented Oct 12, 2023

Yup, i occured the same error with different type.

i temporary fixed it by setting zoom lvl to 1.65 ratio in library from android studio, if u have more efficient way to manage it i would be greatful.

CameraControl cameraControl = camera.getCameraControl();
float zoomLevel = 1.65f;
cameraControl.setZoomRatio(zoomLevel);

@robingenz
Copy link
Member

robingenz commented Oct 12, 2023

PRs are welcome. I propose these types:

  /**
   * Set the zoom ratio of the camera.
   * 
   * Only available on Android and iOS.
   */
  setZoomRatio(options: SetZoomRatioOptions): Promise<void>;
  /**
   * Get the zoom ratio of the camera.
   * 
   * Only available on Android and iOS.
   */
  getZoomRatio(): Promise<GetZoomRatioResult>;
  /**
   * Get the minimum zoom ratio of the camera.
   * 
   * Only available on Android and iOS.
   */
  getMinZoomRatio(): Promise<GetMinZoomRatioResult>;
  /**
   * Get the maximum zoom ratio of the camera.
   * 
   * Only available on Android and iOS.
   */
  getMaxZoomRatio(): Promise<GetMaxZoomRatioResult>;

Docs:

Edit:

  • There should also be a new zoomRatio property in the StartScanOptions interface to set an initial zoom ratio.
  • The setZoomRatio(...) method should throw an error if the value is too large or too small.
  • This issue only refers to the startScan(...) method, not the scan(...) method.

@robingenz robingenz changed the title feat: Zoom functionality feat(barcode-scanning): zoom functionality Dec 6, 2023
@vosecek
Copy link

vosecek commented Dec 20, 2023

Hi, any chance this task could be implemented?

@robingenz
Copy link
Member

@vosecek Sure, but there is no ETA yet.
Here you can find information on how to speed up the process.

@vosecek
Copy link

vosecek commented Dec 20, 2023

@robingenz what is appropriate price/bounty for implementation?

@robingenz
Copy link
Member

@vosecek You can set any amount. Just take care of the minimum and maximum amount (see FAQ).

@vosecek
Copy link

vosecek commented Dec 20, 2023

@robingenz
Copy link
Member

@vosecek Thank you for your contribution! I will prioritize the issue.

@robingenz
Copy link
Member

I’ve just published a dev version, see #112 (comment).
Feel free to give it a try. I would appreciate any feedback.

@vosecek
Copy link

vosecek commented Dec 21, 2023

I’ve just published a dev version, see #112 (comment). Feel free to give it a try. I would appreciate any feedback.

Works great, thanks!

ion-range is not handy component for this, cause zoom is needed only 2x-4x, using sliding range is difficult to set useful zoom ratio.

My implementation for controls is

<ion-fab slot="fixed" horizontal="end" vertical="center">
        <ion-fab-button (click)="increaseZoom()" [disabled]="currentZoomRatio >= maxZoomRatio" class="ion-margin-bottom" [color]="'primary'">
            <ion-icon size="large" name="search-outline"></ion-icon>
        </ion-fab-button>
        <ion-fab-button (click)="decreaseZoom()" [disabled]="currentZoomRatio <= minZoomRatio" [color]="'dark'">
            <ion-icon size="small" name="search-outline"></ion-icon>
        </ion-fab-button>
    </ion-fab>
// set this.currentZoomRatio on init
increaseZoom() {
    // @ts-ignore
    this.setZoomRatio({detail: {value: this.currentZoomRatio + 1}});
  }

  decreaseZoom() {
    // @ts-ignore
    this.setZoomRatio({detail: {value: this.currentZoomRatio - 1}});
  }

public setZoomRatio(event: InputCustomEvent): void {
    if (!event.detail.value) {
      return;
    }
    BarcodeScanner.setZoomRatio({
      zoomRatio: parseInt(event.detail.value as any, 10),
    }).then(() => {
      BarcodeScanner.getZoomRatio().then(r => {
        this.currentZoomRatio = r.zoomRatio;
      });
    }, err => {
      console.log(err);
    });
  }

This is just my suggestion for demo code. Anyway, this is great and fulfil our needs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants