-
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
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ describe("locate", () => { | |
|
||
it('locates a "perfect" image', async () => { | ||
const binarized = await loadBinarized("./src/locator/test-data/perfect.png"); | ||
expect(locate(binarized)).toEqual({ | ||
expect(locate(binarized)[0]).toEqual({ | ||
alignmentPattern: {x: 170.5, y: 170.5}, | ||
bottomLeft: {x: 3.5, y: 173.5}, | ||
dimension: 177, | ||
|
@@ -21,7 +21,7 @@ describe("locate", () => { | |
|
||
it("locates a QR in a real world image", async () => { | ||
const binarized = await loadBinarized("./src/locator/test-data/real-world.png"); | ||
expect(locate(binarized)).toEqual({ | ||
expect(locate(binarized)[0]).toEqual({ | ||
alignmentPattern: { x: 264.25, y: 177 }, | ||
bottomLeft: { x: 195.5, y: 191.5 }, | ||
dimension: 33, | ||
|
@@ -32,7 +32,7 @@ describe("locate", () => { | |
|
||
it("locates a small QR code in real world photo", async () => { | ||
const binarized = await loadBinarized("./src/locator/test-data/small-photo.png"); | ||
expect(locate(binarized)).toEqual({ | ||
expect(locate(binarized)[0]).toEqual({ | ||
alignmentPattern: { x: 103, y: 147.5 }, | ||
bottomLeft: { x: 73.5, y: 152 }, | ||
dimension: 29, | ||
|
@@ -43,7 +43,7 @@ describe("locate", () => { | |
|
||
it("locates a extremely distored QR code", async () => { | ||
const binarized = await loadBinarized("./src/locator/test-data/distorted-extreme.png"); | ||
expect(locate(binarized)).toEqual({ | ||
expect(locate(binarized)[0]).toEqual({ | ||
alignmentPattern: { x: 164.5, y: 39 }, | ||
bottomLeft: { x: 221.5, y: 18.5 }, | ||
dimension: 25, | ||
|
@@ -54,7 +54,7 @@ describe("locate", () => { | |
|
||
it("locates a damaged QR code and guesses the finder pattern location", async () => { | ||
const binarized = await loadBinarized("./src/locator/test-data/damaged.png"); | ||
expect(locate(binarized)).toEqual({ | ||
expect(locate(binarized)[0]).toEqual({ | ||
alignmentPattern: { x: 219.75, y: 221 }, | ||
bottomLeft: { x: 81.5, y: 215.5 }, | ||
dimension: 29, | ||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. |
||
const binarized = await loadBinarized("./src/locator/test-data/damaged.png"); | ||
expect(locate(binarized)).toEqual({ | ||
expect(locate(binarized)[0]).toEqual({ | ||
alignmentPattern: { x: 219.75, y: 221 }, | ||
bottomLeft: { x: 81.5, y: 215.5 }, | ||
dimension: 29, | ||
|
@@ -79,4 +79,15 @@ describe("locate", () => { | |
const binarized = await loadBinarized("./src/locator/test-data/malformed-infinity.png"); | ||
expect(locate(binarized)).toEqual(null); | ||
}); | ||
|
||
it("returns a centered alignment as a fallback", async () => { | ||
const binarized = await loadBinarized("./src/locator/test-data/odd-skew.png"); | ||
expect(locate(binarized)[1]).toEqual({ | ||
alignmentPattern: { x: 163.5, y: 170 }, | ||
bottomLeft: { x: 56.5, y: 185.5 }, | ||
dimension: 29, | ||
topLeft: { x: 57, y: 60 }, | ||
topRight: { x: 185.5, y: 57.5 }, | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,55 @@ | ||
null | ||
{ | ||
"binaryData": [ | ||
49, | ||
50, | ||
51, | ||
52, | ||
53, | ||
54, | ||
55, | ||
56, | ||
57, | ||
48 | ||
], | ||
"data": "1234567890", | ||
"chunks": [ | ||
{ | ||
"type": "numeric", | ||
"text": "1234567890" | ||
} | ||
], | ||
"location": { | ||
"topRightCorner": { | ||
"x": 263.49999999999994, | ||
"y": 291.375 | ||
}, | ||
"topLeftCorner": { | ||
"x": 290.79762807324306, | ||
"y": 234.26604686604492 | ||
}, | ||
"bottomRightCorner": { | ||
"x": 207.9274477212262, | ||
"y": 264.60245217347966 | ||
}, | ||
"bottomLeftCorner": { | ||
"x": 233.49999999999997, | ||
"y": 208.125 | ||
}, | ||
"topRightFinderPattern": { | ||
"x": 258.5, | ||
"y": 277.5 | ||
}, | ||
"topLeftFinderPattern": { | ||
"x": 276.5, | ||
"y": 239.5 | ||
}, | ||
"bottomLeftFinderPattern": { | ||
"x": 238.5, | ||
"y": 222 | ||
}, | ||
"bottomRightAlignmentPattern": { | ||
"x": 232.84618068755663, | ||
"y": 255.48041599830515 | ||
} | ||
} | ||
} |
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.
a52cda5