Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android QRCode Scanner Library [closed]

What do we have out there available to us (if anything) that we can call for QR data discovery and extraction on an image?

While there have been plenty of posts thus far referencing the ZXing library for QRCode scanning, I haven't found that to be a solution that works for me. Several others have been asking for QRCode scanning alternatives and I have not seen useful feedback. I thought I might ask the community once more what the other options might be for a QR code library that does not launch an activity and call outside our own applications. It should scan images from the Camera2 API in a very simplistic manner. It shouldn't be a complicated library. I hadn't seen examples or individuals speaking of it in this manner.

It actually puzzles me as to why there hasn't been native implementations of the QRCode functionality added into perhaps the Camera library or similar place within the Google SDK natively within the operating system.

Calling and requiring another application (or even requesting a download) is not an elegant solution and no users should be succumbed to doing such thing. As developers we should have access to a library capable of extracting a QRCode from an image or frame that we can then remove encoded data from.

like image 344
Jay Snayder Avatar asked Dec 27 '13 14:12

Jay Snayder


People also ask

Why is my QR scanner not working on my Android?

To sum up, if your Android device won't scan QR codes, go to Camera Settings, and enable the QR code scanner option. Additionally, press and hold the QR code screen area or the Google Lens button. If the issue persists, download a QR code scanner from the Play Store.

Why has my QR scanner stopped working?

Here are some reasons why a QR code is not working on Android devices: Your Android device isn't running Android 9 or higher. If your device can't run Android 9 or higher, you can download a third-party app to scan QR codes. You can also check and update your Android version.

Where are QR codes stored on Android?

Tap the capture button. This button usually looks like a circle at the bottom of your screen. It will take a picture of the QR code, and save it to your gallery. You can now find a picture of this QR code in your gallery, and share it or use it however you want.

Do you need a QR code scanner for your smartphone?

Unlike barcodes, the QR codes can be scanned accurately with a smartphone by giving the camera permission to scan. And it doesn’t require any specialized hardware like the barcodes. However, in some smartphones, you may need a QR code scanner for accessing QR codes.

What is a QR code?

Both QR codes in Android and iOS represent a small string like a shortened web URL and/or a contact number. Here’s a QR code example that contains URL of Space-O Technologies. Unlike barcodes, the QR codes can be scanned accurately with a smartphone by giving the camera permission to scan.

What is the best open source QR code library?

Zxing stands for Zebra Crossing, it is one of the most popular open-source API for integrating QR (Quick Response) Code processing. It is a barcode image processing library implemented in Java, with ports to other languages. It has support for the 1D product, 1D industrial, and 2D barcodes.

How to scan a barcode in Android Studio?

Barcode scanning happens on the device, and doesn’t require a network connection. Create a new project in Android Studio from File ⇒ New Project and select Empty Activity from templates. Also we need to set java 1.8 as a targetCompatibility, add the following to the end of the Android block:


2 Answers

While Sean Owen and others that have worked on the original Zxing library had provided an approach to work with the barcode libraries for the past several years, Google has finally put out an official release with Google Play Services for handling qr and barcodes.

The barcode detection library is described here. The inclusion of these libraries will make for a smooth integration. I'll repost with some sample code for achieving these results from a captured image. At the moment, I wanted to update my answer for this official release. If this indeed does provide a nice way to get at this information (without jumping through hoops and complications), then I'll update with the source and check this off as an accepted answer.

The detection library that Google has provided within the past year has been a much easier library to work with. It allows for quick integration with the camera APIs and extracts the information with simplicity. This would be the component that I would suggest going forward with recognition. A quick snippet is demonstrated below for handling a Qr-code. A handful of pseudocode is left in there as well.

public final void analyzeFrameForQrCode(byte[] qrCodePictureF, int imageFormatF, XriteSize previewWindowSizeF) {     if(!qrCodeDetectionPossible() || qrCodePictureF == null || mIsAnalyzingQrCodeFrame)     {         return;     }      ... //Bitmap conversion code      Frame frame = new Frame.Builder().setBitmap(pictureTaken).build();     SparseArray<Barcode> barcodes = mBarcodeDetector.detect(frame);     if(barcodes != null && barcodes.size() != 0)     {         Barcode qrCode = barcodes.valueAt(0);//barcodes.get(Barcode.QR_CODE);         if(qrCode != null)         {              if(extractInformationFromQrCode(qrCode.rawValue)) {                     mIsRequestingBarcodeDetection = false;                     vibrateForQrCodeDiscovery();                     ((Activity)mContext).runOnUiThread(new Runnable() {                         @Override                         public void run()                         {                             hideBarcodeDetection(true);                         }                     });                 }             }         }       ... //Cleanup and code beyond Qr related material     }  } 

There are of course other calls available that can be taken advantage of. But there are really only a couple lines in there. The service for analyzing the frames with the library are not there by default on devices however. So, you should check whether or not the library is available (such as when internet is not available) before calculating as well. This is a slight nuisance of it. I had assumed it would be available as updates for devices going forward as part of the support library or Google Services going out to all devices. But it needs the communication first with an external service to use these library calls. Once it does this one time then that device is good from that moment on.

In my small example, I pop a toast up after a check and then back out of the activity and let the user check their connection. This can be done with a small amount of sample code as well.

if(!mBarcodeDetector.isOperational()) {     updateUserInstructions("The barcode library cannot be downloaded");     return false; } 

Edit (Update):

A considerable amount of time has passed since working with the latest Google Play Services Vision libraries available for barcode detection. While the limitation for needing to download the library over the wifi is indeed a limitation, it is a one time process. And lets be honest...

...our devices will have a connection. The library itself is downloaded in the background so you don't even notice it happening unless there is trouble downloading it and then you would have to report an appropriate corrective measure such as enabling a connection to the internet for it.

One additional tidbit is that it is a little tricky sometimes with how you integrate the library into your application. Using it as a library project worked on some devices and then failed on others. Adding the jar to the build path worked across a broader number of devices (it could be all, but it solved a problem). So as such, I would do it using the secondary method when including it in your projects for now.

like image 141
Jay Snayder Avatar answered Oct 15 '22 14:10

Jay Snayder


Android QRCode Scanner Library

This may help you, this library doesn't require any download or use of any external application. We can directly integrate this into your app and use it for scanning a QR code.

https://github.com/dm77/barcodescanner

This wiki will help you to integrate with your app,

https://github.com/dm77/barcodescanner/blob/master/README.md

like image 32
VivekTamilarasan Avatar answered Oct 15 '22 15:10

VivekTamilarasan