Transmit and receive multiple QR codes

179 views
Skip to first unread message

Sadir Omer

unread,
Jan 24, 2016, 9:14:03 PM1/24/16
to zxing
Hi for the FYP in my Uni I am supposed to transmit and receive a File using multiple QR codes. Right now I'm working on how I must create multiple QR codes using any File. Any suggestions to what format a file (say a 'zip' file) should be converted so that it can be encoded into a QR code?
Any suggestions would be greatly appreciated.
Thank You

Bas Vijfwinkel

unread,
Jan 24, 2016, 10:43:27 PM1/24/16
to zxing
Hi Sadir,

The basic procedure is to chop up your input file into datapieces that fit a QR code.
According to the specs, a QR code can hold 4296 alphanumeric characters or 2953 bytes (8bit).
So decide how you want to store your data :
- alphanumeric characters (easy to check with any decoder but you need to convert your binary data to alphanumeric data) ot
- 8 bit binary data (harder to check but you can add a bit more data to each QR code).
For testing purposes, I would recommend alphanumeric because it is easy to check.

After deciding this the following steps are necessary :
1. convert you input file to alphanumeric if needed
2. chop up your input file into piece that fit a single qr code
3 encode a qr code for each piece.
Now you have a large number QR codes

Decoding them is the reverse process
1. read each QR code and extract that data piece
2. append all data pieces
3. if the data was alphanumeric, convert the alphanumeric data to binary data again.

For bonus points to impress your teacher :
- add each data pice to your own data structure which defined an index. When extracting the data, look up the index of each piece. Then you will be able to scan QR codes in a random order.
- add a checksum to your input data to check the validity of the decoded output.
- add a parity archive (https://en.wikipedia.org/wiki/Parchive) so that you can miss a few QR codes and still be able to recreate the original file.
- add a cool logo to the QR code, or even a sequence number. this involves setting a high error correction for the QR codes themselves.
- create a flip book device with a webcam to scan all QR codes (http://brightbytes.com/collection/flipbooks.html)

Good luck!

Best regards,

Bas

Sadir Omer

unread,
Jan 26, 2016, 1:59:07 AM1/26/16
to zxing
Hi Bas,

Thanks a lot for a very detailed reply.
Is there any method you could suggest to convert a file to alphanumeric, when developing an android app using android studio? So far I've only come across Base64 encoding method.

Sorry if my questions are very basic. I'm a beginner to the programming world.

Thank You

Bas Vijfwinkel

unread,
Jan 27, 2016, 12:28:25 AM1/27/16
to zxing
Hi Sadir,

>>So far I've only come across Base64 encoding method.

Base64 is great for encoding/decoding and you can probably find enough examples how to use it.
And why spend a lot of time on writing your own encoder/decoder if you can use it right out of the box?

If you have any other question, feel free to mail them anytime.

Best regards,

Bas

Sadir Omer

unread,
Jan 27, 2016, 11:18:41 PM1/27/16
to zxing
You have been very helpful. Thanks a lot :)
I will start on the project. If I come across any problem I will mail you

Sadir Omer

unread,
Jan 30, 2016, 5:20:25 AM1/30/16
to zxing
Hi Bas,

I managed to do till the part where the input file is chopped so that it would fit to a single QR code. Any suggestions as to how i should convert the chopped string to multiple QR codes. I can only convert the very first array created. I posted this in stackoverflow

http://stackoverflow.com/questions/35098081/android-generate-integrated-zxing-based-streaming-qr-code?noredirect=1#comment57919349_35098081

Than You

Bas Vijfwinkel

unread,
Jan 31, 2016, 7:59:55 PM1/31/16
to zxing

You've already managed to generate the first block, so that is a great first step.
As you mentioned yourself, you just need to wrap you stuff in a loop that references
each element in the Base64Parts array.

2 things you need to do :
1. Make sure you output the barcode you just made to a file.
2. Put everything you have made so far in a loop :
for (int i=0;i<Base64Parts.length();i++)
{
// in your code change Base64Parts[0] to Base64Parts[i]
// also make sure you use 'i' in the filename of your output image
}
and it will loop over all the elements in the Base64Parts array.

Good luck.

Bas

Sadir Omer

unread,
Feb 1, 2016, 12:39:20 AM2/1/16
to zxing
Thanks again. You are a savior. I shall try this and see.
After i manage to loop over all the elements is there a way to show all the QR codes generated through an ImageView through a timed interval? Or do u think I should make a GIF or Video of with a loop? Any Ideas?

Bas Vijfwinkel

unread,
Feb 2, 2016, 1:10:29 AM2/2/16
to zxing
On Monday, February 1, 2016 at 2:39:20 PM UTC+9, Sadir Omer wrote:
> Thanks again. You are a savior. I shall try this and see.
> After i manage to loop over all the elements is there a way to show all the QR codes generated through an ImageView through a timed interval? Or do u think I should make a GIF or Video of with a loop? Any Ideas?

After generating your individual QR codes,
you need a way to show them 1 by 1.
You could go for the build in photoviewer as a start and focus on building the decoder.
If your decoder proves to be fast enough, you know how long you will need to show each bar code.
Then you could indeed make an animated gif (where you set the display interval long enough to decode each QR code).
Decoding it to a video might take more effort.
Since you are on Android, you could also look foor a photo viewer component and point that to the output folder of your images. Maybe you can have the photo viewer component go to the next image if you press one of the side buttons on the phone. In this way you control the speed with which QR codes are shown. That way you can make sure you QR decoder has decoded the image before you move on to the next.

If you have only 1 phone available, it's maybe easier to write all image to a new folder.
If you want to test your decoder, just point it to the right folder and let it read the files (in the correct order that is).

Reply all
Reply to author
Forward
0 new messages