当前位置: 首页>>代码示例>>Java>>正文


Java MathUtils.sum方法代码示例

本文整理汇总了Java中com.google.zxing.common.detector.MathUtils.sum方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.sum方法的具体用法?Java MathUtils.sum怎么用?Java MathUtils.sum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.zxing.common.detector.MathUtils的用法示例。


在下文中一共展示了MathUtils.sum方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sampleBitCounts

import com.google.zxing.common.detector.MathUtils; //导入方法依赖的package包/类
private static int[] sampleBitCounts(int[] moduleBitCount) {
  float bitCountSum = MathUtils.sum(moduleBitCount);
  int[] result = new int[PDF417Common.BARS_IN_MODULE];
  int bitCountIndex = 0;
  int sumPreviousBits = 0;
  for (int i = 0; i < PDF417Common.MODULES_IN_CODEWORD; i++) {
    float sampleIndex = 
        bitCountSum / (2 * PDF417Common.MODULES_IN_CODEWORD) + 
        (i * bitCountSum) / PDF417Common.MODULES_IN_CODEWORD;
    if (sumPreviousBits + moduleBitCount[bitCountIndex] <= sampleIndex) {
      sumPreviousBits += moduleBitCount[bitCountIndex];
      bitCountIndex++;
    }
    result[bitCountIndex]++;
  }
  return result;
}
 
开发者ID:xiong-it,项目名称:PortraitZXing,代码行数:18,代码来源:PDF417CodewordDecoder.java

示例2: getClosestDecodedValue

import com.google.zxing.common.detector.MathUtils; //导入方法依赖的package包/类
private static int getClosestDecodedValue(int[] moduleBitCount) {
  int bitCountSum = MathUtils.sum(moduleBitCount);
  float[] bitCountRatios = new float[PDF417Common.BARS_IN_MODULE];
  for (int i = 0; i < bitCountRatios.length; i++) {
    bitCountRatios[i] = moduleBitCount[i] / (float) bitCountSum;
  }
  float bestMatchError = Float.MAX_VALUE;
  int bestMatch = -1;
  for (int j = 0; j < RATIOS_TABLE.length; j++) {
    float error = 0.0f;
    float[] ratioTableRow = RATIOS_TABLE[j];
    for (int k = 0; k < PDF417Common.BARS_IN_MODULE; k++) {
      float diff = ratioTableRow[k] - bitCountRatios[k];
      error += diff * diff;
      if (error >= bestMatchError) {
        break;
      }
    }
    if (error < bestMatchError) {
      bestMatchError = error;
      bestMatch = PDF417Common.SYMBOL_TABLE[j];
    }
  }
  return bestMatch;
}
 
开发者ID:xiong-it,项目名称:PortraitZXing,代码行数:26,代码来源:PDF417CodewordDecoder.java

示例3: getBitCountSum

import com.google.zxing.common.detector.MathUtils; //导入方法依赖的package包/类
/**
 * @deprecated call {@link MathUtils#sum(int[])}
 */
@Deprecated
public static int getBitCountSum(int[] moduleBitCount) {
  return MathUtils.sum(moduleBitCount);
}
 
开发者ID:xiong-it,项目名称:PortraitZXing,代码行数:8,代码来源:PDF417Common.java

示例4: detectCodeword

import com.google.zxing.common.detector.MathUtils; //导入方法依赖的package包/类
private static Codeword detectCodeword(BitMatrix image,
                                       int minColumn,
                                       int maxColumn,
                                       boolean leftToRight,
                                       int startColumn,
                                       int imageRow,
                                       int minCodewordWidth,
                                       int maxCodewordWidth) {
  startColumn = adjustCodewordStartColumn(image, minColumn, maxColumn, leftToRight, startColumn, imageRow);
  // we usually know fairly exact now how long a codeword is. We should provide minimum and maximum expected length
  // and try to adjust the read pixels, e.g. remove single pixel errors or try to cut off exceeding pixels.
  // min and maxCodewordWidth should not be used as they are calculated for the whole barcode an can be inaccurate
  // for the current position
  int[] moduleBitCount = getModuleBitCount(image, minColumn, maxColumn, leftToRight, startColumn, imageRow);
  if (moduleBitCount == null) {
    return null;
  }
  int endColumn;
  int codewordBitCount = MathUtils.sum(moduleBitCount);
  if (leftToRight) {
    endColumn = startColumn + codewordBitCount;
  } else {
    for (int i = 0; i < moduleBitCount.length / 2; i++) {
      int tmpCount = moduleBitCount[i];
      moduleBitCount[i] = moduleBitCount[moduleBitCount.length - 1 - i];
      moduleBitCount[moduleBitCount.length - 1 - i] = tmpCount;
    }
    endColumn = startColumn;
    startColumn = endColumn - codewordBitCount;
  }
  // TODO implement check for width and correction of black and white bars
  // use start (and maybe stop pattern) to determine if blackbars are wider than white bars. If so, adjust.
  // should probably done only for codewords with a lot more than 17 bits. 
  // The following fixes 10-1.png, which has wide black bars and small white bars
  //    for (int i = 0; i < moduleBitCount.length; i++) {
  //      if (i % 2 == 0) {
  //        moduleBitCount[i]--;
  //      } else {
  //        moduleBitCount[i]++;
  //      }
  //    }

  // We could also use the width of surrounding codewords for more accurate results, but this seems
  // sufficient for now
  if (!checkCodewordSkew(codewordBitCount, minCodewordWidth, maxCodewordWidth)) {
    // We could try to use the startX and endX position of the codeword in the same column in the previous row,
    // create the bit count from it and normalize it to 8. This would help with single pixel errors.
    return null;
  }

  int decodedValue = PDF417CodewordDecoder.getDecodedValue(moduleBitCount);
  int codeword = PDF417Common.getCodeword(decodedValue);
  if (codeword == -1) {
    return null;
  }
  return new Codeword(startColumn, endColumn, getCodewordBucketNumber(decodedValue), codeword);
}
 
开发者ID:xiong-it,项目名称:PortraitZXing,代码行数:58,代码来源:PDF417ScanningDecoder.java

示例5: count

import com.google.zxing.common.detector.MathUtils; //导入方法依赖的package包/类
/**
 * @deprecated call {@link MathUtils#sum(int[])}
 */
@Deprecated
protected static int count(int[] array) {
  return MathUtils.sum(array);
}
 
开发者ID:xiong-it,项目名称:PortraitZXing,代码行数:8,代码来源:AbstractRSSReader.java

示例6: count

import com.google.zxing.common.detector.MathUtils; //导入方法依赖的package包/类
/**
 * @param array values to sum
 * @return sum of values
 * @deprecated call {@link MathUtils#sum(int[])}
 */
@Deprecated
protected static int count(int[] array) {
  return MathUtils.sum(array);
}
 
开发者ID:10045125,项目名称:QrCode,代码行数:10,代码来源:AbstractRSSReader.java


注:本文中的com.google.zxing.common.detector.MathUtils.sum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。