Skip to content
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

Merged
merged 5 commits into from
Apr 29, 2020
Merged

Add fallback locator point recenter #166

merged 5 commits into from
Apr 29, 2020

Conversation

jefff
Copy link
Collaborator

@jefff jefff commented Apr 22, 2020

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:
buggycenter

This change fixes 5 of the 47 currently failing tests, with no regressions.

@jefff jefff requested a review from cozmo April 22, 2020 11:06
Copy link
Owner

@cozmo cozmo left a 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 {
Copy link
Owner

@cozmo cozmo Apr 22, 2020

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?

Copy link
Collaborator Author

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.

a52cda5

@@ -65,7 +65,7 @@ describe("locate", () => {

it("locates a damaged QR code and guesses the finder pattern location", async () => {
Copy link
Owner

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.

Copy link
Collaborator Author

@jefff jefff Apr 23, 2020

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,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

Copy link
Owner

@cozmo cozmo left a 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.

@jefff jefff merged commit 25b062a into master Apr 29, 2020
@jefff jefff deleted the try-harder-on-skew branch April 29, 2020 03:01
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.

2 participants