C++ changes from r2247

git-svn-id: https://zxing.googlecode.com/svn/trunk@2328 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
smparkes@smparkes.net 2012-06-26 17:21:13 +00:00
parent 7bc138ed7a
commit 53e6b62f9f
5 changed files with 27 additions and 23 deletions

View file

@ -41,3 +41,8 @@ To profile the code (very useful to optimize the code):
- Install valgrind
- "valgrind --tool=callgrind build/zxing - path/to/test/data/*.jpg > report.html"
- kcachegrind is a very nice tool to analize the output
To run the blackbox tests and check for changes:
- build the test util, e.g., scons zxing
- run the tests: bash blackboxtest.sh 2>&1 | tee bb.results
- diff them with the known results: diff bb.results blackboxtest.results

View file

@ -1,3 +1,4 @@
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
/*
* DecodedBitStreamParser.cpp
* zxing
@ -141,9 +142,7 @@ int DecodedBitStreamParser::decodeAsciiSegment(Ref<BitSource> bits, ostringstrea
// Ignore this symbol for now
} else if (oneByte >= 242) { // Not to be used in ASCII encodation
// ... but work around encoders that end with 254, latch back to ASCII
if (oneByte == 254 && bits->available() == 0) {
// Ignore
} else {
if (oneByte != 254 || bits->available() != 0) {
throw FormatException("Not to be used in ASCII encodation");
}
}

View file

@ -174,16 +174,15 @@ namespace zxing {
bestMatch = startCode;
}
}
if (bestMatch >= 0) {
// Look for whitespace before start pattern, >= 50% of width of start pattern
if (row->isRange(std::max(0, patternStart - (i - patternStart) / 2), patternStart,
// Look for whitespace before start pattern, >= 50% of width of start pattern
if (bestMatch >= 0 &&
row->isRange(std::max(0, patternStart - (i - patternStart) / 2), patternStart,
false)) {
int* resultValue = new int[3];
resultValue[0] = patternStart;
resultValue[1] = i;
resultValue[2] = bestMatch;
return resultValue;
}
int* resultValue = new int[3];
resultValue[0] = patternStart;
resultValue[1] = i;
resultValue[2] = bestMatch;
return resultValue;
}
patternStart += counters[0] + counters[1];
for (int y = 2; y < patternLength; y++) {

View file

@ -204,15 +204,14 @@ namespace oned {
counters[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
if (toNarrowWidePattern(counters, countersLen) == ASTERISK_ENCODING) {
// Look for whitespace before start pattern, >= 50% of width of
// start pattern.
if (row->isRange(std::max(0, patternStart - ((i - patternStart) >> 1)), patternStart, false)) {
int* resultValue = new int[2];
resultValue[0] = patternStart;
resultValue[1] = i;
return resultValue;
}
// Look for whitespace before start pattern, >= 50% of width of
// start pattern.
if (toNarrowWidePattern(counters, countersLen) == ASTERISK_ENCODING &&
row->isRange(std::max(0, patternStart - ((i - patternStart) >> 1)), patternStart, false)) {
int* resultValue = new int[2];
resultValue[0] = patternStart;
resultValue[1] = i;
return resultValue;
}
patternStart += counters[0] + counters[1];
for (int y = 2; y < patternLength; y++) {

View file

@ -121,12 +121,14 @@ Ref<PerspectiveTransform> Detector::createTransform(Ref<ResultPoint> topLeft, Re
if (alignmentPattern != 0) {
bottomRightX = alignmentPattern->getX();
bottomRightY = alignmentPattern->getY();
sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0f;
sourceBottomRightX = dimMinusThree - 3.0f;
sourceBottomRightY = sourceBottomRightX;
} else {
// Don't have an alignment pattern, just make up the bottom-right point
bottomRightX = (topRight->getX() - topLeft->getX()) + bottomLeft->getX();
bottomRightY = (topRight->getY() - topLeft->getY()) + bottomLeft->getY();
sourceBottomRightX = sourceBottomRightY = dimMinusThree;
sourceBottomRightX = dimMinusThree;
sourceBottomRightY = dimMinusThree;
}
Ref<PerspectiveTransform> transform(PerspectiveTransform::quadrilateralToQuadrilateral(3.5f, 3.5f, dimMinusThree, 3.5f, sourceBottomRightX,