mirror of
https://github.com/zxing/zxing.git
synced 2025-01-13 04:07:27 -08:00
- Got the DataMatrix decoder compiling again with a quick bandaid.
- Fixed two bugs in the LocalBlockBinarizer sharpening routine. It can now decode 2132 images in our blackbox tests, compared to 2103 using the global histogram approach. - Added the PDF 417 blackbox test to AllPositiveBlackBoxTester, and allowed it to complete even if the tests fail. git-svn-id: https://zxing.googlecode.com/svn/trunk@1004 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
597fcfb23d
commit
10dfe7789b
|
@ -27,6 +27,8 @@ import com.google.zxing.LuminanceSource;
|
|||
* However it tends to produce artifacts on lower frequency images and is therefore not
|
||||
* a good general purpose binarizer for uses outside ZXing.
|
||||
*
|
||||
* NOTE: This class is still experimental and may not be ready for prime time yet.
|
||||
*
|
||||
* @author dswitkin@google.com (Daniel Switkin)
|
||||
*/
|
||||
public final class LocalBlockBinarizer extends Binarizer {
|
||||
|
@ -37,11 +39,13 @@ public final class LocalBlockBinarizer extends Binarizer {
|
|||
super(source);
|
||||
}
|
||||
|
||||
// TODO: Consider a different strategy for 1D Readers.
|
||||
public BitArray getBlackRow(int y, BitArray row) {
|
||||
binarizeEntireImage();
|
||||
return matrix.getRow(y, row);
|
||||
}
|
||||
|
||||
// TODO: If getBlackRow() calculates its own values, removing sharpening here.
|
||||
public BitMatrix getBlackMatrix() {
|
||||
binarizeEntireImage();
|
||||
return matrix;
|
||||
|
@ -152,7 +156,14 @@ public final class LocalBlockBinarizer extends Binarizer {
|
|||
int center = luminances[offset + 1] & 0xff;
|
||||
for (int x = 1; x < width - 1; x++) {
|
||||
int right = luminances[offset + x + 1] & 0xff;
|
||||
luminances[x] = (byte)(((center << 2) - left - right) >> 1);
|
||||
int pixel = ((center << 2) - left - right) >> 1;
|
||||
// Must clamp values to 0..255 so they will fit in a byte.
|
||||
if (pixel > 255) {
|
||||
pixel = 255;
|
||||
} else if (pixel < 0) {
|
||||
pixel = 0;
|
||||
}
|
||||
luminances[offset + x] = (byte)pixel;
|
||||
left = center;
|
||||
center = right;
|
||||
}
|
||||
|
|
|
@ -337,7 +337,10 @@ public final class Detector {
|
|||
// modules, but the
|
||||
// very corners. So there is no 0.5f here; 0.0f is right.
|
||||
GridSampler sampler = GridSampler.getInstance();
|
||||
return sampler.sampleGrid(image, dimension, 0.0f, // p1ToX
|
||||
|
||||
// FIXME: Temporary fix calling getBlackMatrix() inline here. It should be called once
|
||||
// and the result matrix passed down into sampleGrid() and throughout the reader.
|
||||
return sampler.sampleGrid(image.getBlackMatrix(), dimension, 0.0f, // p1ToX
|
||||
0.0f, // p1ToY
|
||||
dimension, // p2ToX
|
||||
0.0f, // p2ToY
|
||||
|
|
|
@ -39,6 +39,7 @@ import com.google.zxing.oned.UPCABlackBox4TestCase;
|
|||
import com.google.zxing.oned.UPCEBlackBox1TestCase;
|
||||
import com.google.zxing.oned.UPCEBlackBox2TestCase;
|
||||
import com.google.zxing.oned.UPCEBlackBox3ReflectiveTestCase;
|
||||
import com.google.zxing.pdf417.PDF417BlackBox1TestCase;
|
||||
import com.google.zxing.qrcode.QRCodeBlackBox1TestCase;
|
||||
import com.google.zxing.qrcode.QRCodeBlackBox2TestCase;
|
||||
import com.google.zxing.qrcode.QRCodeBlackBox3TestCase;
|
||||
|
@ -81,6 +82,7 @@ public final class AllPositiveBlackBoxTester {
|
|||
new UPCEBlackBox1TestCase(),
|
||||
new UPCEBlackBox2TestCase(),
|
||||
new UPCEBlackBox3ReflectiveTestCase(),
|
||||
new PDF417BlackBox1TestCase(),
|
||||
new QRCodeBlackBox1TestCase(),
|
||||
new QRCodeBlackBox2TestCase(),
|
||||
new QRCodeBlackBox3TestCase(),
|
||||
|
@ -156,7 +158,7 @@ public final class AllPositiveBlackBoxTester {
|
|||
AbstractBlackBoxTestCase.SummaryResults results = new AbstractBlackBoxTestCase.SummaryResults();
|
||||
|
||||
for (int x = 0; x < TESTS.length; x++) {
|
||||
results.add(TESTS[x].testBlackBoxCountingResults());
|
||||
results.add(TESTS[x].testBlackBoxCountingResults(false));
|
||||
}
|
||||
|
||||
// This threaded version can't be used yet because BlackPointEstimator (and possibly other code)
|
||||
|
|
|
@ -160,10 +160,10 @@ public abstract class AbstractBlackBoxTestCase extends TestCase {
|
|||
// This workaround is used because AbstractNegativeBlackBoxTestCase overrides this method but does
|
||||
// not return SummaryResults.
|
||||
public void testBlackBox() throws IOException {
|
||||
testBlackBoxCountingResults();
|
||||
testBlackBoxCountingResults(true);
|
||||
}
|
||||
|
||||
public SummaryResults testBlackBoxCountingResults() throws IOException {
|
||||
public SummaryResults testBlackBoxCountingResults(boolean assertOnFailure) throws IOException {
|
||||
assertFalse(testResults.isEmpty());
|
||||
|
||||
File[] imageFiles = getImageFiles();
|
||||
|
@ -218,13 +218,15 @@ public abstract class AbstractBlackBoxTestCase extends TestCase {
|
|||
}
|
||||
|
||||
// Then run through again and assert if any failed
|
||||
for (int x = 0; x < testCount; x++) {
|
||||
assertTrue("Rotation " + testResults.get(x).getRotation() +
|
||||
" degrees: Too many images failed",
|
||||
passedCounts[x] >= testResults.get(x).getMustPassCount());
|
||||
assertTrue("Try harder, Rotation " + testResults.get(x).getRotation() +
|
||||
" degrees: Too many images failed",
|
||||
tryHarderCounts[x] >= testResults.get(x).getTryHarderCount());
|
||||
if (assertOnFailure) {
|
||||
for (int x = 0; x < testCount; x++) {
|
||||
assertTrue("Rotation " + testResults.get(x).getRotation() +
|
||||
" degrees: Too many images failed",
|
||||
passedCounts[x] >= testResults.get(x).getMustPassCount());
|
||||
assertTrue("Try harder, Rotation " + testResults.get(x).getRotation() +
|
||||
" degrees: Too many images failed",
|
||||
tryHarderCounts[x] >= testResults.get(x).getTryHarderCount());
|
||||
}
|
||||
}
|
||||
return new SummaryResults(totalFound, totalMustPass, totalTests);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue