mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Modified my skew correction code to also work upside down, meaning we now decode three more inverted PDF 417 images.
git-svn-id: https://zxing.googlecode.com/svn/trunk@1016 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
b238cb7828
commit
402880798c
|
@ -84,6 +84,11 @@ public final class Detector {
|
|||
if (vertices == null) {
|
||||
// Maybe the image is rotated 180 degrees?
|
||||
vertices = findVertices180(matrix);
|
||||
if (vertices != null) {
|
||||
correctCodeWordVertices(vertices, true);
|
||||
}
|
||||
} else {
|
||||
correctCodeWordVertices(vertices, false);
|
||||
}
|
||||
|
||||
if (vertices != null) {
|
||||
|
@ -92,7 +97,6 @@ public final class Detector {
|
|||
throw ReaderException.getInstance();
|
||||
}
|
||||
|
||||
correctCodeWordVertices(vertices);
|
||||
int dimension = computeDimension(vertices[4], vertices[6],
|
||||
vertices[5], vertices[7], moduleWidth);
|
||||
|
||||
|
@ -271,12 +275,13 @@ public final class Detector {
|
|||
* This method moves those points back onto the edges of the theoretically perfect bounding
|
||||
* quadrilateral if needed.
|
||||
*
|
||||
* FIXME: Make this work for 180 degree rotation.
|
||||
*
|
||||
* @param vertices The eight vertices located by findVertices().
|
||||
*/
|
||||
private static void correctCodeWordVertices(ResultPoint[] vertices) {
|
||||
private static void correctCodeWordVertices(ResultPoint[] vertices, boolean upsideDown) {
|
||||
float skew = vertices[4].getY() - vertices[6].getY();
|
||||
if (upsideDown) {
|
||||
skew = -skew;
|
||||
}
|
||||
if (skew > SKEW_THRESHOLD) {
|
||||
// Fix v4
|
||||
float length = vertices[4].getX() - vertices[0].getX();
|
||||
|
@ -294,6 +299,9 @@ public final class Detector {
|
|||
}
|
||||
|
||||
skew = vertices[7].getY() - vertices[5].getY();
|
||||
if (upsideDown) {
|
||||
skew = -skew;
|
||||
}
|
||||
if (skew > SKEW_THRESHOLD) {
|
||||
// Fix v5
|
||||
float length = vertices[5].getX() - vertices[1].getX();
|
||||
|
|
|
@ -34,7 +34,7 @@ public final class PDF417BlackBox2TestCase extends AbstractBlackBoxTestCase {
|
|||
public PDF417BlackBox2TestCase() {
|
||||
super("test/data/blackbox/pdf417-2", new MultiFormatReader(), BarcodeFormat.PDF417);
|
||||
addTest(11, 11, 0.0f);
|
||||
addTest(9, 9, 180.0f);
|
||||
addTest(12, 12, 180.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue