Robust color handling via zbar 8bpp conversion #170
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.
While pyzbar.decode converts PIL image into greyscale or enforces greyscale image for a (pixel, width, height) argument; it currently grabs only the first channel from NumPy arrays. That works for grayscale/standard RGB, but fails when the QR foreground/background is carried in non-first channels (e.g., red-only scenes). Since libzbar already provides reliable color→8bpp conversion, this PR routes array inputs through zbar’s converters to ensure correct decoding regardless of which channel holds the signal.
Add thin wrappers for zbar_image_convert, zbar_image_convert_resize, zbar_image_get_data, and zbar_image_get_data_length.
When a NumPy array with 3/4 channels is passed, convert to 8bpp via libzbar before scanning.
Preserve existing grayscale path; no behavior change for 8bpp inputs.