Skip to content

BarcodeResult type mismatch between Android and iOS #48

Open
@boutier

Description

@boutier

Hi !

With mlkit 2.0.0, on Android, when scanning a *code, I have something like:

{
  "bounds": {
    "origin": { "x": 100, "y": 215 },
    "size": { "height": 166, "width": 172 }
  },
  "points": [
    { "x": 110, "y": 215 },
    { "x": 272, "y": 220 },
    { "x": 262, "y": 381 },
    { "x": 100, "y": 376 }
  ],
  "rawBytes": [68, 77, 83, 90, 49, 47, 49, 47, 49, 47, 49],
  "format": "QR_CODE",
  "displayValue": "DMSZ1/1/1/1",
  "rawValue": "DMSZ1/1/1/1",
  "valueType": "Text"
}

While I have on iOS:

{
  "bounds": { "y": 279, "x": 661, "width": 576, "height": 589 },
  "points": [
    { "x": 661, "y": 357 },
    { "x": 1161, "y": 279 },
    { "x": 1237, "y": 781 },
    { "x": 738, "y": 868 }
  ],
  "rawBytes": "RE1TWjEvMS8xLzE=",
  "format": ["qr_code"],
  "displayValue": "DMSZ1/1/1/1",
  "rawValue": "DMSZ1/1/1/1",
  "valueType": "text"
}

(both reordered for better readability)

The BarcodeResult interface is defined in https://github.com/NativeScript/mlkit/blob/0712e3dfe4b4d2eb4d0caa3e22786c603366f19f/packages/mlkit-barcode-scanning/index.ts

Given BarcodeResult is the reference:

  • on Android, enum values are not lowercase (QR_CODE and Text instead of qr_code and text in this case)
  • on iOS:
    • bounds is simpler (origin and size are inlined — which I personally prefer BTW)
    • rawBytes being base64 encoded (I guess) instead of being an array of any
    • format being an array

Side questions about BarcodeResult:

  • why having bounds with origin and size in the BarcodeResult model rather than just inlining them as in the current iOS implementation?
  • why having an Origin type while we already have a Point?
  • why typing rawBytes as any[] instead of number[] (or string if base64 is deemed better)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions