コード例 #1
0
 /**
  * This is called when a horizontal scan finds a possible alignment pattern. It will cross check
  * with a vertical scan, and if successful, will, ah, cross-cross-check with another horizontal
  * scan. This is needed primarily to locate the real horizontal center of the pattern in cases of
  * extreme skew.
  *
  * <p>If that succeeds the finder pattern location is added to a list that tracks the number of
  * times each location has been nearly-matched as a finder pattern. Each additional find is more
  * evidence that the location is in fact a finder pattern center
  *
  * @param stateCount reading state module counts from horizontal scan
  * @param i row where finder pattern may be found
  * @param j end of possible finder pattern in row
  * @return true if a finder pattern candidate was found this time
  */
 protected final boolean handlePossibleCenter(int[] stateCount, int i, int j) {
   int stateCountTotal =
       stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
   float centerJ = centerFromEnd(stateCount, j);
   float centerI = crossCheckVertical(i, (int) centerJ, stateCount[2], stateCountTotal);
   if (!Float.isNaN(centerI)) {
     // Re-cross check
     centerJ = crossCheckHorizontal((int) centerJ, (int) centerI, stateCount[2], stateCountTotal);
     if (!Float.isNaN(centerJ)) {
       float estimatedModuleSize = (float) stateCountTotal / 7.0f;
       boolean found = false;
       for (int index = 0; index < possibleCenters.size(); index++) {
         FinderPattern center = possibleCenters.get(index);
         // Look for about the same center and module size:
         if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) {
           possibleCenters.set(
               index, center.combineEstimate(centerI, centerJ, estimatedModuleSize));
           found = true;
           break;
         }
       }
       if (!found) {
         FinderPattern point = new FinderPattern(centerJ, centerI, estimatedModuleSize);
         possibleCenters.add(point);
         if (resultPointCallback != null) {
           resultPointCallback.foundPossibleResultPoint(point);
         }
       }
       return true;
     }
   }
   return false;
 }
コード例 #2
0
 protected final boolean handlePossibleCenter(int[] paramArrayOfInt, int paramInt1, int paramInt2)
 {
   int i = paramArrayOfInt[0] + paramArrayOfInt[1] + paramArrayOfInt[2] + paramArrayOfInt[3] + paramArrayOfInt[4];
   float f1 = centerFromEnd(paramArrayOfInt, paramInt2);
   float f2 = crossCheckVertical(paramInt1, (int)f1, paramArrayOfInt[2], i);
   if (!Float.isNaN(f2))
   {
     float f3 = crossCheckHorizontal((int)f1, (int)f2, paramArrayOfInt[2], i);
     if (!Float.isNaN(f3))
     {
       float f4 = i / 7.0F;
       for (int j = 0;; j++)
       {
         int k = this.possibleCenters.size();
         int m = 0;
         if (j < k)
         {
           FinderPattern localFinderPattern2 = (FinderPattern)this.possibleCenters.get(j);
           if (localFinderPattern2.aboutEquals(f4, f2, f3))
           {
             this.possibleCenters.set(j, localFinderPattern2.combineEstimate(f2, f3, f4));
             m = 1;
           }
         }
         else
         {
           if (m == 0)
           {
             FinderPattern localFinderPattern1 = new FinderPattern(f3, f2, f4);
             this.possibleCenters.add(localFinderPattern1);
             if (this.resultPointCallback != null) {
               this.resultPointCallback.foundPossibleResultPoint(localFinderPattern1);
             }
           }
           return true;
         }
       }
     }
   }
   return false;
 }