Fix: validate finder pattern geometry before early termination#84
Open
bashhack wants to merge 1 commit intomakiuchi-d:masterfrom
Open
Fix: validate finder pattern geometry before early termination#84bashhack wants to merge 1 commit intomakiuchi-d:masterfrom
bashhack wants to merge 1 commit intomakiuchi-d:masterfrom
Conversation
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.
Summary
HaveMultiplyConfirmedCenters()before allowing the finder pattern scanner to stop earlyContext
I observed that the finder pattern scanner stops as soon as
HaveMultiplyConfirmedCenters()returns true. Previously this only checked that the 3 candidates had consistent module sizes. But QR data can sometimes contain patterns that match the 1:1:3:1:1 finder pattern ratio, which is a false positive. When a false positive is accepted, the scanner stop before reaching the real third finder pattern, leading to a failed decode.A real QR code's three finder patterns form an isosceles right triangle. A false positive from QR data produces a skewed triangle with side ratio > 1.5. The 1.4 threshold I've chosen here rejects these while still aiming to accommodate the slight asymmetry of real-world captures.
In my testing - this change has a significant impact on the observed ~5% failure rate on randomly generated TOTP QR codes at 200-400px sizes.
Testing
[x] All existing
arcade/detectortests pass