获取ZXing Reader来解码位图

| 我还无法使用ZXing解码QR码。我正在使用来自buglabs.net的错误,但问题似乎与硬件无关,而与图像的格式有关。 这是我到目前为止所拥有的:
try {
    LuminanceSource source = new AWTImageLuminanceSource(bimage);
    bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(source));
    Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();
    hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
    Result result = reader.decode(bitmap, hints) ;
    System.out.println(\"result is:\" + result.getText());
    } catch (ReaderException re) {
            System.out.println(\"I can\'t find a barcode here\");
    }
该代码在reader.decode(bitmap,hints)处中断。我收到带有以下跟踪的NullPointerException:
java.lang.NullPointerException
    at qrcoder.QRCoder.shoot(QRCoder.java:152) // this is the camera shoot function
    at qrcoder.QRCoder.buttonEvent(QRCoder.java:89) // press button
    at com.buglabs.bug.input.pub.InputEventProvider.run(InputEventProvider.java:90)
不知道InputEventProvider试图告诉我什么。 非常感谢, 萨拉 不确定如何使用,但是Reader从未被写入。最后,通过直接使用解码器将Reader自己的源代码替换回该函数来工作。
private void shoot() throws IOException, NotFoundException, FormatException,     ChecksumException {
    // take the picture
    Hashtable hints = null;
    DecoderResult decoderResult;
    cameraLED.setLEDFlash(true);
    camera.grabPreview(buf);
    camera.grabPreview(buf);
    cameraLED.setLEDFlash(false);
    InputStream in = new ByteArrayInputStream(camera.grabFull());
    BufferedImage bImageFromConvert = ImageIO.read(in);
    LuminanceSource source = new BufferedImageLuminanceSource(bImageFromConvert);
    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
    ResultPoint[] points;

      final Decoder decoder = new Decoder();
      DetectorResult detectorResult = new Detector(bitmap.getBlackMatrix()).detect(hints);
      decoderResult = decoder.decode(detectorResult.getBits(), hints);
      points = detectorResult.getPoints();
      Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.QR_CODE);

    if (result.getText() != null){
        System.out.println(\"result is:\" + result.getText());
        }           
        else {System.out.println(\"bitmap is null\");}     


    ic.repaint();
}
目前可以使用,谢谢!     
已邀请:
        该项目中有BUG的示例代码,由BUG专家提供。参见
bug/
。不过已经很老了。
QRCoder
是你的班,不是吗?所以我不知道这是否是BUG或库的问题。     

要回复问题请先登录注册