Reputation: 3
I have been trying to decode the QR code for many days and have been able to decode the QR codes that are generated by the free applications and stuff.The problem is when i try to use the images taken from camera which can be blur,have extra content,captured at a slight angle, i cant decode them.
NOTE:I dont want to use the intent to call the existing barcode reader.
Bitmap bmap=BitmapFactory.decodeResource(getResources(),R.drawable.qrImage);
LuminanceSource source = new RGBLuminanceSource(bmap);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
QRCodeReader reader = new QRCodeMultiReader();
try{
Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
Result result = reader.decode(bitmap, hints);
TextView tv= (TextView) findViewById(R.id.tv1);
tv.setText(result.getText());
}catch(Exception e)
{
e.printStackTrace();
}
Upvotes: 0
Views: 561
Reputation: 2173
Have you tried zxing QR code scanner. It is an open source code which is useful for reading almost all types of bar codes. you can download the source code of zxing from this link: http://code.google.com/p/zxing/source/checkout in this they have clearly specified the how to scan a qr code. Just go through the code. I can also suggest another link that will help you to run the source code: http://www.falatic.com/index.php/12/building-zxing-for-android-part-3-using-eclipse . After that explore the code you can sort it out
Upvotes: 1