Java Question QR code scanning

zmrcic

Member
Licensed User
Hi, I have a small problem.
this is original QR code from receipt

viber_image_2.jpg


I'm trying to scan it with different libraries and tried almost all of them from b4a site, based on google play service vision, I tried some Johan Schoeman solutions, Erel suggestions, tried taking pictures, grayscale them(change to black and white), CameraEx, Camera2, flashon or off..., but nothing is working.
I have downloaded a few most popular QR code readers from the play store, but there is no result.
There is only one app that can scan it, and it is from the system manufacturer. Strange, when you scan it, it takes you to their webpage(QR is in fact URL), but QR code presented there, shown on the next image, is different than on first image. I know it is an error correction or something, but why?
Untitled.png

is there a way to change error correction for QR reader, or some other parameter? or Am I just silly?
I hope Johan S or somebody can scan this QR(first image) and give me a clue.
Other QR codes, generated by other apps for the same system, are OK, can read them from meters away...
 

drgottjr

Expert
Licensed User
Longtime User
no problem here. #1 mobile vision, #2 zxing
 

Attachments

  • qr1.png
    qr1.png
    157.5 KB · Views: 183
  • qr2.png
    qr2.png
    125.5 KB · Views: 208

zmrcic

Member
Licensed User
thanks for fast reply...
GREAT!!!!
can you please suggest some B4A library or put a link here for a project or example? As I said, I have tested it with a few of Johan Schoeman's examples and some others, but no luck...
 

Johan Schoeman

Expert
Licensed User
Longtime User
thanks for fast reply...
GREAT!!!!
can you please suggest some B4A library or put a link here for a project or example? As I said, I have tested it with a few of Johan Schoeman's examples and some others, but no luck...
Use this one

 

zmrcic

Member
Licensed User
thanks Johan, but still no use....
Am I doing something wrong? Updatetd all libraries, I have manifest

AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="33"/> ''also tied 31, but current v is 33
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
AddApplicationText(<meta-data
android:name="com.google.android.gms.vision.DEPENDENCIES"
android:value="barcode,,face" />
)
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)


#AdditionalJar: com.google.android.gms:play-services-vision
in Main....

out of the box https://www.b4x.com/android/forum/threads/b4x-b4xpages-barcode-reader.120417/ does not work for me?!
have you tried it? I don't know, going mad here....
maybe I need to update something else, some library....?
 

agraham

Expert
Licensed User
Longtime User
no problem here. #1 mobile vision, #2 zxing
Both of those images seem to be reading the second QR code example which is fine. It is the first one that is problematic.

The first problematic one seems to have 25 'location markers' whereas the second readable one has 16. I don't know if this contributes to the reading problem, but that is how I identified that you were reading the second non-problematic one.
 

Johan Schoeman

Expert
Licensed User
Longtime User
thanks Johan, but still no use....
Am I doing something wrong? Updatetd all libraries, I have manifest

AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="33"/> ''also tied 31, but current v is 33
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
AddApplicationText(<meta-data
android:name="com.google.android.gms.vision.DEPENDENCIES"
android:value="barcode,,face" />
)
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)


#AdditionalJar: com.google.android.gms:play-services-vision
in Main....

out of the box https://www.b4x.com/android/forum/threads/b4x-b4xpages-barcode-reader.120417/ does not work for me?!
have you tried it? I don't know, going mad here....
maybe I need to update something else, some library....?
Please upload your B4A project - will be much easier to trace the problem having a project at hand. The project in the link has no problem scanning barcodes.
 

zmrcic

Member
Licensed User
I use the project in the link 'As is'...that is the problem, since you said it is working for you.
I'm not changing a single line of code. Download, run-debug....
point phone to this webpage and scroll from one QR code to another. first one, nothing, :( :mad:
second one, perfect. just check the images attached....

thank you for your patience.
 

Attachments

  • viber_image_q1.jpg
    viber_image_q1.jpg
    173.4 KB · Views: 468
  • viber_image_q2.jpg
    viber_image_q2.jpg
    211.1 KB · Views: 114

Johan Schoeman

Expert
Licensed User
Longtime User
I use the project in the link 'As is'...that is the problem, since you said it is working for you.
I'm not changing a single line of code. Download, run-debug....
point phone to this webpage and scroll from one QR code to another. first one, nothing, :( :mad:
second one, perfect. just check the images attached....

thank you for your patience.
What is "first one". The image from the receipt is very poor to expect a scanner to read a version 20+ qr code. The 2nd one reads easily as the modules are clearly defined.
 

drgottjr

Expert
Licensed User
Longtime User
as @Johan Schoeman suggests in his gentle way, image #1 is essentially not decodable.

image #1 is not an "original QR code from receipt". it is a picture of what may have
been an original qr code. so anyone trying to read #1 is not trying to read the original.

there are only 3 location markers in either image. not 16, not 25.

it isn't fair to blame software for a poor image or poor camera technique.

in addition to op's having unsuccessfully tried several apps, i submitted image #1 to several
online qr code decoding sites (including zxing's own). all failed. the last site mentioned sells
expensive barcode software to developers.

zxing.org

large, severely degraded, partially out of focus and askew images usually cannot
be decoded. if op is saying that there is an app which can read image #1, i'd like
to try it. it would be interesting to see if what that app scanned was image #1 or
the actual qr code.
 

agraham

Expert
Licensed User
Longtime User
there are only 3 location markers in either image. not 16, not 25.
I probably have the terminology wrong but each image has 3 large 'location markers' and number one has a further 22 smaller 'location markers' in a regular array across the image while the second has only a further 13 smaller ones. Whether that is an artifact of the coding or not I have no idea, but they seem too regularly spaced in a 2D pattern to not have a deliberate purpose.
 

zmrcic

Member
Licensed User
totally agree with drgotjr and Johan. But that is the best quality I can reproduce, and in fact, that is picture taken from my phone, so I guess that is how QR readers will see it. That is the only way I can put it here, but I have the same issue with one printed on paper...it is not readable. furthermore, receipts are usually banded and crumpled up....
I have also submitted images to some sites that "read" QR like drgottjr, but still no result.

Fiscal system developers have their app that can read #1 on paper and image posted here????? How?
here it is, you can try

I guess that they use some of the libraries we mentioned here, they could not invent their own.
Maybe modify something, like

code1:
frameBuilder.RunMethod("setImageData", Array(bb, cs.Width, cs.Height,  842094169))
with
code2:
frameBuilder.RunMethod("setBitmap", Array(byte))

(tried that, but nothing :mad: )

Maybe agraham is somewhere near the problem, it is the format of that QR. But how do they do it?
I guess all of the participants here are more experts than me, so maybe you will have a clue.
 

Johan Schoeman

Expert
Licensed User
Longtime User
The qr code in the photo seems to be version 21 ( 101 x 101 modules). The well defined qr code is version 20 (97 x 97 modules). Most barcode scanners read up to version 10 and some up to version 20. There are however scanners that will read up to version 40 (177 x 177 modules).

The 3 big squares are finding patterns. Smaller version QR codes can have a single finding pattern but bigger version have 3 finding patterns. The smaller squares are referred to as alignment patterns and is used for perspective correction of the image or frame containing the qr code.

I am not sure up to what version of qr code the mobile vision lib supports. It might well be that it only supports up to version 20. Regardless, neither Zxing nor mobile vision that can reed the qr code in the photo that you have uploaded. I have not tried with ZBAR.
 

zmrcic

Member
Licensed User
thx Johan...
searching b4x site I found many examples, 90% posted by you :), android vision, mobile vision....
can you maybe find either one of them reading this QR?
so I can focus on that example....
 

agraham

Expert
Licensed User
Longtime User
I've donwloaded the TaxCore Invoice Verificator apk and looked inside. It appears to use a library called NeoReaderSDK which I believe was produced by a company called NeoMedia Technologies, Inc. However as far as I can see the company has gone tits up and is no longer trading.
 

Johan Schoeman

Expert
Licensed User
Longtime User
I have made a version 20 (L) Qr Code. The only lib so far that I could find to scan it is ZBAR. If I make it a V21 QR Code then ZBAR no longer scans it either. Mobile Vision will not read the Version 20 QR code below.

Content of the QR Code is as follows:

B4X:
https://suf.purs.gov.rs/v/?vl=AzYyVzdRVUNDNjJXN1FVQ0MEKgAA8ykAAGBNLwAAAAAAAAABh3wNuZgAAAChtPctsIOzVlxA5VgvUQU2Bkgf2FQZ%2FZXDXtyYnkFncxLEd%2F8GTfqy%2F8lYD1FM%2FhPZHVF3Zg6ioieh0zjzLRh%2F0KX5X6UblIA2z%2FSW6Qu4Db2kPdb0gHnFhzGA4HDMsLWXQjf5ZIMxrzR1ZLHgXYG7IV%2F5Cyfb4qZps0NDPRpsa8n6jFr51Pna3Gx7UMqa2Xjyg1MMKBdnGLcJSQyTsJaz64aYWwtvYW87WyHeWi6WORcfJKJKHRr1rXZ4bEVYmEfY0%2B28VNZfgysCvzM0pz4hCyxBgjI2570ZHhZGXYoVznHXflmmYYB1lSUoeNMx6eqHCXs%2FbW%2FQJoRtkLiyfhqJSIR98Cy7pcr2ht%2B%2F3OVHJcCDORFIyylfIvbrqwimom70zCs0%2FcTZz8de92koY7yFeI%2FAYyIPmE9w1M9A9ead56HS9vS5bsbzYHIn%2Bmt9NdgjC6EAS%2Br5bu5FEZ4xVf6u%2F3hFN71KM%2FoV9tqA05xndWZVsZp%2BYOgscw%2FVrSq%2FNsrd6XNBPXW7FIn%2F21um9z6jrhAUPd2fhmBF6O3Aad6xnZyJ0oztZfr6gYG98TRSo%2FKFHSpegNsNRKSXhGcOsjMKuZ6%2F3XZhU4A4PlKyYW5KpsbpiD4Qb%2F1vsCghHX4cCc09SYERFlI5SkZJJc%2BcJBdO4IaIhSTbCxPHKTaiV5ta7ISWCFSrVvhtac16QUCC8dM%3D

1681633463040.png
 

zmrcic

Member
Licensed User
so we do not have V21+ QR reader implementation in b4a...at the moment

it's just my luck...
thank you all, I'll just give up
 

Johan Schoeman

Expert
Licensed User
Longtime User
so we do not have V21+ QR reader implementation in b4a...at the moment

it's just my luck...
thank you all, I'll just give up
It is definitely a V21 QR code. The modules from left to right and top to bottom in line with the timing patterns add up to 101 in each case (21 * 4 + 17) and the right top and bottom left version information encoded in the QR code is that of a version 21 QR Code (110000010110101010)

1681643345991.png


I have briefly browsed through the ZXING code but cannot see where it has been throttled down. The code does seem to make provision for up to Version 40 but it might be for creating QR Codes only and not for decoding from a scan. Not sure if there are any other scanner libs in the forum that can scan 21+
Have only managed to scan up to version 20 with ZBAR.
 
Last edited:

drgottjr

Expert
Licensed User
Longtime User
attached please find 2 qr codes scanned with zxing: allegedly v25 and v40, respectively. and another one: 2953 characters! zxing.
 

Attachments

  • v25.png
    v25.png
    139.8 KB · Views: 111
  • v40.png
    v40.png
    161 KB · Views: 190
  • 2953.png
    2953.png
    155.2 KB · Views: 442
Last edited:
Top