热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

com.google.zxing.qrcode.QRCodeReader类的使用及代码示例

本文整理了Java中com.google.zxing.qrcode.QRCodeReader类的一些代码示例,展示了QRCodeReader类

本文整理了Java中com.google.zxing.qrcode.QRCodeReader类的一些代码示例,展示了QRCodeReader类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QRCodeReader类的具体详情如下:
包路径:com.google.zxing.qrcode.QRCodeReader
类名称: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 = new 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 = new HashMap<>();
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 = new HashMap<>();
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 = new HashMap<>();
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;
}

推荐阅读
  • 本文详细介绍了GetModuleFileName函数的用法,该函数可以用于获取当前模块所在的路径,方便进行文件操作和读取配置信息。文章通过示例代码和详细的解释,帮助读者理解和使用该函数。同时,还提供了相关的API函数声明和说明。 ... [详细]
  • 1,关于死锁的理解死锁,我们可以简单的理解为是两个线程同时使用同一资源,两个线程又得不到相应的资源而造成永无相互等待的情况。 2,模拟死锁背景介绍:我们创建一个朋友 ... [详细]
  • 《数据结构》学习笔记3——串匹配算法性能评估
    本文主要讨论串匹配算法的性能评估,包括模式匹配、字符种类数量、算法复杂度等内容。通过借助C++中的头文件和库,可以实现对串的匹配操作。其中蛮力算法的复杂度为O(m*n),通过随机取出长度为m的子串作为模式P,在文本T中进行匹配,统计平均复杂度。对于成功和失败的匹配分别进行测试,分析其平均复杂度。详情请参考相关学习资源。 ... [详细]
  • 个人学习使用:谨慎参考1Client类importcom.thoughtworks.gauge.Step;importcom.thoughtworks.gauge.T ... [详细]
  • [大整数乘法] java代码实现
    本文介绍了使用java代码实现大整数乘法的过程,同时也涉及到大整数加法和大整数减法的计算方法。通过分治算法来提高计算效率,并对算法的时间复杂度进行了研究。详细代码实现请参考文章链接。 ... [详细]
  • 本文介绍了南邮ctf-web的writeup,包括签到题和md5 collision。在CTF比赛和渗透测试中,可以通过查看源代码、代码注释、页面隐藏元素、超链接和HTTP响应头部来寻找flag或提示信息。利用PHP弱类型,可以发现md5('QNKCDZO')='0e830400451993494058024219903391'和md5('240610708')='0e462097431906509019562988736854'。 ... [详细]
  • 模板引擎StringTemplate的使用方法和特点
    本文介绍了模板引擎StringTemplate的使用方法和特点,包括强制Model和View的分离、Lazy-Evaluation、Recursive enable等。同时,还介绍了StringTemplate语法中的属性和普通字符的使用方法,并提供了向模板填充属性的示例代码。 ... [详细]
  • GreenDAO快速入门
    前言之前在自己做项目的时候,用到了GreenDAO数据库,其实对于数据库辅助工具库从OrmLite,到litePal再到GreenDAO,总是在不停的切换,但是没有真正去了解他们的 ... [详细]
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • http:my.oschina.netleejun2005blog136820刚看到群里又有同学在说HTTP协议下的Get请求参数长度是有大小限制的,最大不能超过XX ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
  • 动态规划算法的基本步骤及最长递增子序列问题详解
    本文详细介绍了动态规划算法的基本步骤,包括划分阶段、选择状态、决策和状态转移方程,并以最长递增子序列问题为例进行了详细解析。动态规划算法的有效性依赖于问题本身所具有的最优子结构性质和子问题重叠性质。通过将子问题的解保存在一个表中,在以后尽可能多地利用这些子问题的解,从而提高算法的效率。 ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • 猜字母游戏
    猜字母游戏猜字母游戏——设计数据结构猜字母游戏——设计程序结构猜字母游戏——实现字母生成方法猜字母游戏——实现字母检测方法猜字母游戏——实现主方法1猜字母游戏——设计数据结构1.1 ... [详细]
  • 前景:当UI一个查询条件为多项选择,或录入多个条件的时候,比如查询所有名称里面包含以下动态条件,需要模糊查询里面每一项时比如是这样一个数组条件:newstring[]{兴业银行, ... [详细]
author-avatar
手机用户2502941301
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有