QR Scanner

Is it possible, somehow, to limit the “field of view” for the actual scanning area with this new functionality?

I can think of at least one example where this could come in handy. On some products there are many bar-codes in the same area and scanning one specific of them is difficult. If we could somehow setup the scanning area so that is is a low rectangle (and not a big square as it is today) scanning a specific bar-code would have been so much easier!

The problem with limiting the scanning area is that not all phones have good cameras. And even if it’s good, lighting conditions can make it impossible to scan in a small area.

One solution can be filtering of codes so that only those that match the condition will trigger the scanning result.
The other solution can be in scanning several codes in one go and let the developer to perform actions on all of them.

They all are viable, but require development time, so in some future. I have to organize my priorities and available free time.

And you can always cover unwanted codes with something.

Updated iOS version of the plugin: added custom overlay support like on Android.

Lerg,

 Thanks for the great plugin. The new overlays are a great feature and really help me in the project I’m currently working on. This there a chance that you could add a callback as one of the options that would be called if the user taps the screen? 

I’m thinking that I could add in a ‘button’ as part of the custom overlay and then if the user taps the screen the plugin could call the supplied callback and then close. This would let me show a help interface back in my Corona app if they are having trouble with the scanner. 

Again, thanks for the plugin and for continuing to update it.

Thanks for the feedback!

That’s interesting, but non-trivial. Unfortunately, at the moment I don’t have time for something like this, so maybe later. As an alternative, you can show a tutorial screen once before starting the scanner.

Yes, that’s what I’m doing now and let me tell you - it’s not exactly an “optimal” solution…

In my situation I need to scan a wide variety of codes. They can be QR or barcodes, large or small, single or between others. The app is meant to be used to tag your personal items based on these codes (if they are present). A good example is the serial ID of a bicycle, which is often at the underside of the crank. Masking this area with your fingers or some paper pieces when messing about with this in the garage is not a viable solution. 

Fingers can be used to mask unwanted areas, but will very often create shadows on an already difficult area to scan and also trick the camera into shifting focus to the fingers and making it all worse.

In short: At least for my purpose, an external masking solution is not a good solution.

I have noe idea how things work on the inside of this plugin. Maybe it’s not even possible. But a handle that can adjust the scanning area would be just about perfect for my purpose  :slight_smile:

Something like this:

Anyway, I’m grateful for the plugin already!

Thanks for the response Lerg. 

Also, I’ve been working with the overlays but I’m having an issue. Every image that I put in as an overlay ends up being off-center and sometimes stretched on the app. Even if I use the overlay images in your git hub repo for the sample app it still doesn’t correctly cover the screen.

I’m testing on Android and I’m using the latest stable build of Corona - v2016.2830

Are there specific dimensions I need to use when creating the overlay image? Do I need to use a different build of Corona?

Thanks,

Brandon

Overlays follow the same logic as ZoomEven content scaling - scale proportionally to cover entire camera feed. If you see some distorted behavior (wrong aspect ratio), then it’s a bug.
Because all phones are different, result will be slightly different as well. You can however supply different overlays depending on a device.

Here is a picture of what the plugin looks like on my device. The overlay in this instance is a 640x640 png file. Because of how it’s stretching it I wonder if it has something to do with the update you put in recently to handle horizontal orientation apps?

qr-overlay.jpg

bpollet, and what’s your device resolution? Can you try an overlay that is much larger?

720 width x 1280 height.

I tried an image that was 1280x1280 and it didn’t appear at all, I’m not sure what happened there. I also tried 1024 x 1024 and it was similar to the previous picture, off-center to the right and not stretching vertically enough to fill the screen.

Ok, that looks fun! I will try fixing it over the weekend.
Do you have any problems on iOS?

I just tried an overlay at 720 x 1280, on Android, and it’s closer to fitting but still off center to the right and it doesn’t quite cover the full screen. That exact same overlay on iOS works perfectly. I just tested a device build and the overlay looks great.

Lerg,

I’m sure you are busy but I was wondering if you had a chance to look at the overlay bug on Android? iOS scales the overlay correctly but Android isn’t.

Thank you,

Brandon

Sorry, I couldn’t find time yet. Planning to do so this weekend.

I appreciate it. Thanks for getting back to me.

bpollet, I can’t trigger the issue. Can you send me your project and tell me more details about your device? Also can you try on different devices as well?

Actually I’ve found an issue in the code. Updated the plugin. I still couldn’t trigger your case, but I think it should be solved now.

Lerg,

That did solve my issue, now the overlay is scaling correctly and Android functions just like iOS.

Thank you so much for your help.

  • Brandon

Hi Lerg,

I am trying to incorporate this plugin with our app using Corona Enterprise.  Currently I am trying to get it working on Android and have not yet tried with iOS.  I downloaded the repository and copied the .jars to android/libs and the resources to android/res.

I grabbed the sample code from http://spiralcodestudio.com/plugin-qrscanner/ to use the plugin.

When trying to use the scanner from within the app, the screen will show the camera and the dashed rounded rectangle overlay for just a second before the app crashes.

The error received is:

E/AndroidRuntime( 1741): FATAL EXCEPTION: main

E/AndroidRuntime( 1741): java.lang.NoClassDefFoundError: plugin.qrscanner.R$menu

E/AndroidRuntime( 1741):  at plugin.qrscanner.CameraActivity.onCreateOptionsMenu(CameraActivity.java:208)

E/AndroidRuntime( 1741):  at android.app.Activity.onCreatePanelMenu(Activity.java:2476)

E/AndroidRuntime( 1741):  at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:397)

E/AndroidRuntime( 1741):  at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:751)

E/AndroidRuntime( 1741):  at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:2924)

E/AndroidRuntime( 1741):  at android.os.Handler.handleCallback(Handler.java:615)

E/AndroidRuntime( 1741):  at android.os.Handler.dispatchMessage(Handler.java:92)

E/AndroidRuntime( 1741):  at android.os.Looper.loop(Looper.java:137)

E/AndroidRuntime( 1741):  at android.app.ActivityThread.main(ActivityThread.java:4794)

E/AndroidRuntime( 1741):  at java.lang.reflect.Method.invokeNative(Native Method)

E/AndroidRuntime( 1741):  at java.lang.reflect.Method.invoke(Method.java:511)

E/AndroidRuntime( 1741):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)

E/AndroidRuntime( 1741):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)

E/AndroidRuntime( 1741):  at dalvik.system.NativeStart.main(Native Method)

The result is the same on 2 different devices with android versions 4.1.2 and 6.0.1. My Corona Enterprise version is 2016.2830 and my app is targeting api 23, min api 12.

Do you have any ideas on what I need to do to get this working?

Thanks