decoding barcode in an image

104 views
Skip to first unread message

TheNabbitect

unread,
Mar 20, 2011, 8:55:30 PM3/20/11
to zxing
Hi,

I'm trying to develop code to do essentially what the web based
decoder does with a file. However, I think I am coding something
wrong because when I give the MultiFormatReader my image, it takes
almost a minute for each Reader attempt. My code looks like this:

Bitmap bMap = BitmapFactory.decodeFile"image.jpg");
LuminanceSource source = new RGBLuminanceSource(bMap);
Binarizer binarizer = new HybridBinarizer(source);
BinaryBitmap bitmap = new BinaryBitmap(binarizer);
MultiFormatReader reader = new MultiFormatReader();
Result result = reader.decode(bitmap);
System.out.println("barcode data: " + result.getText());

Is there a better way to give an image to the MultiFormatReader? Or
is the code for the web-based decoder available for perusal?

Thank you in advance for your help.

akriwan

unread,
Mar 22, 2011, 5:16:44 AM3/22/11
to zxing
Hi,

my code looks like this, if its faster... i dont know.

Reader reader = new MultiFormatReader();
BufferedImage buffImg = ImageIO.read(new File(filename));
LuminanceSource source = new BufferedImageLuminanceSource(buffImg);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Result result = reader.decode(bitmap);
String output = result.getText();
Reply all
Reply to author
Forward
0 new messages