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


Java MultipleBarcodeReader类代码示例

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


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

示例1: multiple

import com.google.zxing.multi.MultipleBarcodeReader; //导入依赖的package包/类
/**
 * Decode all barcodes in the image
 */
private String multiple(BufferedImage img) throws NotFoundException, ChecksumException, FormatException {
	long begin = System.currentTimeMillis();
	LuminanceSource source = new BufferedImageLuminanceSource(img);
	BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
	com.google.zxing.Reader reader = new MultiFormatReader();
	MultipleBarcodeReader bcReader = new GenericMultipleBarcodeReader(reader);
	Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();
	hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
	StringBuilder sb = new StringBuilder();

	for (Result result : bcReader.decodeMultiple(bitmap, hints)) {
		sb.append(result.getText()).append(" ");
	}

	SystemProfiling.log(null, System.currentTimeMillis() - begin);
	log.trace("multiple.Time: {}", System.currentTimeMillis() - begin);
	return sb.toString();
}
 
开发者ID:openkm,项目名称:document-management-system,代码行数:22,代码来源:BarcodeTextExtractor.java

示例2: testMultiQRCodes

import com.google.zxing.multi.MultipleBarcodeReader; //导入依赖的package包/类
@Test
public void testMultiQRCodes() throws Exception {
  // Very basic test for now
  Path testBase = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/multi-qrcode-1");

  Path testImage = testBase.resolve("1.png");
  BufferedImage image = ImageIO.read(testImage.toFile());
  LuminanceSource source = new BufferedImageLuminanceSource(image);
  BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));

  MultipleBarcodeReader reader = new QRCodeMultiReader();
  Result[] results = reader.decodeMultiple(bitmap);
  assertNotNull(results);
  assertEquals(4, results.length);

  Set<String> barcodeContents = new HashSet<>();
  for (Result result : results) {
    barcodeContents.add(result.getText());
    assertEquals(BarcodeFormat.QR_CODE, result.getBarcodeFormat());
    Map<ResultMetadataType,Object> metadata = result.getResultMetadata();
    assertNotNull(metadata);
  }
  Set<String> expectedContents = new HashSet<>();
  expectedContents.add("You earned the class a 5 MINUTE DANCE PARTY!!  Awesome!  Way to go!  Let's boogie!");
  expectedContents.add("You earned the class 5 EXTRA MINUTES OF RECESS!!  Fabulous!!  Way to go!!");
  expectedContents.add("You get to SIT AT MRS. SIGMON'S DESK FOR A DAY!!  Awesome!!  Way to go!! Guess I better clean up! :)");
  expectedContents.add("You get to CREATE OUR JOURNAL PROMPT FOR THE DAY!  Yay!  Way to go!  ");
  assertEquals(expectedContents, barcodeContents);
}
 
开发者ID:srowen,项目名称:zxing-bsplus,代码行数:30,代码来源:MultiQRCodeTestCase.java


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