private boolean crossCheckDiagonal(int startI,int centerJ,int maxCount,int originalStateCountTotal){
  int[] stateCount=getCrossCheckStateCount();
  int i=0;
  while (startI >= i && centerJ >= i && image.get(centerJ - i,startI - i)) {
    stateCount[2]++;
    i++;
  }
  if (startI < i || centerJ < i) {
    return false;
  }
  while (startI >= i && centerJ >= i && !image.get(centerJ - i,startI - i) && stateCount[1] <= maxCount) {
    stateCount[1]++;
    i++;
  }
  if (startI < i || centerJ < i || stateCount[1] > maxCount) {
    return false;
  }
  while (startI >= i && centerJ >= i && image.get(centerJ - i,startI - i) && stateCount[0] <= maxCount) {
    stateCount[0]++;
    i++;
  }
  if (stateCount[0] > maxCount) {
    return false;
  }
  int maxI=image.getHeight();
  int maxJ=image.getWidth();
  i=1;
  while (startI + i < maxI && centerJ + i < maxJ && image.get(centerJ + i,startI + i)) {
    stateCount[2]++;
    i++;
  }
  if (startI + i >= maxI || centerJ + i >= maxJ) {
    return false;
  }
  while (startI + i < maxI && centerJ + i < maxJ && !image.get(centerJ + i,startI + i) && stateCount[3] < maxCount) {
    stateCount[3]++;
    i++;
  }
  if (startI + i >= maxI || centerJ + i >= maxJ || stateCount[3] >= maxCount) {
    return false;
  }
  while (startI + i < maxI && centerJ + i < maxJ && image.get(centerJ + i,startI + i) && stateCount[4] < maxCount) {
    stateCount[4]++;
    i++;
  }
  if (stateCount[4] >= maxCount) {
    return false;
  }
  int stateCountTotal=stateCount[0] + stateCount[1] + stateCount[2]+ stateCount[3]+ stateCount[4];
  return Math.abs(stateCountTotal - originalStateCountTotal) < 2 * originalStateCountTotal && foundPatternCross(stateCount);
}

private boolean crossCheckDiagonal ( int startI , int centerJ , int maxCount , int originalStateCountTotal ) { int [ ] stateCount = getCrossCheckStateCount ( ) ; int i = 0 ; while ( startI >= i && centerJ >= i && image . get ( centerJ - i , startI - i ) ) { stateCount [ 2 ] ++ ; i ++ ; } if ( startI < i || centerJ < i ) { return false ; } while ( startI >= i && centerJ >= i && ! image . get ( centerJ - i , startI - i ) && stateCount [ 1 ] <= maxCount ) { stateCount [ 1 ] ++ ; i ++ ; } if ( startI < i || centerJ < i || stateCount [ 1 ] > maxCount ) { return false ; } while ( startI >= i && centerJ >= i && image . get ( centerJ - i , startI - i ) && stateCount [ 0 ] <= maxCount ) { stateCount [ 0 ] ++ ; i ++ ; } if ( stateCount [ 0 ] > maxCount ) { return false ; } int maxI = image . getHeight ( ) ; int maxJ = image . getWidth ( ) ; i = 1 ; while ( startI + i < maxI && centerJ + i < maxJ && image . get ( centerJ + i , startI + i ) ) { stateCount [ 2 ] ++ ; i ++ ; } if ( startI + i >= maxI || centerJ + i >= maxJ ) { return false ; } while ( startI + i < maxI && centerJ + i < maxJ && ! image . get ( centerJ + i , startI + i ) && stateCount [ 3 ] < maxCount ) { stateCount [ 3 ] ++ ; i ++ ; } if ( startI + i >= maxI || centerJ + i >= maxJ || stateCount [ 3 ] >= maxCount ) { return false ; } while ( startI + i < maxI && centerJ + i < maxJ && image . get ( centerJ + i , startI + i ) && stateCount [ 4 ] < maxCount ) { stateCount [ 4 ] ++ ; i ++ ; } if ( stateCount [ 4 ] >= maxCount ) { return false ; } int stateCountTotal = stateCount [ 0 ] + stateCount [ 1 ] + stateCount [ 2 ] + stateCount [ 3 ] + stateCount [ 4 ] ; return Math . abs ( stateCountTotal - originalStateCountTotal ) < 2 * originalStateCountTotal && foundPatternCross ( stateCount ) ; }
after a vertical and horizontal scan finds a potential finder pattern , this method " cross - cross - cross - checks " by scanning down diagonally through the center of the possible finder pattern to see if the same proportion is detected .
