-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fallback locator point recenter #166
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple random question/ideas. I like how this moves us closer to supporting multiple QR codes too.
@@ -212,6 +212,20 @@ function scorePattern(point: Point, ratios: number[], matrix: BitMatrix) { | |||
} | |||
} | |||
|
|||
function recenterLocation(matrix: BitMatrix, p: Point): Point { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason we wouldn't recenter vertically too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think it would matter, but after testing, it appears that also leads to a slight improvement.
@@ -65,7 +65,7 @@ describe("locate", () => { | |||
|
|||
it("locates a damaged QR code and guesses the finder pattern location", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't feel too strongly but wouldn't hurt to add a test case for this - Would be as simple as taking one of the originally failing ones and committing it into the locator tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1,7 +1,7 @@ | |||
{ | |||
"counts": { | |||
"failed": 47, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
If you bump the version in the package.json, and then npm run-script build
(maybe npm build
will also work?) - when you push everything will be published etc automatically. LMK if you want to do that or I can also from my side.
We normally use the center of the quads as the location of the tracking points, which is optimal for most cases and will account for a skew in the image. However, In some cases, a slight skew might not be real and instead be caused by image compression errors and/or low resolution. For those cases, we'd be better off centering the point exactly in the middle of the black area. This change computes the location data for the naively centered points as it is little additional work and allows for multiple attempts at decoding harder images.
An example of this bug:
This change fixes 5 of the 47 currently failing tests, with no regressions.