/** * Decode a binary bitmap. * * @param bitmap the binary bitmap * @return a Result or null */ protected Result decode(BinaryBitmap bitmap) { possibleResultPoints.clear(); try { if (reader instanceof MultiFormatReader) { // Optimization - MultiFormatReader's normal decode() method is slow. return ((MultiFormatReader) reader).decodeWithState(bitmap); } else { return reader.decode(bitmap); } } catch (Exception e) { // Decode error, try again next frame return null; } finally { reader.reset(); } }
rawResult = multiFormatReader.decodeWithState(new BinaryBitmap(new HybridBinarizer(new BitmapLuminanceSource(mBitmap)))); } catch (Exception e) { e.printStackTrace();
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); try { rawResult = multiFormatReader.decodeWithState(bitmap); } catch (ReaderException re) {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); try { rawResult = multiFormatReader.decodeWithState(bitmap); } catch (ReaderException re) {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); try { rawResult = multiFormatReader.decodeWithState(bitmap); } catch (ReaderException re) {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); try { rawResult = multiFormatReader.decodeWithState(bitmap); } catch (ReaderException re) { source = CameraManager.get().buildLuminanceSource(data, height, width); bitmap = new BinaryBitmap(new HybridBinarizer(source)); rawResult = multiFormatReader.decodeWithState(bitmap); } catch (Exception e) { multiFormatReader.reset();
MultiFormatReader mReader = new MultiFormatReader(); Map<DecodeHintType,Object> hints = new EnumMap<DecodeHintType,Object>(DecodeHintType.class); hints.put(DecodeHintType.TRY_HARDER, true); // select your barcode formats here List<BarcodeFormat> formats = Arrays.asList(BarcodeFormat.QR_CODE); hints.put(DecodeHintType.POSSIBLE_FORMATS, formats); mReader.setHints(hints); // your camera image here Bitmap input; int width = input.getWidth(), height = input.getHeight(); int[] pixels = new int[width * height]; input.getPixels(pixels, 0, width, 0, 0, width, height); input.recycle(); input = null; BinaryBitmap bb = new BinaryBitmap(new HybridBinarizer(new RGBLuminanceSource(width, height, pixels))); Result result = mReader.decodeWithState(bb); String resultString = result.getText();
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); try { rawResult = multiFormatReader.decodeWithState(bitmap); } catch (ReaderException re) {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); try { rawResult = multiFormatReader.decodeWithState(bitmap); } catch (ReaderException re) {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); try { rawResult = multiFormatReader.decodeWithState(bitmap); } catch (ReaderException re) {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); try { rawResult = multiFormatReader.decodeWithState(bitmap); } catch (ReaderException re) {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); try { rawResult = multiFormatReader.decodeWithState(bitmap); } catch (ReaderException re) {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); try { rawResult = multiFormatReader.decodeWithState(bitmap); } catch (ReaderException re) {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); try { rawResult = multiFormatReader.decodeWithState(bitmap); } catch (ReaderException re) {
@Override public String processData(byte[] data, int width, int height, boolean isRetry) { String result = null; Result rawResult = null; try { PlanarYUVLuminanceSource source = null; Rect rect = mScanBoxView.getScanBoxAreaRect(height); if (rect != null) { source = new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top, rect.width(), rect.height(), false); } else { source = new PlanarYUVLuminanceSource(data, width, height, 0, 0, width, height, false); } rawResult = mMultiFormatReader.decodeWithState(new BinaryBitmap(new HybridBinarizer(source))); } catch (Exception e) { e.printStackTrace(); } finally { mMultiFormatReader.reset(); } if (rawResult != null) { result = rawResult.getText(); } return result; } }
@Override public String processData(byte[] data, int width, int height, boolean isRetry) { String result = null; Result rawResult = null; try { PlanarYUVLuminanceSource source = null; Rect rect = mScanBoxView.getScanBoxAreaRect(height); if (rect != null) { source = new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top, rect.width(), rect.height(), false); } else { source = new PlanarYUVLuminanceSource(data, width, height, 0, 0, width, height, false); } rawResult = mMultiFormatReader.decodeWithState(new BinaryBitmap(new HybridBinarizer(source))); } catch (Exception e) { e.printStackTrace(); } finally { mMultiFormatReader.reset(); } if (rawResult != null) { result = rawResult.getText(); } return result; } }
@Override public String processData(byte[] data, int width, int height, boolean isRetry) { String result = null; Result rawResult = null; try { PlanarYUVLuminanceSource source = null; Rect rect = mScanBoxView.getScanBoxAreaRect(height); if (rect != null) { source = new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top, rect.width(), rect.height(), false); } else { source = new PlanarYUVLuminanceSource(data, width, height, 0, 0, width, height, false); } rawResult = mMultiFormatReader.decodeWithState(new BinaryBitmap(new HybridBinarizer(source))); } catch (Exception e) { e.printStackTrace(); } finally { mMultiFormatReader.reset(); } if (rawResult != null) { result = rawResult.getText(); } return result; } }
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); try { rawResult = multiFormatReader.decodeWithState(bitmap); } catch (ReaderException re) {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); try { result = reader.decodeWithState(bitmap); } catch (Exception e) {//解析失败则通过GlobalHistogramBinarizer 再试一次 BinaryBitmap bitmap1 = new BinaryBitmap(new GlobalHistogramBinarizer(source)); try { result = reader.decodeWithState(bitmap1); } catch (NotFoundException ne) {
/** * 获取解码结果 * * @param bitmap * @return */ public Result getRawResult(Bitmap bitmap) { if (bitmap == null) { return null; } try { return multiFormatReader.decodeWithState(new BinaryBitmap( new HybridBinarizer(new BitmapLuminanceSource(bitmap)))); } catch (NotFoundException e) { e.printStackTrace(); } return null; } }