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


Java ReedSolomonDecoder.decode方法代码示例

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


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

示例1: removeECC

import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; //导入方法依赖的package包/类
private  byte[] removeECC(byte[] input) throws ReedSolomonException {
	if (input == null) {
		throw new IllegalArgumentException("The input to error correction code cannot be null");
	}
	if (input.length > maxBytes) {
		throw new IllegalArgumentException("The input to error correction code plus error correction bytes cannot be longer than 256");
	}
	int[] ints = new int[input.length];
	for (int i = 0; i < ints.length; i++) {
		ints[i] = input[i] & 0xFF;
	}
	ReedSolomonDecoder d = new ReedSolomonDecoder(gf);
	d.decode(ints, errorCorrectionBytes);
	byte[] result = new byte[input.length - errorCorrectionBytes];
	for (int i = 0; i < result.length; i++) {
		result[i] = (byte) ints[i];
	}
	return result;
}
 
开发者ID:Sector67,项目名称:one-time-pad-library,代码行数:20,代码来源:ErrorCorrectingBase16Encoder.java

示例2: getCorrectedParameterData

import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; //导入方法依赖的package包/类
/**
 * Corrects the parameter bits using Reed-Solomon algorithm.
 *
 * @param parameterData parameter bits
 * @param compact true if this is a compact Aztec code
 * @throws NotFoundException if the array contains too many errors
 */
private static int getCorrectedParameterData(long parameterData, boolean compact) throws NotFoundException {
  int numCodewords;
  int numDataCodewords;

  if (compact) {
    numCodewords = 7;
    numDataCodewords = 2;
  } else {
    numCodewords = 10;
    numDataCodewords = 4;
  }

  int numECCodewords = numCodewords - numDataCodewords;
  int[] parameterWords = new int[numCodewords];
  for (int i = numCodewords - 1; i >= 0; --i) {
    parameterWords[i] = (int) parameterData & 0xF;
    parameterData >>= 4;
  }
  try {
    ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(GenericGF.AZTEC_PARAM);
    rsDecoder.decode(parameterWords, numECCodewords);
  } catch (ReedSolomonException ignored) {
    throw NotFoundException.getNotFoundInstance();
  }
  // Toss the error correction.  Just return the data as an integer
  int result = 0;
  for (int i = 0; i < numDataCodewords; i++) {
    result = (result << 4) + parameterWords[i];
  }
  return result;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:39,代码来源:Detector.java

示例3: getCorrectedParameterData

import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; //导入方法依赖的package包/类
/**
 * Corrects the parameter bits using Reed-Solomon algorithm.
 *
 * @param parameterData parameter bits
 * @param compact       true if this is a compact Aztec code
 * @throws NotFoundException if the array contains too many errors
 */
private static int getCorrectedParameterData(long parameterData, boolean compact) throws NotFoundException {
    int numCodewords;
    int numDataCodewords;

    if (compact) {
        numCodewords = 7;
        numDataCodewords = 2;
    } else {
        numCodewords = 10;
        numDataCodewords = 4;
    }

    int numECCodewords = numCodewords - numDataCodewords;
    int[] parameterWords = new int[numCodewords];
    for (int i = numCodewords - 1; i >= 0; --i) {
        parameterWords[i] = (int) parameterData & 0xF;
        parameterData >>= 4;
    }
    try {
        ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(GenericGF.AZTEC_PARAM);
        rsDecoder.decode(parameterWords, numECCodewords);
    } catch (ReedSolomonException ignored) {
        throw NotFoundException.getNotFoundInstance();
    }
    // Toss the error correction.  Just return the data as an integer
    int result = 0;
    for (int i = 0; i < numDataCodewords; i++) {
        result = (result << 4) + parameterWords[i];
    }
    return result;
}
 
开发者ID:Ag47,项目名称:TrueTone,代码行数:39,代码来源:Detector.java

示例4: bitsReedSolomonDecode

import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; //导入方法依赖的package包/类
/** Decode using Reed-Solomon error correction (with n bytes at the end of bits). */
public static Bits bitsReedSolomonDecode(final Bits bits, final int n) throws ReedSolomonException {
    int[] data = new Bits(bits.getBits(0, bits.size() - n * 8)).getBytes();
    data = Arrays.copyOf(data, data.length + n);
    for (int i = 0; i < n; i++) {
        data[data.length - n + i] = (int) bits.getValue(bits.size() - n * 8 + i * 8, 8);
    }
    final ReedSolomonDecoder dec = new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256);
    dec.decode(data, n);
    final Bits result = new Bits();
    result.addBytes(Arrays.copyOf(data, data.length - n));
    return result;
}
 
开发者ID:neeti18,项目名称:dct-watermark,代码行数:14,代码来源:Bits.java

示例5: getCorrectedParameterData

import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; //导入方法依赖的package包/类
/**
 * Corrects the parameter bits using Reed-Solomon algorithm.
 *
 * @param parameterData parameter bits
 * @param compact true if this is a compact Aztec code
 * @throws com.google.zxing.NotFoundException if the array contains too many errors
 */
private static int getCorrectedParameterData(long parameterData, boolean compact) throws NotFoundException {
  int numCodewords;
  int numDataCodewords;

  if (compact) {
    numCodewords = 7;
    numDataCodewords = 2;
  } else {
    numCodewords = 10;
    numDataCodewords = 4;
  }

  int numECCodewords = numCodewords - numDataCodewords;
  int[] parameterWords = new int[numCodewords];
  for (int i = numCodewords - 1; i >= 0; --i) {
    parameterWords[i] = (int) parameterData & 0xF;
    parameterData >>= 4;
  }
  try {
    ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(GenericGF.AZTEC_PARAM);
    rsDecoder.decode(parameterWords, numECCodewords);
  } catch (ReedSolomonException ignored) {
    throw NotFoundException.getNotFoundInstance();
  }
  // Toss the error correction.  Just return the data as an integer
  int result = 0;
  for (int i = 0; i < numDataCodewords; i++) {
    result = (result << 4) + parameterWords[i];
  }
  return result;
}
 
开发者ID:bushidowallet,项目名称:bushido-android-app,代码行数:39,代码来源:Detector.java

示例6: onGaydecki

import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; //导入方法依赖的package包/类
/** Called when the samples have been updated. */
private static final void onGaydecki(final ReedSolomonDecoder pReedSolomonDecoder, final double[] pSamples, final double[] pConfidences, final int pSubsamples, final ChirpFactory.IListener pChirpListener) {
    // Calculate the Number of Symbols.
    final int    lSymbols      = (pSamples.length / pSubsamples);
    // Declare the String.
          String lAccumulation = "";
    // Iterate the Samples whilst we're building up the string.
    for(int i = 0; i < lSymbols && (lAccumulation.length() != MainActivity.FACTORY_CHIRP.getEncodedLength()); i++) {
        // Fetch the Offset for the next Symbol.
        final int lOffset = (i * pSubsamples);
        // Detect the Chirp.
        final ChirpFactory.Result lResult = ChirpFactory.DETECTOR_CHIRP_MEAN.getSymbol(MainActivity.FACTORY_CHIRP, pSamples, pConfidences, lOffset, pSubsamples);
        // Is the Result valid?
        if(lResult.isValid()) {
            // Buffer the Result's data into the Accumulation.
            lAccumulation += lResult.getCharacter();
        }
    }
    // Is the accumulated data long enough?
    if(lAccumulation.length() == MainActivity.FACTORY_CHIRP.getEncodedLength()) {
        // Declare the Packetized Representation.
        final int[] lPacketized = new int[MainActivity.FACTORY_CHIRP.getRange().getFrameLength()];
        // Buffer the Header/Payload.
        for(int i = 0; i < MainActivity.FACTORY_CHIRP.getIdentifier().length() + MainActivity.FACTORY_CHIRP.getPayloadLength(); i++) {
            // Update the Packetized with the corresponding index value.
            lPacketized[i] = MainActivity.FACTORY_CHIRP.getRange().getCharacters().indexOf(lAccumulation.charAt(i));
        }
        // Iterate the Error Symbols.
        for(int i = 0; i < MainActivity.FACTORY_CHIRP.getErrorLength(); i++) {
            // Update the Packetized with the corresponding index value.
            lPacketized[MainActivity.FACTORY_CHIRP.getRange().getFrameLength() - MainActivity.FACTORY_CHIRP.getErrorLength() + i] = MainActivity.FACTORY_CHIRP.getRange().getCharacters().indexOf(lAccumulation.charAt(MainActivity.FACTORY_CHIRP.getIdentifier().length() + MainActivity.FACTORY_CHIRP.getPayloadLength() + i));
        }
        // Attempt to Reed/Solomon Decode.
        try {
            // Decode the Sample.
            pReedSolomonDecoder.decode(lPacketized, MainActivity.FACTORY_CHIRP.getErrorLength());
            // Declare the search metric.
            boolean lIsValid = true;
            // Iterate the Identifier characters.
            for(int i = 0; i < MainActivity.FACTORY_CHIRP.getIdentifier().length(); i++) {
                // Update the search metric.
                lIsValid &= MainActivity.FACTORY_CHIRP.getIdentifier().charAt(i) == (MainActivity.FACTORY_CHIRP.getRange().getCharacters().charAt(lPacketized[i]));
            }
            // Is the message directed to us?
            if(lIsValid) {
                // Fetch the Message data.
                String lMessage = "";
                // Iterate the Packet.
                for(int i = MainActivity.FACTORY_CHIRP.getIdentifier().length(); i < MainActivity.FACTORY_CHIRP.getIdentifier().length() + MainActivity.FACTORY_CHIRP.getPayloadLength(); i++) {
                    // Accumulate the Message.
                    lMessage += MainActivity.FACTORY_CHIRP.getRange().getCharacters().charAt(lPacketized[i]);
                }
                // Call the callback.
                pChirpListener.onChirp(lMessage);
            }
        }
        catch(final ReedSolomonException pReedSolomonException) { /* Do nothing; we're transmitting across a very lossy channel! */ }
    }
}
 
开发者ID:Cawfree,项目名称:OpenChirp,代码行数:60,代码来源:MainActivity.java


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