Java Code Examples for com.google.zxing.NotFoundException#printStackTrace()
The following examples show how to use
com.google.zxing.NotFoundException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbsCodec.java From StarBarcode with Apache License 2.0 | 6 votes |
/** * 使用YUV解析bitmap * * @param data * @param width * @param height * @param hintTypeMap * @return */ private Result decodeFromYUV(int[] data, int width, int height, Map<DecodeHintType, ?> hintTypeMap) { Result result = null; byte[] yuv = convertRGBToYuv(data, new byte[width * height], width, height); PlanarYUVLuminanceSource source = new PlanarYUVLuminanceSource(yuv, width, height, 0, 0, width, height, false); BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source)); try { result = new MultiFormatReader().decode(binaryBitmap, hintTypeMap); } catch (NotFoundException e) { //使用GlobalHistogramBinarizer算法进行解析 try { result = new MultiFormatReader().decode(new BinaryBitmap(new GlobalHistogramBinarizer(source)), hintTypeMap); } catch (NotFoundException e1) { e1.printStackTrace(); } } return result; }
Example 2
Source File: QrUtils.java From Mobike with Apache License 2.0 | 6 votes |
public static Result decodeImage(final String path) { Bitmap bitmap = QrUtils.decodeSampledBitmapFromFile(path, 256, 256); // Google Photo 相册中选取云照片是会出现 Bitmap == null if (bitmap == null) return null; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPixels(pixels, 0, width, 0, 0, width, height); // RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels); PlanarYUVLuminanceSource source1 = new PlanarYUVLuminanceSource(getYUV420sp(width, height, bitmap), width, height, 0, 0, width, height, false); BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source1)); // BinaryBitmap binaryBitmap = new BinaryBitmap(new GlobalHistogramBinarizer(source1)); HashMap<DecodeHintType, Object> hints = new HashMap<>(); hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); hints.put(DecodeHintType.CHARACTER_SET, "UTF-8"); try { return new MultiFormatReader().decode(binaryBitmap, hints); } catch (NotFoundException e) { e.printStackTrace(); } return null; }
Example 3
Source File: CameraPreview.java From Android-Barcode-Reader with MIT License | 6 votes |
@Override public void onPreviewFrame(byte[] data, Camera camera) { // TODO Auto-generated method stub if (mDialog.isShowing()) return; LuminanceSource source = new PlanarYUVLuminanceSource(data, mWidth, mHeight, mLeft, mTop, mAreaWidth, mAreaHeight, false); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer( source)); Result result; try { result = mMultiFormatReader.decode(bitmap, null); if (result != null) { mDialog.setTitle("Result"); mDialog.setMessage(result.getText()); mDialog.show(); } } catch (NotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Example 4
Source File: BitmapDecoder.java From BarcodeScanner with Apache License 2.0 | 6 votes |
/** * 获取解码结果 * * @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; }
Example 5
Source File: AbsCodec.java From StarBarcode with Apache License 2.0 | 5 votes |
/** * 使用RGB解析bitmap * * @param data * @param width * @param height * @param hintTypeMap * @return */ private Result decodeFromRGB(int[] data, int width, int height, Map<DecodeHintType, ?> hintTypeMap) { RGBLuminanceSource source = new RGBLuminanceSource(width, height, data); BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source)); try { return new MultiFormatReader().decode(binaryBitmap, hintTypeMap); } catch (NotFoundException e) { e.printStackTrace(); } return null; }
Example 6
Source File: BarCodeReaderManager.java From StarBarcode with Apache License 2.0 | 5 votes |
/** * 解码条形码 * * @param bitmap */ Result decodeWithState(BinaryBitmap bitmap) { try { return multiFormatReader.decodeWithState(bitmap); } catch (NotFoundException e) { e.printStackTrace(); } finally { multiFormatReader.reset(); } return null; }