當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。