當前位置: 首頁>>代碼示例>>Java>>正文


Java ChecksumException類代碼示例

本文整理匯總了Java中com.google.zxing.ChecksumException的典型用法代碼示例。如果您正苦於以下問題:Java ChecksumException類的具體用法?Java ChecksumException怎麽用?Java ChecksumException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ChecksumException類屬於com.google.zxing包,在下文中一共展示了ChecksumException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: decode

import com.google.zxing.ChecksumException; //導入依賴的package包/類
private static Result[] decode(BinaryBitmap image, Map<DecodeHintType, ?> hints, boolean multiple) 
    throws NotFoundException, FormatException, ChecksumException {
  List<Result> results = new ArrayList<>();
  PDF417DetectorResult detectorResult = Detector.detect(image, hints, multiple);
  for (ResultPoint[] points : detectorResult.getPoints()) {
    DecoderResult decoderResult = PDF417ScanningDecoder.decode(detectorResult.getBits(), points[4], points[5],
        points[6], points[7], getMinCodewordWidth(points), getMaxCodewordWidth(points));
    Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.PDF_417);
    result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.getECLevel());
    PDF417ResultMetadata pdf417ResultMetadata = (PDF417ResultMetadata) decoderResult.getOther();
    if (pdf417ResultMetadata != null) {
      result.putMetadata(ResultMetadataType.PDF417_EXTRA_METADATA, pdf417ResultMetadata);
    }
    results.add(result);
  }
  return results.toArray(new Result[results.size()]);
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:18,代碼來源:PDF417Reader.java

示例2: decodeCodewords

import com.google.zxing.ChecksumException; //導入依賴的package包/類
private static DecoderResult decodeCodewords(int[] codewords, int ecLevel, int[] erasures) throws FormatException,
    ChecksumException {
  if (codewords.length == 0) {
    throw FormatException.getFormatInstance();
  }

  int numECCodewords = 1 << (ecLevel + 1);
  int correctedErrorsCount = correctErrors(codewords, erasures, numECCodewords);
  verifyCodewordCount(codewords, numECCodewords);

  // Decode the codewords
  DecoderResult decoderResult = DecodedBitStreamParser.decode(codewords, String.valueOf(ecLevel));
  decoderResult.setErrorsCorrected(correctedErrorsCount);
  decoderResult.setErasures(erasures.length);
  return decoderResult;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:17,代碼來源:PDF417ScanningDecoder.java

示例3: findErrorLocations

import com.google.zxing.ChecksumException; //導入依賴的package包/類
private int[] findErrorLocations(ModulusPoly errorLocator) throws ChecksumException {
  // This is a direct application of Chien's search
  int numErrors = errorLocator.getDegree();
  int[] result = new int[numErrors];
  int e = 0;
  for (int i = 1; i < field.getSize() && e < numErrors; i++) {
    if (errorLocator.evaluateAt(i) == 0) {
      result[e] = field.inverse(i);
      e++;
    }
  }
  if (e != numErrors) {
    throw ChecksumException.getChecksumInstance();
  }
  return result;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:17,代碼來源:ErrorCorrection.java

示例4: correctErrors

import com.google.zxing.ChecksumException; //導入依賴的package包/類
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  int numECCodewords = codewordBytes.length - numDataCodewords;
  try {
    rsDecoder.decode(codewordsInts, numECCodewords);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:28,代碼來源:Decoder.java

示例5: decode

import com.google.zxing.ChecksumException; //導入依賴的package包/類
@Override
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
    throws NotFoundException, ChecksumException, FormatException {
  DecoderResult decoderResult;
  ResultPoint[] points;
  if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) {
    BitMatrix bits = extractPureBits(image.getBlackMatrix());
    decoderResult = decoder.decode(bits);
    points = NO_POINTS;
  } else {
    DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect();
    decoderResult = decoder.decode(detectorResult.getBits());
    points = detectorResult.getPoints();
  }
  Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points,
      BarcodeFormat.DATA_MATRIX);
  List<byte[]> byteSegments = decoderResult.getByteSegments();
  if (byteSegments != null) {
    result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
  }
  String ecLevel = decoderResult.getECLevel();
  if (ecLevel != null) {
    result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
  }
  return result;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:27,代碼來源:DataMatrixReader.java

示例6: decode

import com.google.zxing.ChecksumException; //導入依賴的package包/類
@Override
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
    throws NotFoundException, ChecksumException, FormatException {
  DecoderResult decoderResult;
  if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) {
    BitMatrix bits = extractPureBits(image.getBlackMatrix());
    decoderResult = decoder.decode(bits, hints);
  } else {
    throw NotFoundException.getNotFoundInstance();
  }

  ResultPoint[] points = NO_POINTS;
  Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.MAXICODE);

  String ecLevel = decoderResult.getECLevel();
  if (ecLevel != null) {
    result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
  }
  return result;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:21,代碼來源:MaxiCodeReader.java

示例7: correctErrors

import com.google.zxing.ChecksumException; //導入依賴的package包/類
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  try {
    rsDecoder.decode(codewordsInts, codewordBytes.length - numDataCodewords);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
開發者ID:10045125,項目名稱:QrCode,代碼行數:27,代碼來源:Decoder.java

示例8: decode

import com.google.zxing.ChecksumException; //導入依賴的package包/類
private static Result[] decode(BinaryBitmap image, Map<DecodeHintType, ?> hints, boolean
        multiple) throws NotFoundException, FormatException, ChecksumException {
    List<Result> results = new ArrayList();
    PDF417DetectorResult detectorResult = Detector.detect(image, hints, multiple);
    for (ResultPoint[] points : detectorResult.getPoints()) {
        DecoderResult decoderResult = PDF417ScanningDecoder.decode(detectorResult.getBits(),
                points[4], points[5], points[6], points[7], getMinCodewordWidth(points),
                getMaxCodewordWidth(points));
        Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(),
                points, BarcodeFormat.PDF_417);
        result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult
                .getECLevel());
        PDF417ResultMetadata pdf417ResultMetadata = (PDF417ResultMetadata) decoderResult
                .getOther();
        if (pdf417ResultMetadata != null) {
            result.putMetadata(ResultMetadataType.PDF417_EXTRA_METADATA, pdf417ResultMetadata);
        }
        results.add(result);
    }
    return (Result[]) results.toArray(new Result[results.size()]);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:22,代碼來源:PDF417Reader.java

示例9: correctErrors

import com.google.zxing.ChecksumException; //導入依賴的package包/類
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws
        ChecksumException {
    int i;
    int numCodewords = codewordBytes.length;
    int[] codewordsInts = new int[numCodewords];
    for (i = 0; i < numCodewords; i++) {
        codewordsInts[i] = codewordBytes[i] & 255;
    }
    try {
        this.rsDecoder.decode(codewordsInts, codewordBytes.length - numDataCodewords);
        for (i = 0; i < numDataCodewords; i++) {
            codewordBytes[i] = (byte) codewordsInts[i];
        }
    } catch (ReedSolomonException e) {
        throw ChecksumException.getChecksumInstance();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:18,代碼來源:Decoder.java

示例10: decode

import com.google.zxing.ChecksumException; //導入依賴的package包/類
public Result decode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws
        NotFoundException, ChecksumException, FormatException {
    DecoderResult decoderResult;
    ResultPoint[] points;
    if (hints == null || !hints.containsKey(DecodeHintType.PURE_BARCODE)) {
        DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect();
        decoderResult = this.decoder.decode(detectorResult.getBits());
        points = detectorResult.getPoints();
    } else {
        decoderResult = this.decoder.decode(extractPureBits(image.getBlackMatrix()));
        points = NO_POINTS;
    }
    Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points,
            BarcodeFormat.DATA_MATRIX);
    List<byte[]> byteSegments = decoderResult.getByteSegments();
    if (byteSegments != null) {
        result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
    }
    String ecLevel = decoderResult.getECLevel();
    if (ecLevel != null) {
        result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
    }
    return result;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:25,代碼來源:DataMatrixReader.java

示例11: decode

import com.google.zxing.ChecksumException; //導入依賴的package包/類
public DecoderResult decode(BitMatrix bits) throws FormatException, ChecksumException {
    BitMatrixParser parser = new BitMatrixParser(bits);
    DataBlock[] dataBlocks = DataBlock.getDataBlocks(parser.readCodewords(), parser
            .getVersion());
    int dataBlocksCount = dataBlocks.length;
    int totalBytes = 0;
    for (DataBlock db : dataBlocks) {
        totalBytes += db.getNumDataCodewords();
    }
    byte[] resultBytes = new byte[totalBytes];
    for (int j = 0; j < dataBlocksCount; j++) {
        DataBlock dataBlock = dataBlocks[j];
        byte[] codewordBytes = dataBlock.getCodewords();
        int numDataCodewords = dataBlock.getNumDataCodewords();
        correctErrors(codewordBytes, numDataCodewords);
        for (int i = 0; i < numDataCodewords; i++) {
            resultBytes[(i * dataBlocksCount) + j] = codewordBytes[i];
        }
    }
    return DecodedBitStreamParser.decode(resultBytes);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:22,代碼來源:Decoder.java

示例12: decode

import com.google.zxing.ChecksumException; //導入依賴的package包/類
public DecoderResult decode(BitMatrix bits, Map<DecodeHintType, ?> map) throws
        FormatException, ChecksumException {
    byte[] datawords;
    byte[] codewords = new BitMatrixParser(bits).readCodewords();
    correctErrors(codewords, 0, 10, 10, 0);
    int mode = codewords[0] & 15;
    switch (mode) {
        case 2:
        case 3:
        case 4:
            correctErrors(codewords, 20, 84, 40, 1);
            correctErrors(codewords, 20, 84, 40, 2);
            datawords = new byte[94];
            break;
        case 5:
            correctErrors(codewords, 20, 68, 56, 1);
            correctErrors(codewords, 20, 68, 56, 2);
            datawords = new byte[78];
            break;
        default:
            throw FormatException.getFormatInstance();
    }
    System.arraycopy(codewords, 0, datawords, 0, 10);
    System.arraycopy(codewords, 20, datawords, 10, datawords.length - 10);
    return DecodedBitStreamParser.decode(datawords, mode);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:27,代碼來源:Decoder.java

示例13: correctErrors

import com.google.zxing.ChecksumException; //導入依賴的package包/類
private void correctErrors(byte[] codewordBytes, int start, int dataCodewords, int
        ecCodewords, int mode) throws ChecksumException {
    int codewords = dataCodewords + ecCodewords;
    int divisor = mode == 0 ? 1 : 2;
    int[] codewordsInts = new int[(codewords / divisor)];
    int i = 0;
    while (i < codewords) {
        if (mode == 0 || i % 2 == mode - 1) {
            codewordsInts[i / divisor] = codewordBytes[i + start] & 255;
        }
        i++;
    }
    try {
        this.rsDecoder.decode(codewordsInts, ecCodewords / divisor);
        i = 0;
        while (i < dataCodewords) {
            if (mode == 0 || i % 2 == mode - 1) {
                codewordBytes[i + start] = (byte) codewordsInts[i / divisor];
            }
            i++;
        }
    } catch (ReedSolomonException e) {
        throw ChecksumException.getChecksumInstance();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:26,代碼來源:Decoder.java

示例14: decodeMultiple

import com.google.zxing.ChecksumException; //導入依賴的package包/類
@Override
public Result[] decodeMultiple(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException {
  try {
    return decode(image, hints, true);
  } catch (FormatException | ChecksumException ignored) {
    throw NotFoundException.getNotFoundInstance();
  }
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:9,代碼來源:PDF417Reader.java

示例15: createDecoderResult

import com.google.zxing.ChecksumException; //導入依賴的package包/類
private static DecoderResult createDecoderResult(DetectionResult detectionResult) throws FormatException,
    ChecksumException, NotFoundException {
  BarcodeValue[][] barcodeMatrix = createBarcodeMatrix(detectionResult);
  adjustCodewordCount(detectionResult, barcodeMatrix);
  Collection<Integer> erasures = new ArrayList<>();
  int[] codewords = new int[detectionResult.getBarcodeRowCount() * detectionResult.getBarcodeColumnCount()];
  List<int[]> ambiguousIndexValuesList = new ArrayList<>();
  List<Integer> ambiguousIndexesList = new ArrayList<>();
  for (int row = 0; row < detectionResult.getBarcodeRowCount(); row++) {
    for (int column = 0; column < detectionResult.getBarcodeColumnCount(); column++) {
      int[] values = barcodeMatrix[row][column + 1].getValue();
      int codewordIndex = row * detectionResult.getBarcodeColumnCount() + column;
      if (values.length == 0) {
        erasures.add(codewordIndex);
      } else if (values.length == 1) {
        codewords[codewordIndex] = values[0];
      } else {
        ambiguousIndexesList.add(codewordIndex);
        ambiguousIndexValuesList.add(values);
      }
    }
  }
  int[][] ambiguousIndexValues = new int[ambiguousIndexValuesList.size()][];
  for (int i = 0; i < ambiguousIndexValues.length; i++) {
    ambiguousIndexValues[i] = ambiguousIndexValuesList.get(i);
  }
  return createDecoderResultFromAmbiguousValues(detectionResult.getBarcodeECLevel(), codewords,
      PDF417Common.toIntArray(erasures), PDF417Common.toIntArray(ambiguousIndexesList), ambiguousIndexValues);
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:30,代碼來源:PDF417ScanningDecoder.java


注:本文中的com.google.zxing.ChecksumException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。