RSSExpandedReader.java (zxing-zxing-3.4.0) | : | RSSExpandedReader.java (zxing-zxing-3.4.1) | ||
---|---|---|---|---|
skipping to change at line 43 | skipping to change at line 43 | |||
import com.google.zxing.Result; | import com.google.zxing.Result; | |||
import com.google.zxing.ResultPoint; | import com.google.zxing.ResultPoint; | |||
import com.google.zxing.common.BitArray; | import com.google.zxing.common.BitArray; | |||
import com.google.zxing.common.detector.MathUtils; | import com.google.zxing.common.detector.MathUtils; | |||
import com.google.zxing.oned.rss.AbstractRSSReader; | import com.google.zxing.oned.rss.AbstractRSSReader; | |||
import com.google.zxing.oned.rss.DataCharacter; | import com.google.zxing.oned.rss.DataCharacter; | |||
import com.google.zxing.oned.rss.FinderPattern; | import com.google.zxing.oned.rss.FinderPattern; | |||
import com.google.zxing.oned.rss.RSSUtils; | import com.google.zxing.oned.rss.RSSUtils; | |||
import com.google.zxing.oned.rss.expanded.decoders.AbstractExpandedDecoder; | import com.google.zxing.oned.rss.expanded.decoders.AbstractExpandedDecoder; | |||
import java.util.Arrays; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | |||
import java.util.Collection; | import java.util.Collection; | |||
import java.util.Iterator; | import java.util.Iterator; | |||
import java.util.List; | import java.util.List; | |||
import java.util.Map; | import java.util.Map; | |||
import java.util.Collections; | import java.util.Collections; | |||
/** | /** | |||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) | |||
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.e s) | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.e s) | |||
skipping to change at line 168 | skipping to change at line 169 | |||
done = true; | done = true; | |||
} | } | |||
} | } | |||
// TODO: verify sequence of finder patterns as in checkPairSequence() | // TODO: verify sequence of finder patterns as in checkPairSequence() | |||
if (checkChecksum()) { | if (checkChecksum()) { | |||
return this.pairs; | return this.pairs; | |||
} | } | |||
boolean tryStackedDecode = !this.rows.isEmpty(); | boolean tryStackedDecode = !this.rows.isEmpty(); | |||
storeRow(rowNumber, false); // TODO: deal with reversed rows | storeRow(rowNumber); // TODO: deal with reversed rows | |||
if (tryStackedDecode) { | if (tryStackedDecode) { | |||
// When the image is 180-rotated, then rows are sorted in wrong direction. | // When the image is 180-rotated, then rows are sorted in wrong direction. | |||
// Try twice with both the directions. | // Try twice with both the directions. | |||
List<ExpandedPair> ps = checkRows(false); | List<ExpandedPair> ps = checkRows(false); | |||
if (ps != null) { | if (ps != null) { | |||
return ps; | return ps; | |||
} | } | |||
ps = checkRows(true); | ps = checkRows(true); | |||
if (ps != null) { | if (ps != null) { | |||
return ps; | return ps; | |||
skipping to change at line 265 | skipping to change at line 266 | |||
if (stop) { | if (stop) { | |||
return true; | return true; | |||
} | } | |||
} | } | |||
} | } | |||
return false; | return false; | |||
} | } | |||
private void storeRow(int rowNumber, boolean wasReversed) { | private void storeRow(int rowNumber) { | |||
// Discard if duplicate above or below; otherwise insert in order by row num ber. | // Discard if duplicate above or below; otherwise insert in order by row num ber. | |||
int insertPos = 0; | int insertPos = 0; | |||
boolean prevIsSame = false; | boolean prevIsSame = false; | |||
boolean nextIsSame = false; | boolean nextIsSame = false; | |||
while (insertPos < this.rows.size()) { | while (insertPos < this.rows.size()) { | |||
ExpandedRow erow = this.rows.get(insertPos); | ExpandedRow erow = this.rows.get(insertPos); | |||
if (erow.getRowNumber() > rowNumber) { | if (erow.getRowNumber() > rowNumber) { | |||
nextIsSame = erow.isEquivalent(this.pairs); | nextIsSame = erow.isEquivalent(this.pairs); | |||
break; | break; | |||
} | } | |||
skipping to change at line 292 | skipping to change at line 293 | |||
// When the row was partially decoded (e.g. 2 pairs found instead of 3), | // When the row was partially decoded (e.g. 2 pairs found instead of 3), | |||
// it will prevent us from detecting the barcode. | // it will prevent us from detecting the barcode. | |||
// Try to merge partial rows | // Try to merge partial rows | |||
// Check whether the row is part of an already detected row | // Check whether the row is part of an already detected row | |||
if (isPartialRow(this.pairs, this.rows)) { | if (isPartialRow(this.pairs, this.rows)) { | |||
return; | return; | |||
} | } | |||
this.rows.add(insertPos, new ExpandedRow(this.pairs, rowNumber, wasReversed) ); | this.rows.add(insertPos, new ExpandedRow(this.pairs, rowNumber, false)); | |||
removePartialRows(this.pairs, this.rows); | removePartialRows(this.pairs, this.rows); | |||
} | } | |||
// Remove all the rows that contains only specified pairs | // Remove all the rows that contains only specified pairs | |||
private static void removePartialRows(Collection<ExpandedPair> pairs, Collecti on<ExpandedRow> rows) { | private static void removePartialRows(Collection<ExpandedPair> pairs, Collecti on<ExpandedRow> rows) { | |||
for (Iterator<ExpandedRow> iterator = rows.iterator(); iterator.hasNext();) { | for (Iterator<ExpandedRow> iterator = rows.iterator(); iterator.hasNext();) { | |||
ExpandedRow r = iterator.next(); | ExpandedRow r = iterator.next(); | |||
if (r.getPairs().size() != pairs.size()) { | if (r.getPairs().size() != pairs.size()) { | |||
boolean allFound = true; | boolean allFound = true; | |||
skipping to change at line 574 | skipping to change at line 575 | |||
return null; | return null; | |||
} | } | |||
return new FinderPattern(value, new int[] {start, end}, start, end, rowNumbe r); | return new FinderPattern(value, new int[] {start, end}, start, end, rowNumbe r); | |||
} | } | |||
DataCharacter decodeDataCharacter(BitArray row, | DataCharacter decodeDataCharacter(BitArray row, | |||
FinderPattern pattern, | FinderPattern pattern, | |||
boolean isOddPattern, | boolean isOddPattern, | |||
boolean leftChar) throws NotFoundException { | boolean leftChar) throws NotFoundException { | |||
int[] counters = this.getDataCharacterCounters(); | int[] counters = this.getDataCharacterCounters(); | |||
for (int x = 0; x < counters.length; x++) { | Arrays.fill(counters, 0); | |||
counters[x] = 0; | ||||
} | ||||
if (leftChar) { | if (leftChar) { | |||
recordPatternInReverse(row, pattern.getStartEnd()[0], counters); | recordPatternInReverse(row, pattern.getStartEnd()[0], counters); | |||
} else { | } else { | |||
recordPattern(row, pattern.getStartEnd()[1], counters); | recordPattern(row, pattern.getStartEnd()[1], counters); | |||
// reverse it | // reverse it | |||
for (int i = 0, j = counters.length - 1; i < j; i++, j--) { | for (int i = 0, j = counters.length - 1; i < j; i++, j--) { | |||
int temp = counters[i]; | int temp = counters[i]; | |||
counters[i] = counters[j]; | counters[i] = counters[j]; | |||
counters[j] = temp; | counters[j] = temp; | |||
End of changes. 5 change blocks. | ||||
6 lines changed or deleted | 5 lines changed or added |