本文整理汇总了Java中com.google.zxing.multi.GenericMultipleBarcodeReader类的典型用法代码示例。如果您正苦于以下问题:Java GenericMultipleBarcodeReader类的具体用法?Java GenericMultipleBarcodeReader怎么用?Java GenericMultipleBarcodeReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenericMultipleBarcodeReader类属于com.google.zxing.multi包,在下文中一共展示了GenericMultipleBarcodeReader类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: multiple
import com.google.zxing.multi.GenericMultipleBarcodeReader; //导入依赖的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: decodeMulti
import com.google.zxing.multi.GenericMultipleBarcodeReader; //导入依赖的package包/类
private Result[] decodeMulti(URI uri, Map<DecodeHintType,?> hints) throws IOException {
BufferedImage image;
try {
image = ImageIO.read(uri.toURL());
} catch (IllegalArgumentException iae) {
throw new FileNotFoundException("Resource not found: " + uri);
}
if (image == null) {
System.err.println(uri.toString() + ": Could not load image");
return null;
}
try {
LuminanceSource source;
if (config.getCrop() == null) {
source = new BufferedImageLuminanceSource(image);
} else {
int[] crop = config.getCrop();
source = new BufferedImageLuminanceSource(image, crop[0], crop[1], crop[2], crop[3]);
}
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
if (config.isDumpBlackPoint()) {
dumpBlackPoint(uri, image, bitmap);
}
MultiFormatReader multiFormatReader = new MultiFormatReader();
GenericMultipleBarcodeReader reader = new GenericMultipleBarcodeReader(
multiFormatReader);
Result[] results = reader.decodeMultiple(bitmap, hints);
if (config.isBrief()) {
System.out.println(uri.toString() + ": Success");
} else {
for (Result result : results) {
ParsedResult parsedResult = ResultParser.parseResult(result);
System.out.println(uri.toString() + " (format: "
+ result.getBarcodeFormat() + ", type: "
+ parsedResult.getType() + "):\nRaw result:\n"
+ result.getText() + "\nParsed result:\n"
+ parsedResult.getDisplayResult());
System.out.println("Found " + result.getResultPoints().length + " result points.");
for (int i = 0; i < result.getResultPoints().length; i++) {
ResultPoint rp = result.getResultPoints()[i];
System.out.println(" Point " + i + ": (" + rp.getX() + ',' + rp.getY() + ')');
}
}
}
return results;
} catch (NotFoundException nfe) {
System.out.println(uri.toString() + ": No barcode found");
return null;
}
}
开发者ID:da-baumann,项目名称:dev,代码行数:53,代码来源:DecodeThread.java
注:本文中的com.google.zxing.multi.GenericMultipleBarcodeReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论