mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
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:
parent
af2ce46c37
commit
0944a2bb18
|
@ -132,7 +132,7 @@ public final class Detector {
|
|||
int[] loc = null;
|
||||
// Top Left
|
||||
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) {
|
||||
result[0] = new ResultPoint(loc[0], i);
|
||||
result[4] = new ResultPoint(loc[1], i);
|
||||
|
@ -144,7 +144,7 @@ public final class Detector {
|
|||
if (found) { // Found the Top Left vertex
|
||||
found = false;
|
||||
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) {
|
||||
result[1] = new ResultPoint(loc[0], i);
|
||||
result[5] = new ResultPoint(loc[1], i);
|
||||
|
@ -157,7 +157,7 @@ public final class Detector {
|
|||
if (found) { // Found the Bottom Left vertex
|
||||
found = false;
|
||||
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) {
|
||||
result[2] = new ResultPoint(loc[1], i);
|
||||
result[6] = new ResultPoint(loc[0], i);
|
||||
|
@ -170,7 +170,7 @@ public final class Detector {
|
|||
if (found) { // Found the Top right vertex
|
||||
found = false;
|
||||
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) {
|
||||
result[3] = new ResultPoint(loc[1], i);
|
||||
result[7] = new ResultPoint(loc[0], i);
|
||||
|
@ -212,7 +212,7 @@ public final class Detector {
|
|||
int[] loc = null;
|
||||
// Top Left
|
||||
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) {
|
||||
result[0] = new ResultPoint(loc[1], i);
|
||||
result[4] = new ResultPoint(loc[0], i);
|
||||
|
@ -224,7 +224,7 @@ public final class Detector {
|
|||
if (found) { // Found the Top Left vertex
|
||||
found = false;
|
||||
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) {
|
||||
result[1] = new ResultPoint(loc[1], i);
|
||||
result[5] = new ResultPoint(loc[0], i);
|
||||
|
@ -237,7 +237,7 @@ public final class Detector {
|
|||
if (found) { // Found the Bottom Left vertex
|
||||
found = false;
|
||||
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) {
|
||||
result[2] = new ResultPoint(loc[0], i);
|
||||
result[6] = new ResultPoint(loc[1], i);
|
||||
|
@ -250,7 +250,7 @@ public final class Detector {
|
|||
if (found) { // Found the Top Right vertex
|
||||
found = false;
|
||||
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) {
|
||||
result[3] = new ResultPoint(loc[0], i);
|
||||
result[7] = new ResultPoint(loc[1], i);
|
||||
|
@ -357,12 +357,13 @@ public final class Detector {
|
|||
* being searched for as a pattern
|
||||
* @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;
|
||||
// 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.
|
||||
int[] counters = new int[patternLength];
|
||||
boolean isWhite = false;
|
||||
boolean isWhite = whiteFirst;
|
||||
|
||||
int counterPosition = 0;
|
||||
int patternStart = column;
|
||||
|
|
|
@ -34,9 +34,7 @@ public final class PDF417BlackBox1TestCase extends AbstractBlackBoxTestCase {
|
|||
public PDF417BlackBox1TestCase() {
|
||||
super("test/data/blackbox/pdf417", new MultiFormatReader(), BarcodeFormat.PDF417);
|
||||
addTest(3, 3, 0.0f);
|
||||
//addTest(1, 1, 90.0f);
|
||||
//addTest(1, 1, 180.0f);
|
||||
//addTest(1, 1, 270.0f);
|
||||
addTest(3, 3, 180.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,9 +34,7 @@ public final class PDF417BlackBox2TestCase extends AbstractBlackBoxTestCase {
|
|||
public PDF417BlackBox2TestCase() {
|
||||
super("test/data/blackbox/pdf417-2", new MultiFormatReader(), BarcodeFormat.PDF417);
|
||||
addTest(8, 8, 0.0f);
|
||||
//addTest(1, 1, 90.0f);
|
||||
//addTest(1, 1, 180.0f);
|
||||
//addTest(1, 1, 270.0f);
|
||||
addTest(9, 9, 180.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue