从GenericMultiplebarcodereader类获取结果

时间:2014-01-06 12:45:30

标签: android

我正在尝试解码图像上找到的多个条形码,任何人都可以帮助我如何输出条形码的结果。 这是我的代码段。

public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
    if (requestCode == SELECT_PICTURE) {
        Uri selectedImageUri = data.getData();
        selectedImagePath = getPath(selectedImageUri);
        Bitmap bMap = BitmapFactory.decodeFile(selectedImagePath);
        LuminanceSource source = new RGBLuminanceSource(bMap);
        BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
        Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>    ();
        hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
MultiFormatReader mreader = new MultiFormatReader();
        GenericMultipleBarcodeReader multireader = new GenericMultipleBarcodeReader(mreader);
        try {
             Result[] result = multireader.decodeMultiple(bitmap,hints);
             if(result != null){
                 tv1.setText("Total Result" + result.length);// + photo.getWidth() +     "Height=" + photo.getHeight());
                 for(Result kp : result)
                 {

                     System.out.println(kp.toString());
                 }
             }



        } catch (NotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }   


    }
}

0 个答案:

没有答案