Skip to content

Fix padded iOS camera frame luminance conversion - #324

Draft
jfversluis wants to merge 1 commit into
mainfrom
jfversluis-camera-resolution-issue
Draft

jfversluis wants to merge 1 commit into
mainfrom
jfversluis-camera-resolution-issue

Conversation

@jfversluis

Copy link
Copy Markdown
Collaborator

Summary

Related to #323.

The iOS/MacCatalyst camera luminance converter assumed that BGRA rows were tightly packed. CoreVideo buffers can contain row padding, which was being interpreted as image pixels and distorting the input passed to ZXing.

  • Respect CVPixelBuffer.BytesPerRow and reuse the existing stride-aware BGRA luminance helper.
  • Correct luminance rounding through the shared conversion implementation.
  • Add camera-free regression coverage for padded buffers and both barcode values from the report.
  • Document format restriction and cross-frame confirmation as application-level mitigations without changing scanner defaults.

Reproduction and validation

A camera-free harness using the actual iOS converter source reproduced corruption: a padded 2×2 buffer returned 0, 254, 98, 254 instead of 0, 255, 255, 0. The corrected converter produces the expected pixels.

The issue's actual barcode photographs were decoded at seven simulated resolutions each. Results were either the expected barcode or no detection; the reported incorrect values were not reproduced. This fixes a confirmed conversion bug, but its contribution to #323 remains unconfirmed and requires testing on the affected iPhone.

  • 22 targeted luminance/barcode tests passed.
  • iOS and MacCatalyst builds succeeded without warnings or errors.

Device testing

The existing CI workflow uploads a NuGet artifact containing the experimental packages when its build completes. Please test both packages together on the affected device and report whether the erroneous EAN-13/UPC-A/UPC-E detections persist. This PR intentionally remains draft pending that feedback.

Respect CVPixelBuffer row stride and reuse shared BGRA luminance conversion. Add camera-free coverage for padded buffers and the barcode values reported in issue #323.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 10b7ac79-c541-4682-a83f-fad27551a353
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant