Got 180 degree rotation working for PDF 417, and turned on the appropriate unit tests as a result.

git-svn-id: https://zxing.googlecode.com/svn/trunk@1014 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
dswitkin 2009-07-01 19:42:52 +00:00
parent af2ce46c37
commit 0944a2bb18
3 changed files with 13 additions and 16 deletions

View file

@ -132,7 +132,7 @@ public final class Detector {
int[] loc = null; int[] loc = null;
// Top Left // Top Left
for (int i = 0; i < height; i++) { for (int i = 0; i < height; i++) {
loc = findGuardPattern(matrix, 0, i, halfWidth, START_PATTERN); loc = findGuardPattern(matrix, 0, i, halfWidth, false, START_PATTERN);
if (loc != null) { if (loc != null) {
result[0] = new ResultPoint(loc[0], i); result[0] = new ResultPoint(loc[0], i);
result[4] = new ResultPoint(loc[1], i); result[4] = new ResultPoint(loc[1], i);
@ -144,7 +144,7 @@ public final class Detector {
if (found) { // Found the Top Left vertex if (found) { // Found the Top Left vertex
found = false; found = false;
for (int i = height - 1; i > 0; i--) { for (int i = height - 1; i > 0; i--) {
loc = findGuardPattern(matrix, 0, i, halfWidth, START_PATTERN); loc = findGuardPattern(matrix, 0, i, halfWidth, false, START_PATTERN);
if (loc != null) { if (loc != null) {
result[1] = new ResultPoint(loc[0], i); result[1] = new ResultPoint(loc[0], i);
result[5] = new ResultPoint(loc[1], i); result[5] = new ResultPoint(loc[1], i);
@ -157,7 +157,7 @@ public final class Detector {
if (found) { // Found the Bottom Left vertex if (found) { // Found the Bottom Left vertex
found = false; found = false;
for (int i = 0; i < height; i++) { for (int i = 0; i < height; i++) {
loc = findGuardPattern(matrix, halfWidth, i, halfWidth, STOP_PATTERN); loc = findGuardPattern(matrix, halfWidth, i, halfWidth, false, STOP_PATTERN);
if (loc != null) { if (loc != null) {
result[2] = new ResultPoint(loc[1], i); result[2] = new ResultPoint(loc[1], i);
result[6] = new ResultPoint(loc[0], i); result[6] = new ResultPoint(loc[0], i);
@ -170,7 +170,7 @@ public final class Detector {
if (found) { // Found the Top right vertex if (found) { // Found the Top right vertex
found = false; found = false;
for (int i = height - 1; i > 0; i--) { for (int i = height - 1; i > 0; i--) {
loc = findGuardPattern(matrix, halfWidth, i, halfWidth, STOP_PATTERN); loc = findGuardPattern(matrix, halfWidth, i, halfWidth, false, STOP_PATTERN);
if (loc != null) { if (loc != null) {
result[3] = new ResultPoint(loc[1], i); result[3] = new ResultPoint(loc[1], i);
result[7] = new ResultPoint(loc[0], i); result[7] = new ResultPoint(loc[0], i);
@ -212,7 +212,7 @@ public final class Detector {
int[] loc = null; int[] loc = null;
// Top Left // Top Left
for (int i = height - 1; i > 0; i--) { for (int i = height - 1; i > 0; i--) {
loc = findGuardPattern(matrix, halfWidth, i, halfWidth, START_PATTERN_REVERSE); loc = findGuardPattern(matrix, halfWidth, i, halfWidth, true, START_PATTERN_REVERSE);
if (loc != null) { if (loc != null) {
result[0] = new ResultPoint(loc[1], i); result[0] = new ResultPoint(loc[1], i);
result[4] = new ResultPoint(loc[0], i); result[4] = new ResultPoint(loc[0], i);
@ -224,7 +224,7 @@ public final class Detector {
if (found) { // Found the Top Left vertex if (found) { // Found the Top Left vertex
found = false; found = false;
for (int i = 0; i < height; i++) { for (int i = 0; i < height; i++) {
loc = findGuardPattern(matrix, halfWidth, i, halfWidth, START_PATTERN_REVERSE); loc = findGuardPattern(matrix, halfWidth, i, halfWidth, true, START_PATTERN_REVERSE);
if (loc != null) { if (loc != null) {
result[1] = new ResultPoint(loc[1], i); result[1] = new ResultPoint(loc[1], i);
result[5] = new ResultPoint(loc[0], i); result[5] = new ResultPoint(loc[0], i);
@ -237,7 +237,7 @@ public final class Detector {
if (found) { // Found the Bottom Left vertex if (found) { // Found the Bottom Left vertex
found = false; found = false;
for (int i = height - 1; i > 0; i--) { for (int i = height - 1; i > 0; i--) {
loc = findGuardPattern(matrix, 0, i, halfWidth, STOP_PATTERN_REVERSE); loc = findGuardPattern(matrix, 0, i, halfWidth, false, STOP_PATTERN_REVERSE);
if (loc != null) { if (loc != null) {
result[2] = new ResultPoint(loc[0], i); result[2] = new ResultPoint(loc[0], i);
result[6] = new ResultPoint(loc[1], i); result[6] = new ResultPoint(loc[1], i);
@ -250,7 +250,7 @@ public final class Detector {
if (found) { // Found the Top Right vertex if (found) { // Found the Top Right vertex
found = false; found = false;
for (int i = 0; i < height; i++) { for (int i = 0; i < height; i++) {
loc = findGuardPattern(matrix, 0, i, halfWidth, STOP_PATTERN_REVERSE); loc = findGuardPattern(matrix, 0, i, halfWidth, false, STOP_PATTERN_REVERSE);
if (loc != null) { if (loc != null) {
result[3] = new ResultPoint(loc[0], i); result[3] = new ResultPoint(loc[0], i);
result[7] = new ResultPoint(loc[1], i); result[7] = new ResultPoint(loc[1], i);
@ -357,12 +357,13 @@ public final class Detector {
* being searched for as a pattern * being searched for as a pattern
* @return start/end horizontal offset of guard pattern, as an array of two ints. * @return start/end horizontal offset of guard pattern, as an array of two ints.
*/ */
static int[] findGuardPattern(BitMatrix matrix, int column, int row, int width, int[] pattern) { static int[] findGuardPattern(BitMatrix matrix, int column, int row, int width,
boolean whiteFirst, int[] pattern) {
int patternLength = pattern.length; int patternLength = pattern.length;
// TODO: Find a way to cache this array, as this method is called hundreds of times // TODO: Find a way to cache this array, as this method is called hundreds of times
// per image, and we want to allocate as seldom as possible. // per image, and we want to allocate as seldom as possible.
int[] counters = new int[patternLength]; int[] counters = new int[patternLength];
boolean isWhite = false; boolean isWhite = whiteFirst;
int counterPosition = 0; int counterPosition = 0;
int patternStart = column; int patternStart = column;

View file

@ -34,9 +34,7 @@ public final class PDF417BlackBox1TestCase extends AbstractBlackBoxTestCase {
public PDF417BlackBox1TestCase() { public PDF417BlackBox1TestCase() {
super("test/data/blackbox/pdf417", new MultiFormatReader(), BarcodeFormat.PDF417); super("test/data/blackbox/pdf417", new MultiFormatReader(), BarcodeFormat.PDF417);
addTest(3, 3, 0.0f); addTest(3, 3, 0.0f);
//addTest(1, 1, 90.0f); addTest(3, 3, 180.0f);
//addTest(1, 1, 180.0f);
//addTest(1, 1, 270.0f);
} }
@Override @Override

View file

@ -34,9 +34,7 @@ public final class PDF417BlackBox2TestCase extends AbstractBlackBoxTestCase {
public PDF417BlackBox2TestCase() { public PDF417BlackBox2TestCase() {
super("test/data/blackbox/pdf417-2", new MultiFormatReader(), BarcodeFormat.PDF417); super("test/data/blackbox/pdf417-2", new MultiFormatReader(), BarcodeFormat.PDF417);
addTest(8, 8, 0.0f); addTest(8, 8, 0.0f);
//addTest(1, 1, 90.0f); addTest(9, 9, 180.0f);
//addTest(1, 1, 180.0f);
//addTest(1, 1, 270.0f);
} }
@Override @Override