mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Various user-contributed fixes (Issue 701, Issue 710, Issue 714, Issue 718)
git-svn-id: https://zxing.googlecode.com/svn/trunk@1717 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
71ddbf6f08
commit
7a6cc4c3d0
|
@ -42,8 +42,11 @@ public final class WhiteRectangleDetector {
|
||||||
private final int rightInit;
|
private final int rightInit;
|
||||||
private final int downInit;
|
private final int downInit;
|
||||||
private final int upInit;
|
private final int upInit;
|
||||||
|
|
||||||
public WhiteRectangleDetector(BitMatrix image) {
|
/**
|
||||||
|
* @throws NotFoundException if image is too small
|
||||||
|
*/
|
||||||
|
public WhiteRectangleDetector(BitMatrix image) throws NotFoundException {
|
||||||
this.image = image;
|
this.image = image;
|
||||||
height = image.getHeight();
|
height = image.getHeight();
|
||||||
width = image.getWidth();
|
width = image.getWidth();
|
||||||
|
@ -51,17 +54,26 @@ public final class WhiteRectangleDetector {
|
||||||
rightInit = (width + INIT_SIZE) >> 1;
|
rightInit = (width + INIT_SIZE) >> 1;
|
||||||
upInit = (height - INIT_SIZE) >> 1;
|
upInit = (height - INIT_SIZE) >> 1;
|
||||||
downInit = (height + INIT_SIZE) >> 1;
|
downInit = (height + INIT_SIZE) >> 1;
|
||||||
|
if (upInit < 0 || leftInit < 0 || downInit >= height || rightInit >= width) {
|
||||||
|
throw NotFoundException.getNotFoundInstance();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public WhiteRectangleDetector(BitMatrix image, int INIT_SIZE, int x, int y) {
|
/**
|
||||||
this.image = image;
|
* @throws NotFoundException if image is too small
|
||||||
height = image.getHeight();
|
*/
|
||||||
width = image.getWidth();
|
public WhiteRectangleDetector(BitMatrix image, int initSize, int x, int y) throws NotFoundException {
|
||||||
int halfsize = INIT_SIZE >> 1;
|
this.image = image;
|
||||||
leftInit = x - halfsize;
|
height = image.getHeight();
|
||||||
rightInit = x + halfsize;
|
width = image.getWidth();
|
||||||
upInit = y - halfsize;
|
int halfsize = initSize >> 1;
|
||||||
downInit = y + halfsize;
|
leftInit = x - halfsize;
|
||||||
|
rightInit = x + halfsize;
|
||||||
|
upInit = y - halfsize;
|
||||||
|
downInit = y + halfsize;
|
||||||
|
if (upInit < 0 || leftInit < 0 || downInit >= height || rightInit >= width) {
|
||||||
|
throw NotFoundException.getNotFoundInstance();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,7 +83,7 @@ public final class WhiteRectangleDetector {
|
||||||
* region until it finds a white rectangular region.
|
* region until it finds a white rectangular region.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @return {@link ResultPoint}[] describing the corners of the rectangular
|
* @return {@link ResultPoint[]} describing the corners of the rectangular
|
||||||
* region. The first and last points are opposed on the diagonal, as
|
* region. The first and last points are opposed on the diagonal, as
|
||||||
* are the second and third. The first point will be the topmost
|
* are the second and third. The first point will be the topmost
|
||||||
* point and the last, the bottommost. The second point will be
|
* point and the last, the bottommost. The second point will be
|
||||||
|
|
|
@ -401,7 +401,7 @@ final class DecodedBitStreamParser {
|
||||||
int edifactValue = bits.readBits(6);
|
int edifactValue = bits.readBits(6);
|
||||||
|
|
||||||
// Check for the unlatch character
|
// Check for the unlatch character
|
||||||
if (edifactValue == 0x2B67) { // 011111
|
if (edifactValue == 0x1F) { // 011111
|
||||||
unlatch = true;
|
unlatch = true;
|
||||||
// If we encounter the unlatch code then continue reading because the Codeword triple
|
// If we encounter the unlatch code then continue reading because the Codeword triple
|
||||||
// is padded with 0's
|
// is padded with 0's
|
||||||
|
@ -423,14 +423,15 @@ final class DecodedBitStreamParser {
|
||||||
private static void decodeBase256Segment(BitSource bits, StringBuffer result, Vector byteSegments)
|
private static void decodeBase256Segment(BitSource bits, StringBuffer result, Vector byteSegments)
|
||||||
throws FormatException {
|
throws FormatException {
|
||||||
// Figure out how long the Base 256 Segment is.
|
// Figure out how long the Base 256 Segment is.
|
||||||
int d1 = bits.readBits(8);
|
int codewordPosition = 2;
|
||||||
|
int d1 = unrandomize255State(bits.readBits(8), codewordPosition++);
|
||||||
int count;
|
int count;
|
||||||
if (d1 == 0) { // Read the remainder of the symbol
|
if (d1 == 0) { // Read the remainder of the symbol
|
||||||
count = bits.available() / 8;
|
count = bits.available() / 8;
|
||||||
} else if (d1 < 250) {
|
} else if (d1 < 250) {
|
||||||
count = d1;
|
count = d1;
|
||||||
} else {
|
} else {
|
||||||
count = 250 * (d1 - 249) + bits.readBits(8);
|
count = 250 * (d1 - 249) + unrandomize255State(bits.readBits(8), codewordPosition++);
|
||||||
}
|
}
|
||||||
byte[] bytes = new byte[count];
|
byte[] bytes = new byte[count];
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
|
@ -439,7 +440,7 @@ final class DecodedBitStreamParser {
|
||||||
if (bits.available() < 8) {
|
if (bits.available() < 8) {
|
||||||
throw FormatException.getFormatInstance();
|
throw FormatException.getFormatInstance();
|
||||||
}
|
}
|
||||||
bytes[i] = unrandomize255State(bits.readBits(8), i);
|
bytes[i] = unrandomize255State(bits.readBits(8), codewordPosition++);
|
||||||
}
|
}
|
||||||
byteSegments.addElement(bytes);
|
byteSegments.addElement(bytes);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -46,7 +46,7 @@ public final class Detector {
|
||||||
private final BitMatrix image;
|
private final BitMatrix image;
|
||||||
private final WhiteRectangleDetector rectangleDetector;
|
private final WhiteRectangleDetector rectangleDetector;
|
||||||
|
|
||||||
public Detector(BitMatrix image) {
|
public Detector(BitMatrix image) throws NotFoundException {
|
||||||
this.image = image;
|
this.image = image;
|
||||||
rectangleDetector = new WhiteRectangleDetector(image);
|
rectangleDetector = new WhiteRectangleDetector(image);
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,7 +252,7 @@ final class DecodedBitStreamParser {
|
||||||
} else {
|
} else {
|
||||||
if (subModeCh == 26) {
|
if (subModeCh == 26) {
|
||||||
ch = ' ';
|
ch = ' ';
|
||||||
} else if (subModeCh == AL) {
|
} else if (subModeCh == AS) {
|
||||||
subMode = ALPHA;
|
subMode = ALPHA;
|
||||||
} else if (subModeCh == ML) {
|
} else if (subModeCh == ML) {
|
||||||
subMode = MIXED;
|
subMode = MIXED;
|
||||||
|
|
BIN
core/test/data/blackbox/datamatrix-1/0123456789.gif
Normal file
BIN
core/test/data/blackbox/datamatrix-1/0123456789.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
1
core/test/data/blackbox/datamatrix-1/0123456789.txt
Normal file
1
core/test/data/blackbox/datamatrix-1/0123456789.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
0123456789
|
|
@ -27,10 +27,10 @@ public final class DataMatrixBlackBox1TestCase extends AbstractBlackBoxTestCase
|
||||||
|
|
||||||
public DataMatrixBlackBox1TestCase() {
|
public DataMatrixBlackBox1TestCase() {
|
||||||
super("test/data/blackbox/datamatrix-1", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX);
|
super("test/data/blackbox/datamatrix-1", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX);
|
||||||
addTest(16, 16, 0.0f);
|
addTest(17, 17, 0.0f);
|
||||||
addTest(16, 16, 90.0f);
|
addTest(17, 17, 90.0f);
|
||||||
addTest(16, 16, 180.0f);
|
addTest(17, 17, 180.0f);
|
||||||
addTest(16, 16, 270.0f);
|
addTest(17, 17, 270.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,7 +17,7 @@ if env['PIC']:
|
||||||
flags.append("-fPIC")
|
flags.append("-fPIC")
|
||||||
|
|
||||||
compile_options['CXXFLAGS'] = ' '.join(flags)
|
compile_options['CXXFLAGS'] = ' '.join(flags)
|
||||||
|
compile_options['LINKFLAGS'] = "-ldl"
|
||||||
|
|
||||||
def all_files(dir, ext='.cpp', level=5):
|
def all_files(dir, ext='.cpp', level=5):
|
||||||
files = []
|
files = []
|
||||||
|
|
Loading…
Reference in a new issue