decoder: read mirror images by retrying on the transposed grid - #40
Merged
Merged
Conversation
Owner
|
@copilot resolve the merge conflicts on this branch. |
Owner
|
Copilot doesn't work. So this needs a rebase, since the first PR got merged. |
A mirror image locates like any symbol, since finders and timing are symmetric, and fails only at the format and data bits. When the sampled grid does not decode, transpose it in place and try once more: the transpose of a mirrored symbol is the upright one. ISO/IEC 18004 expects a reader to read mirror images, and a camera plane can arrive mirrored with no metadata saying so (iOS WebKit hands VideoFrame.copyTo a mirrored rear-camera plane and reports neither flip nor rotation). The retry runs only after a failed read. BoofCV accuracy is unchanged (57.5%, every category identical); a 1080p frame with no symbol costs the same (blank 2.73 → 2.70 ms, noise 8.37 → 8.21 ms); raster and photo decodes are within noise.
Contributor
Author
|
Rebased |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A mirror image locates like any symbol, since finders and timing are symmetric, and fails only at the format and data bits. When the sampled grid does not decode, transpose it in place and try once more: the transpose of a mirrored symbol is the upright one. ISO/IEC 18004 expects a reader to read mirror images, and a camera plane can arrive mirrored with no metadata saying so.
Why
On iOS (WebKit),
VideoFrame.copyToof the rear camera hands the reader a plane that is a mirror image of the scene, and the frame reports neitherflipnorrotation. Every finder is found, and every decode fails. We hit this in production with the Rip port of this decoder and confirmed it withZXingReaderon the same bytes (IsMirrored: true).Checks
Real iPhone frames (2592x2160 NV12, rotated coded frame, fed to the decoder unchanged), plus a mirrored raster and a mirrored BoofCV photo:
blurred/image007, mirroredUpright inputs are unchanged. The retry runs only after a failed read, so successful decodes pay nothing; a 1080p frame with no symbol costs the same (blank 2.73 → 2.70 ms, noise 8.37 → 8.21 ms), and the worst case is one extra grid decode per failed projection. BoofCV accuracy is unchanged (57.5%, every category identical). One test added:
decodeQR reads mirror images.