com.google.zxing.oned.rss.FinderPattern Java Examples

The following examples show how to use com.google.zxing.oned.rss.FinderPattern. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RSSExpandedReader.java    From ScreenCapture with MIT License 5 votes vote down vote up
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);
}
 
Example #2
Source File: ExpandedPair.java    From weex with Apache License 2.0 5 votes vote down vote up
ExpandedPair(DataCharacter leftChar,
             DataCharacter rightChar,
             FinderPattern finderPattern,
             boolean mayBeLast) {
  this.leftChar = leftChar;
  this.rightChar = rightChar;
  this.finderPattern = finderPattern;
  this.mayBeLast = mayBeLast;
}
 
Example #3
Source File: RSSExpandedReader.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
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);
}
 
Example #4
Source File: RSSExpandedReader.java    From weex with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #5
Source File: ExpandedPair.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
ExpandedPair(DataCharacter leftChar,
             DataCharacter rightChar,
             FinderPattern finderPattern,
             boolean mayBeLast) {
  this.leftChar = leftChar;
  this.rightChar = rightChar;
  this.finderPattern = finderPattern;
  this.mayBeLast = mayBeLast;
}
 
Example #6
Source File: ExpandedPair.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
ExpandedPair(DataCharacter leftChar,
             DataCharacter rightChar,
             FinderPattern finderPattern,
             boolean mayBeLast) {
  this.leftChar = leftChar;
  this.rightChar = rightChar;
  this.finderPattern = finderPattern;
  this.mayBeLast = mayBeLast;
}
 
Example #7
Source File: RSSExpandedReader.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #8
Source File: ExpandedPair.java    From ZXing-Orient with Apache License 2.0 5 votes vote down vote up
ExpandedPair(DataCharacter leftChar,
             DataCharacter rightChar,
             FinderPattern finderPattern,
             boolean mayBeLast) {
  this.leftChar = leftChar;
  this.rightChar = rightChar;
  this.finderPattern = finderPattern;
  this.mayBeLast = mayBeLast;
}
 
Example #9
Source File: RSSExpandedReader.java    From reacteu-app with MIT License 5 votes vote down vote up
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);
}
 
Example #10
Source File: RSSExpandedReader.java    From reacteu-app with MIT License 5 votes vote down vote up
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();
}
 
Example #11
Source File: RSSExpandedReader.java    From ZXing-Orient with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #12
Source File: ExpandedPair.java    From QrCodeScanner with GNU General Public License v3.0 5 votes vote down vote up
ExpandedPair(DataCharacter leftChar,
             DataCharacter rightChar,
             FinderPattern finderPattern,
             boolean mayBeLast) {
  this.leftChar = leftChar;
  this.rightChar = rightChar;
  this.finderPattern = finderPattern;
  this.mayBeLast = mayBeLast;
}
 
Example #13
Source File: ExpandedPair.java    From reacteu-app with MIT License 5 votes vote down vote up
ExpandedPair(DataCharacter leftChar,
             DataCharacter rightChar,
             FinderPattern finderPattern,
             boolean mayBeLast) {
  this.leftChar      = leftChar;
  this.rightChar     = rightChar;
  this.finderPattern = finderPattern;
  this.mayBeLast     = mayBeLast;
}
 
Example #14
Source File: RSSExpandedReader.java    From QrCodeScanner with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #15
Source File: ExpandedPair.java    From Tesseract-OCR-Scanner with Apache License 2.0 5 votes vote down vote up
ExpandedPair(DataCharacter leftChar,
             DataCharacter rightChar,
             FinderPattern finderPattern,
             boolean mayBeLast) {
  this.leftChar = leftChar;
  this.rightChar = rightChar;
  this.finderPattern = finderPattern;
  this.mayBeLast = mayBeLast;
}
 
Example #16
Source File: RSSExpandedReader.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
private FinderPattern a(BitArray bitarray, int i1, boolean flag)
{
    int j1;
    int k1;
    int l1;
    int ai[];
    int i2;
    if (flag)
    {
        int j2;
        for (j2 = -1 + p[0]; j2 >= 0 && !bitarray.get(j2); j2--) { }
        j1 = j2 + 1;
        l1 = p[0] - j1;
        k1 = p[1];
    } else
    {
        j1 = p[0];
        k1 = bitarray.getNextUnset(1 + p[1]);
        l1 = k1 - p[1];
    }
    ai = getDecodeFinderCounters();
    System.arraycopy(ai, 0, ai, 1, -1 + ai.length);
    ai[0] = l1;
    try
    {
        i2 = parseFinderValue(ai, d);
    }
    catch (NotFoundException notfoundexception)
    {
        return null;
    }
    return new FinderPattern(i2, new int[] {
        j1, k1
    }, j1, k1, i1);
}
 
Example #17
Source File: b.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
b(DataCharacter datacharacter, DataCharacter datacharacter1, FinderPattern finderpattern, boolean flag)
{
    b = datacharacter;
    c = datacharacter1;
    d = finderpattern;
    a = flag;
}
 
Example #18
Source File: ExpandedPair.java    From ScreenCapture with MIT License 5 votes vote down vote up
ExpandedPair(DataCharacter leftChar,
             DataCharacter rightChar,
             FinderPattern finderPattern,
             boolean mayBeLast) {
  this.leftChar = leftChar;
  this.rightChar = rightChar;
  this.finderPattern = finderPattern;
  this.mayBeLast = mayBeLast;
}
 
Example #19
Source File: RSSExpandedReader.java    From Tesseract-OCR-Scanner with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #20
Source File: b.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
FinderPattern d()
{
    return d;
}
 
Example #21
Source File: RSSExpandedReader.java    From reacteu-app with MIT License 4 votes vote down vote up
private static boolean isNotA1left(FinderPattern pattern, boolean isOddPattern, boolean leftChar) {
  // A1: pattern.getValue is 0 (A), and it's an oddPattern, and it is a left char
  return !(pattern.getValue() == 0 && isOddPattern && leftChar);
}
 
Example #22
Source File: ExpandedPair.java    From weex with Apache License 2.0 4 votes vote down vote up
FinderPattern getFinderPattern() {
  return this.finderPattern;
}
 
Example #23
Source File: RSSExpandedReader.java    From barcodescanner-lib-aar with MIT License 4 votes vote down vote up
private FinderPattern parseFoundFinderPattern(BitArray row, int rowNumber, boolean oddPattern) {
  // Actually we found elements 2-5.
  int firstCounter;
  int start;
  int end;

  if (oddPattern) {
    // If pattern number is odd, we need to locate element 1 *before* the current block.

    int firstElementStart = this.startEnd[0] - 1;
    // Locate element 1
    while (firstElementStart >= 0 && !row.get(firstElementStart)) {
      firstElementStart--;
    }

    firstElementStart++;
    firstCounter = this.startEnd[0] - firstElementStart;
    start = firstElementStart;
    end = this.startEnd[1];

  } else {
    // If pattern number is even, the pattern is reversed, so we need to locate element 1 *after* the current block.

    start = this.startEnd[0];

    end = row.getNextUnset(this.startEnd[1] + 1);
    firstCounter = end - this.startEnd[1];
  }

  // Make 'counters' hold 1-4
  int [] counters = this.getDecodeFinderCounters();
  System.arraycopy(counters, 0, counters, 1, counters.length - 1);

  counters[0] = firstCounter;
  int value;
  try {
    value = parseFinderValue(counters, FINDER_PATTERNS);
  } catch (NotFoundException ignored) {
    return null;
  }
  return new FinderPattern(value, new int[] {start, end}, start, end, rowNumber);
}
 
Example #24
Source File: RSSExpandedReader.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
private boolean a(List list, FinderPattern finderpattern)
    {
        int i1;
        int ai[][];
        int k1;
        int l1;
        i1 = 1 + list.size();
        if (i1 > q.length)
        {
            throw NotFoundException.getNotFoundInstance();
        }
        for (int j1 = 0; j1 < list.size(); j1++)
        {
            q[j1] = ((b)list.get(j1)).d().getValue();
        }

        q[i1 - 1] = finderpattern.getValue();
        ai = l;
        k1 = ai.length;
        l1 = 0;
_L6:
        if (l1 >= k1) goto _L2; else goto _L1
_L1:
        int ai1[];
        int i2;
        ai1 = ai[l1];
        if (ai1.length < i1)
        {
            continue; /* Loop/switch isn't completed */
        }
        i2 = 0;
_L5:
        if (i2 >= i1)
        {
            break MISSING_BLOCK_LABEL_180;
        }
        if (q[i2] == ai1[i2]) goto _L4; else goto _L3
_L3:
        boolean flag = false;
_L7:
        if (!flag)
        {
            continue; /* Loop/switch isn't completed */
        }
        int j2 = ai1.length;
        boolean flag1 = false;
        if (i1 == j2)
        {
            flag1 = true;
        }
        return flag1;
_L4:
        i2++;
          goto _L5
        l1++;
          goto _L6
_L2:
        throw NotFoundException.getNotFoundInstance();
        flag = true;
          goto _L7
    }
 
Example #25
Source File: RSSExpandedReader.java    From barcodescanner-lib-aar with MIT License 4 votes vote down vote up
private static boolean isNotA1left(FinderPattern pattern, boolean isOddPattern, boolean leftChar) {
  // A1: pattern.getValue is 0 (A), and it's an oddPattern, and it is a left char
  return !(pattern.getValue() == 0 && isOddPattern && leftChar);
}
 
Example #26
Source File: RSSExpandedReader.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
private static boolean a(FinderPattern finderpattern, boolean flag, boolean flag1)
{
    return finderpattern.getValue() != 0 || !flag || !flag1;
}
 
Example #27
Source File: ExpandedPair.java    From barcodescanner-lib-aar with MIT License 4 votes vote down vote up
FinderPattern getFinderPattern() {
  return this.finderPattern;
}
 
Example #28
Source File: ExpandedPair.java    From reacteu-app with MIT License 4 votes vote down vote up
FinderPattern getFinderPattern() {
  return this.finderPattern;
}
 
Example #29
Source File: RSSExpandedReader.java    From reacteu-app with MIT License 4 votes vote down vote up
private FinderPattern parseFoundFinderPattern(BitArray row, int rowNumber, boolean oddPattern) {
  // Actually we found elements 2-5.
  int firstCounter;
  int start;
  int end;

  if(oddPattern){
    // If pattern number is odd, we need to locate element 1 *before* the current block.

    int firstElementStart = this.startEnd[0] - 1;
    // Locate element 1
    while (firstElementStart >= 0 && !row.get(firstElementStart)) {
      firstElementStart--;
    }

    firstElementStart++;
    firstCounter = this.startEnd[0] - firstElementStart;
    start = firstElementStart;
    end = this.startEnd[1];

  }else{
    // If pattern number is even, the pattern is reversed, so we need to locate element 1 *after* the current block.

    start = this.startEnd[0];

    end = row.getNextUnset(this.startEnd[1] + 1);
    firstCounter = end - this.startEnd[1];
  }

  // Make 'counters' hold 1-4
  int [] counters = this.getDecodeFinderCounters();
  System.arraycopy(counters, 0, counters, 1, counters.length - 1);

  counters[0] = firstCounter;
  int value;
  try {
    value = parseFinderValue(counters, FINDER_PATTERNS);
  } catch (NotFoundException nfe) {
    return null;
  }
  return new FinderPattern(value, new int[] {start, end}, start, end, rowNumber);
}
 
Example #30
Source File: ExpandedPair.java    From QrCodeScanner with GNU General Public License v3.0 4 votes vote down vote up
FinderPattern getFinderPattern() {
  return this.finderPattern;
}