本文整理汇总了Java中com.google.zxing.oned.rss.FinderPattern类的典型用法代码示例。如果您正苦于以下问题:Java FinderPattern类的具体用法?Java FinderPattern怎么用?Java FinderPattern使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FinderPattern类属于com.google.zxing.oned.rss包,在下文中一共展示了FinderPattern类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRetrieveNextPairPatterns
import com.google.zxing.oned.rss.FinderPattern; //导入依赖的package包/类
@Test
public void testRetrieveNextPairPatterns() throws Exception {
BufferedImage image = readImage("3.png");
BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
int rowNumber = binaryMap.getHeight() / 2;
BitArray row = binaryMap.getBlackRow(rowNumber, null);
List<ExpandedPair> previousPairs = new ArrayList<>();
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
ExpandedPair pair1 = rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber);
previousPairs.add(pair1);
FinderPattern finderPattern = pair1.getFinderPattern();
assertNotNull(finderPattern);
assertEquals(0, finderPattern.getValue());
ExpandedPair pair2 = rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber);
previousPairs.add(pair2);
finderPattern = pair2.getFinderPattern();
assertNotNull(finderPattern);
assertEquals(0, finderPattern.getValue());
}
示例2: testDecodeDataCharacter
import com.google.zxing.oned.rss.FinderPattern; //导入依赖的package包/类
@Test
public void testDecodeDataCharacter() throws Exception {
BufferedImage image = readImage("3.png");
BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
BitArray row = binaryMap.getBlackRow(binaryMap.getHeight() / 2, null);
int[] startEnd = {145, 243};//image pixels where the A1 pattern starts (at 124) and ends (at 214)
int value = 0; // A
FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.getHeight() / 2);
//{1, 8, 4, 1, 1};
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
DataCharacter dataCharacter = rssExpandedReader.decodeDataCharacter(row, finderPatternA1, true, false);
assertEquals(19, dataCharacter.getValue());
assertEquals(1007, dataCharacter.getChecksumPortion());
}
示例3: testDecodeCheckCharacter
import com.google.zxing.oned.rss.FinderPattern; //导入依赖的package包/类
@Test
public void testDecodeCheckCharacter() throws Exception {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
String path = "test/data/blackbox/rssexpanded-1/3.jpg";
File file = new File(path);
if (!file.exists()) {
// Support running from project root too
file = new File("core", path);
}
BufferedImage image = ImageIO.read(file);
BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
BitArray row = binaryMap.getBlackRow(binaryMap.getHeight() / 2, null);
int[] startEnd = {145, 243};//image pixels where the A1 pattern starts (at 124) and ends (at 214)
int value = 0;// A
FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.getHeight() / 2);
//{1, 8, 4, 1, 1};
DataCharacter dataCharacter = rssExpandedReader.decodeDataCharacter(row, finderPatternA1, true, true);
assertEquals(98, dataCharacter.getValue());
}
示例4: testDecodeDataCharacter
import com.google.zxing.oned.rss.FinderPattern; //导入依赖的package包/类
@Test
public void testDecodeDataCharacter() throws Exception {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
String path = "test/data/blackbox/rssexpanded-1/3.jpg";
File file = new File(path);
if (!file.exists()) {
// Support running from project root too
file = new File("core", path);
}
BufferedImage image = ImageIO.read(file);
BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
BitArray row = binaryMap.getBlackRow(binaryMap.getHeight() / 2, null);
int[] startEnd = {145, 243};//image pixels where the A1 pattern starts (at 124) and ends (at 214)
int value = 0; // A
FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.getHeight() / 2);
//{1, 8, 4, 1, 1};
DataCharacter dataCharacter = rssExpandedReader.decodeDataCharacter(row, finderPatternA1, true, false);
assertEquals(19, dataCharacter.getValue());
assertEquals(1007, dataCharacter.getChecksumPortion());
}
示例5: testDecodeCheckCharacter
import com.google.zxing.oned.rss.FinderPattern; //导入依赖的package包/类
@Test
public void testDecodeCheckCharacter() throws Exception {
String path = "test/data/blackbox/rssexpanded-1/3.png";
File file = new File(path);
if (!file.exists()) {
// Support running from project root too
file = new File("core", path);
}
BufferedImage image = ImageIO.read(file);
BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
BitArray row = binaryMap.getBlackRow(binaryMap.getHeight() / 2, null);
int[] startEnd = {145, 243};//image pixels where the A1 pattern starts (at 124) and ends (at 214)
int value = 0;// A
FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.getHeight() / 2);
//{1, 8, 4, 1, 1};
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
DataCharacter dataCharacter = rssExpandedReader.decodeDataCharacter(row, finderPatternA1, true, true);
assertEquals(98, dataCharacter.getValue());
}
示例6: testDecodeDataCharacter
import com.google.zxing.oned.rss.FinderPattern; //导入依赖的package包/类
@Test
public void testDecodeDataCharacter() throws Exception {
String path = "test/data/blackbox/rssexpanded-1/3.png";
File file = new File(path);
if (!file.exists()) {
// Support running from project root too
file = new File("core", path);
}
BufferedImage image = ImageIO.read(file);
BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
BitArray row = binaryMap.getBlackRow(binaryMap.getHeight() / 2, null);
int[] startEnd = {145, 243};//image pixels where the A1 pattern starts (at 124) and ends (at 214)
int value = 0; // A
FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.getHeight() / 2);
//{1, 8, 4, 1, 1};
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
DataCharacter dataCharacter = rssExpandedReader.decodeDataCharacter(row, finderPatternA1, true, false);
assertEquals(19, dataCharacter.getValue());
assertEquals(1007, dataCharacter.getChecksumPortion());
}
示例7: retrieveNextPair
import com.google.zxing.oned.rss.FinderPattern; //导入依赖的package包/类
ExpandedPair retrieveNextPair(BitArray row, List<ExpandedPair> previousPairs, int rowNumber)
throws NotFoundException {
boolean isOddPattern = previousPairs.size() % 2 == 0;
if (startFromEven) {
isOddPattern = !isOddPattern;
}
FinderPattern pattern;
boolean keepFinding = true;
int forcedOffset = -1;
do{
this.findNextPair(row, previousPairs, forcedOffset);
pattern = parseFoundFinderPattern(row, rowNumber, isOddPattern);
if (pattern == null){
forcedOffset = getNextSecondBar(row, this.startEnd[0]);
} else {
keepFinding = false;
}
}while(keepFinding);
// When stacked symbol is split over multiple rows, there's no way to guess if this pair can be last or not.
// boolean mayBeLast = checkPairSequence(previousPairs, pattern);
DataCharacter leftChar = this.decodeDataCharacter(row, pattern, isOddPattern, true);
if (!previousPairs.isEmpty() && previousPairs.get(previousPairs.size()-1).mustBeLast()) {
throw NotFoundException.getNotFoundInstance();
}
DataCharacter rightChar;
try {
rightChar = this.decodeDataCharacter(row, pattern, isOddPattern, false);
} catch(NotFoundException ignored) {
rightChar = null;
}
boolean mayBeLast = true;
return new ExpandedPair(leftChar, rightChar, pattern, mayBeLast);
}
示例8: ExpandedPair
import com.google.zxing.oned.rss.FinderPattern; //导入依赖的package包/类
ExpandedPair(DataCharacter leftChar,
DataCharacter rightChar,
FinderPattern finderPattern,
boolean mayBeLast) {
this.leftChar = leftChar;
this.rightChar = rightChar;
this.finderPattern = finderPattern;
this.mayBeLast = mayBeLast;
}
示例9: retrieveNextPair
import com.google.zxing.oned.rss.FinderPattern; //导入依赖的package包/类
ExpandedPair retrieveNextPair(BitArray row, List<ExpandedPair> previousPairs, int rowNumber)
throws NotFoundException {
boolean isOddPattern = previousPairs.size() % 2 == 0;
if (startFromEven) {
isOddPattern = !isOddPattern;
}
FinderPattern pattern;
boolean keepFinding = true;
int forcedOffset = -1;
do {
this.findNextPair(row, previousPairs, forcedOffset);
pattern = parseFoundFinderPattern(row, rowNumber, isOddPattern);
if (pattern == null) {
forcedOffset = getNextSecondBar(row, this.startEnd[0]);
} else {
keepFinding = false;
}
} while (keepFinding);
// When stacked symbol is split over multiple rows, there's no way to guess if this pair can be last or not.
// boolean mayBeLast = checkPairSequence(previousPairs, pattern);
DataCharacter leftChar = this.decodeDataCharacter(row, pattern, isOddPattern, true);
if (!previousPairs.isEmpty() && previousPairs.get(previousPairs.size() - 1).mustBeLast()) {
throw NotFoundException.getNotFoundInstance();
}
DataCharacter rightChar;
try {
rightChar = this.decodeDataCharacter(row, pattern, isOddPattern, false);
} catch (NotFoundException ignored) {
rightChar = null;
}
return new ExpandedPair(leftChar, rightChar, pattern, true);
}
示例10: parseFoundFinderPattern
import com.google.zxing.oned.rss.FinderPattern; //导入依赖的package包/类
private FinderPattern parseFoundFinderPattern(BitArray row, int rowNumber, boolean oddPattern) {
int firstCounter;
int start;
int end;
if (oddPattern) {
int firstElementStart = this.startEnd[0] - 1;
while (firstElementStart >= 0 && !row.get(firstElementStart)) {
firstElementStart--;
}
firstElementStart++;
firstCounter = this.startEnd[0] - firstElementStart;
start = firstElementStart;
end = this.startEnd[1];
} else {
start = this.startEnd[0];
end = row.getNextUnset(this.startEnd[1] + 1);
firstCounter = end - this.startEnd[1];
}
int[] counters = getDecodeFinderCounters();
System.arraycopy(counters, 0, counters, 1, counters.length - 1);
counters[0] = firstCounter;
try {
return new FinderPattern(AbstractRSSReader.parseFinderValue(counters,
FINDER_PATTERNS), new int[]{start, end}, start, end, rowNumber);
} catch (NotFoundException e) {
return null;
}
}
示例11: ExpandedPair
import com.google.zxing.oned.rss.FinderPattern; //导入依赖的package包/类
ExpandedPair(DataCharacter leftChar, DataCharacter rightChar, FinderPattern finderPattern,
boolean mayBeLast) {
this.leftChar = leftChar;
this.rightChar = rightChar;
this.finderPattern = finderPattern;
this.mayBeLast = mayBeLast;
}
示例12: retrieveNextPair
import com.google.zxing.oned.rss.FinderPattern; //导入依赖的package包/类
ExpandedPair retrieveNextPair(BitArray row, List<ExpandedPair> previousPairs, int rowNumber)
throws NotFoundException {
boolean isOddPattern = previousPairs.size() % 2 == 0;
if (startFromEven) {
isOddPattern = !isOddPattern;
}
FinderPattern pattern;
boolean keepFinding = true;
int forcedOffset = -1;
do {
this.findNextPair(row, previousPairs, forcedOffset);
pattern = parseFoundFinderPattern(row, rowNumber, isOddPattern);
if (pattern == null) {
forcedOffset = getNextSecondBar(row, this.startEnd[0]);
} else {
keepFinding = false;
}
} while (keepFinding);
// When stacked symbol is split over multiple rows, there's no way to guess if this pair can be last or not.
// boolean mayBeLast = checkPairSequence(previousPairs, pattern);
DataCharacter leftChar = this.decodeDataCharacter(row, pattern, isOddPattern, true);
if (!previousPairs.isEmpty() && previousPairs.get(previousPairs.size() - 1).mustBeLast()) {
throw NotFoundException.getNotFoundInstance();
}
DataCharacter rightChar;
try {
rightChar = this.decodeDataCharacter(row, pattern, isOddPattern, false);
} catch (NotFoundException ignored) {
rightChar = null;
}
return new ExpandedPair(leftChar, rightChar, pattern, true);
}
示例13: retrieveNextPair
import com.google.zxing.oned.rss.FinderPattern; //导入依赖的package包/类
ExpandedPair retrieveNextPair(BitArray row, List<ExpandedPair> previousPairs, int rowNumber)
throws NotFoundException {
boolean isOddPattern = previousPairs.size() % 2 == 0;
FinderPattern pattern;
boolean keepFinding = true;
int forcedOffset = -1;
do{
this.findNextPair(row, previousPairs, forcedOffset);
pattern = parseFoundFinderPattern(row, rowNumber, isOddPattern);
if (pattern == null){
forcedOffset = getNextSecondBar(row, this.startEnd[0]);
} else {
keepFinding = false;
}
}while(keepFinding);
boolean mayBeLast = checkPairSequence(previousPairs, pattern);
DataCharacter leftChar = this.decodeDataCharacter(row, pattern, isOddPattern, true);
DataCharacter rightChar;
try{
rightChar = this.decodeDataCharacter(row, pattern, isOddPattern, false);
}catch(NotFoundException nfe){
if(mayBeLast) {
rightChar = null;
} else {
throw nfe;
}
}
return new ExpandedPair(leftChar, rightChar, pattern, mayBeLast);
}
示例14: checkPairSequence
import com.google.zxing.oned.rss.FinderPattern; //导入依赖的package包/类
private boolean checkPairSequence(List<ExpandedPair> previousPairs, FinderPattern pattern)
throws NotFoundException {
int currentSequenceLength = previousPairs.size() + 1;
if(currentSequenceLength > this.currentSequence.length) {
throw NotFoundException.getNotFoundInstance();
}
for(int pos = 0; pos < previousPairs.size(); ++pos) {
this.currentSequence[pos] = previousPairs.get(pos).getFinderPattern().getValue();
}
this.currentSequence[currentSequenceLength - 1] = pattern.getValue();
for (int[] validSequence : FINDER_PATTERN_SEQUENCES) {
if (validSequence.length >= currentSequenceLength) {
boolean valid = true;
for (int pos = 0; pos < currentSequenceLength; ++pos) {
if (this.currentSequence[pos] != validSequence[pos]) {
valid = false;
break;
}
}
if (valid) {
return currentSequenceLength == validSequence.length;
}
}
}
throw NotFoundException.getNotFoundInstance();
}
示例15: ExpandedPair
import com.google.zxing.oned.rss.FinderPattern; //导入依赖的package包/类
ExpandedPair(DataCharacter leftChar,
DataCharacter rightChar,
FinderPattern finderPattern,
boolean mayBeLast) {
this.leftChar = leftChar;
this.rightChar = rightChar;
this.finderPattern = finderPattern;
this.mayBeLast = mayBeLast;
}