本文整理了Java中com.google.zxing.qrcode.QRCodeReader
类的一些代码示例,展示了QRCodeReader
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QRCodeReader
类的具体详情如下:
包路径:com.google.zxing.qrcode.QRCodeReader
类名称:QRCodeReader
[英]This implementation can detect and decode QR Codes in an image.
[中]这种实现可以检测和解码图像中的二维码。
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(
rgbLuminanceSource));
QRCodeReader qrCodeReader = new QRCodeReader();
HashMap
decodeHintTypeStringHashMap.put(DecodeHintType.CHARACTER_SET, "utf-8");
Result result = qrCodeReader.decode(binaryBitmap,
decodeHintTypeStringHashMap);
String url = result.getText();
代码示例来源:origin: helloworld1/FreeOTPPlus
public ScanAsyncTask() {
mBlockingQueue = new LinkedBlockingQueue(5);
mReader = new QRCodeReader();
}
代码示例来源:origin: jenly1314/ZXingLite
QRCodeReader reader = new QRCodeReader();
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
try {
result = reader.decode(bitmap,hints);
} catch (Exception e) {//解析失败则通过GlobalHistogramBinarizer 再试一次
BinaryBitmap bitmap1 = new BinaryBitmap(new GlobalHistogramBinarizer(source));
try {
result = reader.decode(bitmap1);
} catch (NotFoundException ne) {
reader.reset();
代码示例来源:origin: Gutyn/camera2QRcodeReader
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
rawResult = mQrReader.decode(bitmap);
onQRCodeRead(rawResult.getText());
} catch (ReaderException ignored) {
ex.printStackTrace();
} finally {
mQrReader.reset();
Log.e(TAG, "in the finally! ------------");
if (img != null)
代码示例来源:origin: iluhcm/QrCodeScanner
/**
* Locates and decodes a QR code in an image.
*
* @return a String representing the content encoded by the QR code
* @throws NotFoundException if a QR code cannot be found
* @throws FormatException if a QR code cannot be decoded
* @throws ChecksumException if error correction fails
*/
@Override
public Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException {
return decode(image, null);
}
代码示例来源:origin: joelind/zxing-iphone
public Result decode(BinaryBitmap image, Hashtable 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, hints);
points = NO_POINTS;
} else {
DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(hints);
decoderResult = decoder.decode(detectorResult.getBits(), hints);
points = detectorResult.getPoints();
}
Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.QR_CODE);
if (decoderResult.getByteSegments() != null) {
result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, decoderResult.getByteSegments());
}
if (decoderResult.getECLevel() != null) {
result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.getECLevel().toString());
}
return result;
}
代码示例来源:origin: joelind/zxing-iphone
public Result decode(BinaryBitmap image, Hashtable hints)
throws NotFoundException, FormatException {
DecoderResult decoderResult;
ResultPoint[] points;
if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) {
BitMatrix bits = QRCodeReader.extractPureBits(image.getBlackMatrix());
decoderResult = decoder.decode(bits);
points = NO_POINTS;
} else {
DetectorResult detectorResult = new Detector(image).detect();
decoderResult = decoder.decode(detectorResult.getBits());
points = detectorResult.getPoints();
}
return new Result(decoderResult.getText(), decoderResult.getRawBytes(), points,
BarcodeFormat.PDF417);
}
代码示例来源:origin: stackoverflow.com
String b64_data = dataUrl.substring("data:image/gif;base64,".length());
byte[] bin_data = Base64.decodeBase64(b64_data);
BufferedImage image = GifDecoder.read(bin_data).getFrame(0);
LuminanceSource source = new BufferedImageLuminanceSource(image)
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source));
Map
hints.put(DecodeHintType.PURE_BARCODE, true);
Result result = new QRCodeReader().decode(binaryBitmap, hints);
代码示例来源:origin: openwalletGH/openwallet-android
final Result scanResult = reader.decode(bitmap, hints);
reader.reset();
代码示例来源:origin: simplezhli/Tesseract-OCR-Scanner
/**
* Locates and decodes a QR code in an image.
*
* @return a String representing the content encoded by the QR code
* @throws NotFoundException if a QR code cannot be found
* @throws FormatException if a QR code cannot be decoded
* @throws ChecksumException if error correction fails
*/
@Override
public Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException {
return decode(image, null);
}
代码示例来源:origin: simplezhli/Tesseract-OCR-Scanner
ResultPoint[] points;
if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) {
BitMatrix bits = extractPureBits(image.getBlackMatrix());
decoderResult = decoder.decode(bits, hints);
points = NO_POINTS;
代码示例来源:origin: cloudfoundry/uaa
private String decodeQrPng(String encodedQrCode) throws IOException, NotFoundException, ChecksumException, FormatException {
byte[] decodedByte = Base64.getDecoder().decode(encodedQrCode);
BufferedImage image = ImageIO.read(new ByteArrayInputStream(decodedByte));
BufferedImageLuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
QRCodeReader reader = new QRCodeReader();
Map
hintMap.put(DecodeHintType.PURE_BARCODE, true);
return reader.decode(bitmap, hintMap).getText();
}
代码示例来源:origin: stackoverflow.com
private Result readQRCode(BufferedImage bi){
BinaryBitmap binaryBitmap;
Result result;
try{
binaryBitmap = new BinaryBitmap( new HybridBinarizer(new BufferedImageLuminanceSource( bi )));
result = new QRCodeReader().decode(binaryBitmap);
return result;
}catch(Exception ex){
ex.printStackTrace();
return null;
}
}
代码示例来源:origin: Coinomi/coinomi-android
final Result scanResult = reader.decode(bitmap, hints);
reader.reset();
代码示例来源:origin: iluhcm/QrCodeScanner
ResultPoint[] points;
if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) {
BitMatrix bits = extractPureBits(image.getBlackMatrix());
decoderResult = decoder.decode(bits, hints);
points = NO_POINTS;
代码示例来源:origin: cloudfoundry/uaa
private String qrCodeText(String dataUrl) throws Exception {
QRCodeReader reader = new QRCodeReader();
String[] rawSplit = dataUrl.split(",");
assertEquals("data:image/png;base64", rawSplit[0]);
byte[] decodedByte = Base64.getDecoder().decode(rawSplit[1]);
BufferedImage image = ImageIO.read(new ByteArrayInputStream(decodedByte));
BufferedImageLuminanceSource source = new BufferedImageLuminanceSource(image);
Map
hintMap.put(DecodeHintType.PURE_BARCODE, true);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
return reader.decode(bitmap, hintMap).getText();
}
代码示例来源:origin: stackoverflow.com
@Override
public void surfaceCreated(SurfaceHolder holder) {
boolean useFlash = true;
try {
// Indicate camera, our View dimensions
mCameraManager.openDriver(holder,this.getWidth(),this.getHeight());
} catch (IOException e) {
Log.w(TAG, "Can not openDriver: "+e.getMessage());
mCameraManager.closeDriver();
}
try {
mQRCodeReader = new QRCodeReader();
if (useFlash){
Parameters p = cam.getParameters();
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
mCameraManager.setParameters(p);
}
mCameraManager.startPreview();
} catch (Exception e) {
Log.e(TAG, "Exception: " + e.getMessage());
mCameraManager.closeDriver();
}
}
代码示例来源:origin: stackoverflow.com
Bitmap b = ...;//TODO: create a bitmap from your source...
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(new RGBLuminanceSource(b)));
Result result = null;
QRCodeReader reader = new QRCodeReader();
try {
result = reader.decode(bitmap);
ParsedResult parsedResult = ResultParser.parseResult(result);
//TODO: use parsedResult
}
catch(OutOfMemoryError e) {
}
catch(Exception e) {
}
代码示例来源:origin: stackoverflow.com
// Decodes like this works perfectly
LuminanceSource ls = new BufferedImageLuminanceSource(encodedBufferedImage);
Result result = new QRCodeReader().decode(new BinaryBitmap( new HybridBinarizer(ls)));
Vector byteSegments = (Vector) result.getResultMetadata().get(ResultMetadataType.BYTE_SEGMENTS);
int i = 0;
int tam = 0;
for (Object o : byteSegments) {
byte[] bs = (byte[])o;
tam += bs.length;
}
byte[] resultBytes = new byte[tam];
i = 0;
for (Object o : byteSegments) {
byte[] bs = (byte[])o;
for (byte b : bs) {
resultBytes[i++] = b;
}
}
return resultBytes;
代码示例来源:origin: stackoverflow.com
public static String qrDecodeFromImage(BufferedImage img) {
if(img!=null) {
LuminanceSource bfImgLuminanceSource = new BufferedImageLuminanceSource(img);
BinaryBitmap binaryBmp = new BinaryBitmap(new HybridBinarizer(bfImgLuminanceSource));
QRCodeReader qrReader = new QRCodeReader();
Result result;
try {
result = qrReader.decode(binaryBmp);
return result.getText();
} catch (NotFoundException e) {} catch (ChecksumException e) {} catch (FormatException e) {}
}
return null;
}