Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using multiple QR codes to encode a binary image

Tags:

qr-code

I'm increasingly looking at using QR codes to transmit binary information, such as images, since it seems whenever I demo my app, it's happening in situations where the WiFi or 3G/4G just doesn't work.

I'm wondering if it's possible to split a binary file up into multiple parts to be encoded by a series of QR codes?

Would this be as simple as splitting up a text file, or would some sort of complex data coherency check be required?

like image 363
ina Avatar asked Jun 02 '12 01:06

ina


2 Answers

Yes, you could convert any arbitrary file into a series of QR codes, something like Books2Barcodes.

The standard way of encoding data too big to fit in one QR code is with the "Structured Append Feature" of the QR code standard. Alas, I hear that most QR encoders or decoders -- such as zxing -- currently do not (yet) support generating or reading such a series of barcodes that use the structured append feature.

QR codes already have a pretty strong internal error correction. If you are lucky, perhaps splitting up your file with the "split" utility into pieces small enough to fit into a easily-readable QR code, then later scanning them in (hopefully) the right order and using "cat" to re-assemble them, might be adequate for your application.

like image 142
David Cary Avatar answered Nov 15 '22 18:11

David Cary


You surely can store a lot of data in a QR code; it can store 2953 bytes of data, which is nearly twice the size of a standard TCP/IP packet originated on an Ethernet network, so it's pretty powerful.

You will need to define some header for each QR code that describes its position in the stream required to rebuild the data. It'll be something like filename chunk 12 of 96, though encoded in something better than plain text. (Eight bytes for filename, one byte each for chunk number and total number of chunks -- a maximum of 256 QR codes, one simple ten-byte answer, still leaving 2943 bytes per code.)

You will probably also want to use some form of forward error correction such as erasure codes to encode sufficient redundant data to allow for mis-reads of either individual QR codes or entire missing QR codes to be transparently handled well. While you may be able to take an existing library, such as for Reed-Solomon codes to provide the ability to fix mis-reads within a QR code, handling missing QR codes entirely may take significantly more effort on your part.

Using erasure codes will of course reduce the amount of data you can transmit -- instead of all 753,408 bytes (256 * 2943), you will only have 512k or 384k or even less available to your final images -- depending upon what code rate you choose.

like image 32
sarnold Avatar answered Nov 15 '22 19:11

sarnold