mirror of
https://github.com/zxing/zxing.git
synced 2024-11-12 22:14:06 -08:00
Fixed a bug which prevented this binarizer from caching rows.
git-svn-id: https://zxing.googlecode.com/svn/trunk@1512 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
2eb3d191b5
commit
a2226af690
|
@ -40,8 +40,7 @@ GlobalHistogramBinarizer::~GlobalHistogramBinarizer() {
|
||||||
|
|
||||||
|
|
||||||
Ref<BitArray> GlobalHistogramBinarizer::getBlackRow(int y, Ref<BitArray> row) {
|
Ref<BitArray> GlobalHistogramBinarizer::getBlackRow(int y, Ref<BitArray> row) {
|
||||||
|
if (y == cached_row_num_) {
|
||||||
if (row == cached_row_num_) {
|
|
||||||
return cached_row_;
|
return cached_row_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,17 +82,18 @@ Ref<BitArray> GlobalHistogramBinarizer::getBlackRow(int y, Ref<BitArray> row) {
|
||||||
|
|
||||||
cached_row_ = array_ref;
|
cached_row_ = array_ref;
|
||||||
cached_row_num_ = y;
|
cached_row_num_ = y;
|
||||||
|
|
||||||
delete [] row_pixels;
|
delete [] row_pixels;
|
||||||
return array_ref;
|
return array_ref;
|
||||||
} catch (IllegalArgumentException const& iae) {
|
} catch (IllegalArgumentException const& iae) {
|
||||||
|
// Cache the fact that this row failed.
|
||||||
|
cached_row_ = NULL;
|
||||||
|
cached_row_num_ = y;
|
||||||
delete [] row_pixels;
|
delete [] row_pixels;
|
||||||
throw iae;
|
throw iae;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<BitMatrix> GlobalHistogramBinarizer::getBlackMatrix() {
|
Ref<BitMatrix> GlobalHistogramBinarizer::getBlackMatrix() {
|
||||||
|
|
||||||
if (cached_matrix_ != NULL) {
|
if (cached_matrix_ != NULL) {
|
||||||
return cached_matrix_;
|
return cached_matrix_;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,6 @@ Ref<BitMatrix> GlobalHistogramBinarizer::getBlackMatrix() {
|
||||||
int height = source.getHeight();
|
int height = source.getHeight();
|
||||||
vector<int> histogram(LUMINANCE_BUCKETS, 0);
|
vector<int> histogram(LUMINANCE_BUCKETS, 0);
|
||||||
|
|
||||||
|
|
||||||
// Quickly calculates the histogram by sampling four rows from the image.
|
// Quickly calculates the histogram by sampling four rows from the image.
|
||||||
// This proved to be more robust on the blackbox tests than sampling a
|
// This proved to be more robust on the blackbox tests than sampling a
|
||||||
// diagonal as we used to do.
|
// diagonal as we used to do.
|
||||||
|
@ -142,7 +141,6 @@ int GlobalHistogramBinarizer::estimate(vector<int> &histogram) {
|
||||||
int numBuckets = histogram.size();
|
int numBuckets = histogram.size();
|
||||||
int maxBucketCount = 0;
|
int maxBucketCount = 0;
|
||||||
|
|
||||||
|
|
||||||
// Find tallest peak in histogram
|
// Find tallest peak in histogram
|
||||||
int firstPeak = 0;
|
int firstPeak = 0;
|
||||||
int firstPeakSize = 0;
|
int firstPeakSize = 0;
|
||||||
|
|
Loading…
Reference in a new issue