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


Java PDF417Common.getBitCountSum方法代码示例

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


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

示例1: sampleBitCounts

import com.google.zxing.pdf417.PDF417Common; //导入方法依赖的package包/类
private static int[] sampleBitCounts(int[] moduleBitCount) {
  float bitCountSum = PDF417Common.getBitCountSum(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:amap-demo,项目名称:weex-3d-map,代码行数:18,代码来源:PDF417CodewordDecoder.java

示例2: getClosestDecodedValue

import com.google.zxing.pdf417.PDF417Common; //导入方法依赖的package包/类
private static int getClosestDecodedValue(int[] moduleBitCount) {
  int bitCountSum = PDF417Common.getBitCountSum(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:amap-demo,项目名称:weex-3d-map,代码行数:26,代码来源:PDF417CodewordDecoder.java

示例3: getClosestDecodedValue

import com.google.zxing.pdf417.PDF417Common; //导入方法依赖的package包/类
private static int getClosestDecodedValue(int[] moduleBitCount) {
    int bitCountSum = PDF417Common.getBitCountSum(moduleBitCount);
    float[] bitCountRatios = new float[8];
    for (int i = 0; i < bitCountRatios.length; i++) {
        bitCountRatios[i] = ((float) moduleBitCount[i]) / ((float) bitCountSum);
    }
    float bestMatchError = AutoScrollHelper.NO_MAX;
    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 < 8; 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:JackChan1999,项目名称:boohee_v5.6,代码行数:26,代码来源:PDF417CodewordDecoder.java

示例4: sampleBitCounts

import com.google.zxing.pdf417.PDF417Common; //导入方法依赖的package包/类
private static int[] sampleBitCounts(int[] moduleBitCount) {
    float bitCountSum = PDF417Common.getBitCountSum(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:Ag47,项目名称:TrueTone,代码行数:18,代码来源:PDF417CodewordDecoder.java

示例5: getClosestDecodedValue

import com.google.zxing.pdf417.PDF417Common; //导入方法依赖的package包/类
private static int getClosestDecodedValue(int[] moduleBitCount) {
    int bitCountSum = PDF417Common.getBitCountSum(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:Ag47,项目名称:TrueTone,代码行数:26,代码来源:PDF417CodewordDecoder.java

示例6: getClosestDecodedValue

import com.google.zxing.pdf417.PDF417Common; //导入方法依赖的package包/类
private static int getClosestDecodedValue(int[] moduleBitCount) {
    int bitCountSum = PDF417Common.getBitCountSum(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;
        for (int k = 0; k < PDF417Common.BARS_IN_MODULE; k++) {
            float diff = RATIOS_TABLE[j][k] - bitCountRatios[k];
            error += diff * diff;
        }
        if (error < bestMatchError) {
            bestMatchError = error;
            bestMatch = PDF417Common.SYMBOL_TABLE[j];
        }
    }
    return bestMatch;
}
 
开发者ID:yakovenkodenis,项目名称:Discounty,代码行数:22,代码来源:PDF417CodewordDecoder.java

示例7: getClosestDecodedValue

import com.google.zxing.pdf417.PDF417Common; //导入方法依赖的package包/类
private static int getClosestDecodedValue(int[] moduleBitCount) {
  int bitCountSum = PDF417Common.getBitCountSum(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;
    for (int k = 0; k < PDF417Common.BARS_IN_MODULE; k++) {
      float diff = RATIOS_TABLE[j][k] - bitCountRatios[k];
      error += diff * diff;
    }
    if (error < bestMatchError) {
      bestMatchError = error;
      bestMatch = PDF417Common.SYMBOL_TABLE[j];
    }
  }
  return bestMatch;
}
 
开发者ID:yinglovezhuzhu,项目名称:ZxingCore,代码行数:22,代码来源:PDF417CodewordDecoder.java

示例8: detectCodeword

import com.google.zxing.pdf417.PDF417Common; //导入方法依赖的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);
    int[] moduleBitCount = getModuleBitCount(image, minColumn, maxColumn, leftToRight,
            startColumn, imageRow);
    if (moduleBitCount == null) {
        return null;
    }
    int endColumn;
    int codewordBitCount = PDF417Common.getBitCountSum(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;
    }
    if (!checkCodewordSkew(codewordBitCount, minCodewordWidth, maxCodewordWidth)) {
        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:JackChan1999,项目名称:boohee_v5.6,代码行数:35,代码来源:PDF417ScanningDecoder.java

示例9: detectCodeword

import com.google.zxing.pdf417.PDF417Common; //导入方法依赖的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 = PDF417Common.getBitCountSum(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:amap-demo,项目名称:weex-3d-map,代码行数:58,代码来源:PDF417ScanningDecoder.java

示例10: detectCodeword

import com.google.zxing.pdf417.PDF417Common; //导入方法依赖的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 = PDF417Common.getBitCountSum(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:Ag47,项目名称:TrueTone,代码行数:58,代码来源:PDF417ScanningDecoder.java

示例11: detectCodeword

import com.google.zxing.pdf417.PDF417Common; //导入方法依赖的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 = PDF417Common.getBitCountSum(moduleBitCount);
    if (leftToRight) {
        endColumn = startColumn + codewordBitCount;
    } else {
        for (int i = 0; i < moduleBitCount.length >> 1; 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:yakovenkodenis,项目名称:Discounty,代码行数:58,代码来源:PDF417ScanningDecoder.java

示例12: detectCodeword

import com.google.zxing.pdf417.PDF417Common; //导入方法依赖的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 = PDF417Common.getBitCountSum(moduleBitCount);
  if (leftToRight) {
    endColumn = startColumn + codewordBitCount;
  } else {
    for (int i = 0; i < moduleBitCount.length >> 1; 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:yinglovezhuzhu,项目名称:ZxingCore,代码行数:58,代码来源:PDF417ScanningDecoder.java


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