mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 11:47:26 -08:00
debug printout cleanup
git-svn-id: https://zxing.googlecode.com/svn/trunk@472 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
8cffdc4b70
commit
753ca4afbf
|
@ -87,14 +87,14 @@ estimateBlackPoint(BlackPointEstimationMethod method, int arg) {
|
|||
valarray<int> histogram(LUMINANCE_BUCKETS);
|
||||
if (method == BlackPointEstimationMethod_2D) {
|
||||
size_t minDimension = width < height ? width : height;
|
||||
size_t yOffset = height == minDimension ? 0 : (height - width) >> 1;
|
||||
size_t xOffset = width == minDimension ? 0 : (width - height) >> 1;
|
||||
size_t startX = (width - minDimension) >> 1;
|
||||
size_t startY = (height - minDimension) >> 1;
|
||||
for (size_t n = 0; n < minDimension; n++) {
|
||||
unsigned char pixel = getPixel(xOffset + n, yOffset + n);
|
||||
unsigned char pixel = getPixel(startX + n, startY + n);
|
||||
histogram[pixel >> LUMINANCE_SHIFT]++;
|
||||
}
|
||||
} else if (method == BlackPointEstimationMethod_RowSampling) {
|
||||
if (arg < 0 || arg > (int)height) {
|
||||
if (arg < 0 || arg >= (int)height) {
|
||||
throw new IllegalArgumentException
|
||||
("black point estimation argument out of range");
|
||||
}
|
||||
|
@ -114,6 +114,6 @@ estimateBlackPoint(BlackPointEstimationMethod method, int arg) {
|
|||
}
|
||||
|
||||
BlackPointEstimationMethod MonochromeBitmapSource::getLastEstimationMethod() {
|
||||
return BlackPointEstimationMethod_None;
|
||||
return lastEstimationMethod_;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace common {
|
|||
size_t BlackPointEstimator::estimate(valarray<int> &histogram) {
|
||||
|
||||
size_t numBuckets = histogram.size();
|
||||
int maxBucketCount = 0;
|
||||
|
||||
// Find tallest peak in histogram
|
||||
size_t firstPeak = 0;
|
||||
|
@ -37,6 +38,9 @@ namespace common {
|
|||
firstPeak = i;
|
||||
firstPeakSize = histogram[i];
|
||||
}
|
||||
if (histogram[i] > maxBucketCount) {
|
||||
maxBucketCount = histogram[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Find second-tallest peak -- well, another peak that is tall and not
|
||||
|
@ -65,7 +69,7 @@ namespace common {
|
|||
// Decoding the image/line is either pointless, or may in some cases lead to a false positive
|
||||
// for 1D formats, which are relatively lenient.
|
||||
// We arbitrarily say "close" is "<= 1/16 of the total histogram buckets apart"
|
||||
if (secondPeak - firstPeak <= histogram.size() >> 4) {
|
||||
if (secondPeak - firstPeak <= numBuckets >> 4) {
|
||||
throw new IllegalArgumentException
|
||||
("Too little dynamic range in luminance");
|
||||
}
|
||||
|
@ -77,7 +81,7 @@ namespace common {
|
|||
int fromFirst = i - firstPeak;
|
||||
// Favor a "valley" that is not too close to either peak -- especially not the black peak --
|
||||
// and that has a low value of course
|
||||
int score = fromFirst * fromFirst * (secondPeak - i) * (256 - histogram[i]);
|
||||
int score = fromFirst * fromFirst * (secondPeak - i) * (maxBucketCount - histogram[i]);
|
||||
if (score > bestValleyScore) {
|
||||
bestValley = i;
|
||||
bestValleyScore = score;
|
||||
|
|
|
@ -40,13 +40,20 @@ namespace reedsolomon {
|
|||
cout << "decode(): received = " << &received << ", array = " <<
|
||||
received.array_ << " (" << received.array_->count_ << ")\n";
|
||||
#endif
|
||||
|
||||
Ref<GF256Poly> poly(new GF256Poly(field, received));
|
||||
|
||||
#ifdef DEBUG
|
||||
cout << "decoding with poly " << *poly << "\n";
|
||||
#endif
|
||||
|
||||
ArrayRef<int> syndromeCoefficients(new Array<int>(twoS));
|
||||
|
||||
#ifdef DEBUG
|
||||
cout << "syndromeCoefficients array = " <<
|
||||
syndromeCoefficients.array_ << "\n";
|
||||
#endif
|
||||
|
||||
bool noError = true;
|
||||
for (int i = 0; i < twoS; i++) {
|
||||
int eval = poly->evaluateAt(field.exp(i));
|
||||
|
@ -56,10 +63,12 @@ namespace reedsolomon {
|
|||
}
|
||||
}
|
||||
if (noError) {
|
||||
|
||||
#ifdef DEBUG
|
||||
cout << "before returning: syndromeCoefficients rc = " <<
|
||||
syndromeCoefficients.array_->count_ << "\n";
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -149,10 +158,12 @@ namespace reedsolomon {
|
|||
Ref<GF256Poly> sigma(t->multiply(inverse));
|
||||
Ref<GF256Poly> omega(r->multiply(inverse));
|
||||
|
||||
#ifdef DEBUG
|
||||
cout << "t = " << *t << "\n";
|
||||
cout << "r = " << *r << "\n";
|
||||
cout << "sigma = " << *sigma << "\n";
|
||||
cout << "omega = " << *omega << "\n";
|
||||
#endif
|
||||
|
||||
vector<Ref<GF256Poly> > result(2);
|
||||
result[0] = sigma;
|
||||
|
|
|
@ -31,12 +31,24 @@ namespace qrcode {
|
|||
using namespace std;
|
||||
|
||||
Ref<Result> QRCodeReader::decode(Ref<MonochromeBitmapSource> image) {
|
||||
#ifdef DEBUG
|
||||
cout << "decoding image " << image.object_ << ":\n" << flush;
|
||||
#endif
|
||||
|
||||
Detector detector(image);
|
||||
|
||||
#ifdef DEBUG
|
||||
cout << "(1) created detector " << &detector << "\n" << flush;
|
||||
#endif
|
||||
|
||||
Ref<DetectorResult> detectorResult(detector.detect());
|
||||
#ifdef DEBUG
|
||||
cout << "(2) detected, have detectorResult " << detectorResult.object_ << "\n" << flush;
|
||||
#endif
|
||||
|
||||
ArrayRef<Ref<ResultPoint> > points(detectorResult->getPoints());
|
||||
|
||||
#ifdef DEBUG
|
||||
cout << "(3) extracted points " << &points << "\n" << flush;
|
||||
cout << "found " << points->size() << " points:\n";
|
||||
for (size_t i = 0; i < points->size(); i++) {
|
||||
|
@ -44,13 +56,21 @@ namespace qrcode {
|
|||
}
|
||||
cout << "bits:\n";
|
||||
cout << *(detectorResult->getBits()) << "\n";
|
||||
#endif
|
||||
|
||||
Ref<DecoderResult> decoderResult(decoder_.decode(detectorResult->getBits()));
|
||||
#ifdef DEBUG
|
||||
cout << "(4) decoded, have decoderResult " << decoderResult.object_ << "\n" << flush;
|
||||
#endif
|
||||
|
||||
Ref<Result> result(new Result(decoderResult->getText(),
|
||||
decoderResult->getRawBytes(),
|
||||
points,
|
||||
BarcodeFormat_QR_CODE));
|
||||
#ifdef DEBUG
|
||||
cout << "(5) created result " << result.object_ << ", returning\n" << flush;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -166,8 +166,10 @@ namespace qrcode {
|
|||
functionPattern->setRegion(dimension - 11, 0, 3, 6);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
cout << "version " << versionNumber_ << " built function pattern:\n";
|
||||
cout << *functionPattern;
|
||||
#endif
|
||||
|
||||
return functionPattern;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue