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


Java ReaderException类代码示例

本文整理汇总了Java中com.google.zxing.ReaderException的典型用法代码示例。如果您正苦于以下问题:Java ReaderException类的具体用法?Java ReaderException怎么用?Java ReaderException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: processImage

import com.google.zxing.ReaderException; //导入依赖的package包/类
public IAnswerData processImage(Image image)
        throws ImageProcessingException {
    MonochromeBitmapSource source = new LCDUIImageMonochromeBitmapSource(
            image);
    Reader reader = new QRCodeReader();
    Hashtable hints = new Hashtable();
    // hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);

    try {
        Result result = reader.decode(source, hints);
        if ((result != null) && (result.getText() != null)) {
            String scannedCode = result.getText();
            return new StringData(scannedCode);
        } else {
            throw new ImageProcessingException("Barcode scanning failed");
        }
    } catch (ReaderException re) {
        throw new ImageProcessingException("Barcode scanning failed");
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:21,代码来源:ZXingBarcodeProcessingService.java

示例2: detectMulti

import com.google.zxing.ReaderException; //导入依赖的package包/类
public DetectorResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException {
  BitMatrix image = getImage();
  ResultPointCallback resultPointCallback =
      hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
  MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback);
  FinderPatternInfo[] infos = finder.findMulti(hints);

  if (infos.length == 0) {
    throw NotFoundException.getNotFoundInstance();
  }

  List<DetectorResult> result = new ArrayList<>();
  for (FinderPatternInfo info : infos) {
    try {
      result.add(processFinderPatternInfo(info));
    } catch (ReaderException e) {
      // ignore
    }
  }
  if (result.isEmpty()) {
    return EMPTY_DETECTOR_RESULTS;
  } else {
    return result.toArray(new DetectorResult[result.size()]);
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:26,代码来源:MultiDetector.java

示例3: decodeWithZxing

import com.google.zxing.ReaderException; //导入依赖的package包/类
public String decodeWithZxing(byte[] data, int width, int height, Rect crop) {
    MultiFormatReader multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(changeZXingDecodeDataMode());

    Result rawResult = null;
    PlanarYUVLuminanceSource source = new PlanarYUVLuminanceSource(data, width, height,
            crop.left, crop.top, crop.width(), crop.height(), false);

    if (source != null) {
        BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
        try {
            rawResult = multiFormatReader.decodeWithState(bitmap);
        } catch (ReaderException re) {
            // continue
        } finally {
            multiFormatReader.reset();
        }
    }

    return rawResult != null ? rawResult.getText() : null;
}
 
开发者ID:snice,项目名称:androidscan,代码行数:22,代码来源:DecodeUtils.java

示例4: decodeWithZxing

import com.google.zxing.ReaderException; //导入依赖的package包/类
public Result decodeWithZxing(Bitmap bitmap) {
    MultiFormatReader multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(changeZXingDecodeDataMode());

    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    int[] pixels = new int[width * height];
    bitmap.getPixels(pixels, 0, width, 0, 0, width, height);

    Result rawResult = null;
    RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels);

    BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source));
    try {
        rawResult = multiFormatReader.decodeWithState(binaryBitmap);
    } catch (ReaderException re) {
        // continue
    } finally {
        multiFormatReader.reset();
    }

    return rawResult;
}
 
开发者ID:absentm,项目名称:myapplication,代码行数:24,代码来源:DecodeUtils.java

示例5: doInBackground

import com.google.zxing.ReaderException; //导入依赖的package包/类
@Override
protected Result doInBackground(Void... params) {
	BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(luminanceSource));
	Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(3);
	hints.put(DecodeHintType.CHARACTER_SET, "UTF-8");
	hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, listener);
	MultiFormatReader multiFormatReader = new MultiFormatReader();
	multiFormatReader.setHints(hints);
	long start = System.currentTimeMillis();
	Result rawResult = null;
	try {
		rawResult = multiFormatReader.decodeWithState(bitmap);
		mBitmap = luminanceSource.renderCroppedGreyScaleBitmap();
		long end = System.currentTimeMillis();
		Log.d("DecodeThread", "Decode use " + (end - start) + "ms");
	} catch (ReaderException re) {
	} finally {
		multiFormatReader.reset();
	}
	return rawResult;
}
 
开发者ID:Revival-liangjialiang,项目名称:ShoppingApp,代码行数:22,代码来源:DecodeThread.java

示例6: detectMulti

import com.google.zxing.ReaderException; //导入依赖的package包/类
public DetectorResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException {
  BitMatrix image = getImage();
  ResultPointCallback resultPointCallback =
      hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
  MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback);
  FinderPatternInfo[] infos = finder.findMulti(hints);

  if (infos.length == 0) {
    throw NotFoundException.getNotFoundInstance();
  }

  List<DetectorResult> result = new ArrayList<DetectorResult>();
  for (FinderPatternInfo info : infos) {
    try {
      result.add(processFinderPatternInfo(info));
    } catch (ReaderException e) {
      // ignore
    }
  }
  if (result.isEmpty()) {
    return EMPTY_DETECTOR_RESULTS;
  } else {
    return result.toArray(new DetectorResult[result.size()]);
  }
}
 
开发者ID:atomsheep,项目名称:sres-app,代码行数:26,代码来源:MultiDetector.java

示例7: checkFormat

import com.google.zxing.ReaderException; //导入依赖的package包/类
private void checkFormat(File file, BarcodeFormat format) throws IOException {
    Reader reader = new MultiFormatReader();
    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(ImageIO.read(file))));
    Result result;
    try {
        result = reader.decode(bitmap);
    } catch (ReaderException ex) {
        throw new IOException(ex);
    }
    
    assertEquals(format, result.getBarcodeFormat());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:BarcodeTestBase.java

示例8: detectMulti

import com.google.zxing.ReaderException; //导入依赖的package包/类
public DetectorResult[] detectMulti(Map<DecodeHintType, ?> hints) throws NotFoundException {
    BitMatrix image = getImage();
    ResultPointCallback resultPointCallback =
            hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
    MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback);
    FinderPatternInfo[] infos = finder.findMulti(hints);

    if (infos.length == 0) {
        throw NotFoundException.getNotFoundInstance();
    }

    List<DetectorResult> result = new ArrayList<>();
    for (FinderPatternInfo info : infos) {
        try {
            result.add(processFinderPatternInfo(info));
        } catch (ReaderException e) {
            // ignore
        }
    }
    if (result.isEmpty()) {
        return EMPTY_DETECTOR_RESULTS;
    } else {
        return result.toArray(new DetectorResult[result.size()]);
    }
}
 
开发者ID:Ag47,项目名称:TrueTone,代码行数:26,代码来源:MultiDetector.java

示例9: detectMulti

import com.google.zxing.ReaderException; //导入依赖的package包/类
public DetectorResult[] detectMulti(Map<DecodeHintType, ?> hints) throws NotFoundException {
    BitMatrix image = getImage();
    ResultPointCallback resultPointCallback =
            hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
    MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback);
    FinderPatternInfo[] infos = finder.findMulti(hints);

    if (infos.length == 0) {
        throw NotFoundException.getNotFoundInstance();
    }

    List<DetectorResult> result = new ArrayList<DetectorResult>();
    for (FinderPatternInfo info : infos) {
        try {
            result.add(processFinderPatternInfo(info));
        } catch (ReaderException e) {
            // ignore
        }
    }
    if (result.isEmpty()) {
        return EMPTY_DETECTOR_RESULTS;
    } else {
        return result.toArray(new DetectorResult[result.size()]);
    }
}
 
开发者ID:yakovenkodenis,项目名称:Discounty,代码行数:26,代码来源:MultiDetector.java

示例10: decode

import com.google.zxing.ReaderException; //导入依赖的package包/类
private String decode(byte[] data, int width, int height) {
    ScannerManager manager = mManager.get();
    if (manager == null) {
        return null;
    }
    Rect rect = manager.getFramingRectInPreview();
    PlanarYUVLuminanceSource source = new PlanarYUVLuminanceSource(data,
            width, height, rect.left, rect.top, rect.right, rect.bottom, false);
    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
    QRCodeReader reader = new QRCodeReader();
    try {
        Result result = reader.decode(bitmap, mHints);
        return result.getText();
    } catch (ReaderException e) {
        // Ignore as we will repeatedly decode the preview frame
        return null;
    }
}
 
开发者ID:googlesamples,项目名称:attendee-checkin,代码行数:19,代码来源:ScannerManager.java

示例11: testFlowWithSetKeyData

import com.google.zxing.ReaderException; //导入依赖的package包/类
public void testFlowWithSetKeyData() {
    for (int i = 0; i < groupKeyList.size(); i++) {
        Bitmap bmp = qrReaderWriter.createQrCode(cipher, groupKeyList.get(i), Instant.now(), 200, 200);

        try {
            Result decoded = QRReaderWriterTests.decodePureBitmap(bmp);
            String temporary = decoded.getText();
            GroupQRReaderWriter.ScannedGroupKey key = qrReaderWriter.parseCode(temporary, cipher);
            SecretKey result = cipher.byteArrayToSecretKey(key.getKey().getEncoded());
            assertEquals("Key #" + i + " was not recognized : ", groupKeyList.get(i), result);
        } catch (ReaderException e) {
            Log.d("KeyToImageAndBackTests", "Key #" + i + " was ignored due to a Reader Error");
            keyIgnoredCounter[i]++;
        }
    }
}
 
开发者ID:timberdoodle,项目名称:TimberdoodleApp,代码行数:17,代码来源:KeyToImageAndBackTests.java

示例12: assertCorrectImage2binary

import com.google.zxing.ReaderException; //导入依赖的package包/类
private static void assertCorrectImage2binary(String fileName, String expected)
    throws IOException, NotFoundException {
  Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName);

  BufferedImage image = ImageIO.read(path.toFile());
  BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
  int rowNumber = binaryMap.getHeight() / 2;
  BitArray row = binaryMap.getBlackRow(rowNumber, null);

  List<ExpandedPair> pairs;
  try {
    RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
    pairs = rssExpandedReader.decodeRow2pairs(rowNumber, row);
  } catch (ReaderException re) {
    fail(re.toString());
    return;
  }
  BitArray binary = BitArrayBuilder.buildBitArray(pairs);
  assertEquals(expected, binary.toString());
}
 
开发者ID:srowen,项目名称:zxing-bsplus,代码行数:21,代码来源:RSSExpandedImage2binaryTestCase.java

示例13: assertCorrectImage2string

import com.google.zxing.ReaderException; //导入依赖的package包/类
private static void assertCorrectImage2string(String fileName, String expected)
    throws IOException, NotFoundException {
  Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName);

  BufferedImage image = ImageIO.read(path.toFile());
  BinaryBitmap binaryMap =
      new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
  int rowNumber = binaryMap.getHeight() / 2;
  BitArray row = binaryMap.getBlackRow(rowNumber, null);

  Result result;
  try {
    RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
    result = rssExpandedReader.decodeRow(rowNumber, row, null);
  } catch (ReaderException re) {
    fail(re.toString());
    return;
  }

  assertSame(BarcodeFormat.RSS_EXPANDED, result.getBarcodeFormat());
  assertEquals(expected, result.getText());
}
 
开发者ID:srowen,项目名称:zxing-bsplus,代码行数:23,代码来源:RSSExpandedImage2stringTestCase.java

示例14: assertCorrectImage2result

import com.google.zxing.ReaderException; //导入依赖的package包/类
private static void assertCorrectImage2result(String fileName, ExpandedProductParsedResult expected)
    throws IOException, NotFoundException {
  Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName);

  BufferedImage image = ImageIO.read(path.toFile());
  BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
  int rowNumber = binaryMap.getHeight() / 2;
  BitArray row = binaryMap.getBlackRow(rowNumber, null);

  Result theResult;
  try {
    RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
    theResult = rssExpandedReader.decodeRow(rowNumber, row, null);
  } catch (ReaderException re) {
    fail(re.toString());
    return;
  }

  assertSame(BarcodeFormat.RSS_EXPANDED, theResult.getBarcodeFormat());

  ParsedResult result = ResultParser.parseResult(theResult);

  assertEquals(expected, result);
}
 
开发者ID:srowen,项目名称:zxing-bsplus,代码行数:25,代码来源:RSSExpandedImage2resultTestCase.java


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