Reputation: 17562
I'm developing an embedded application where a device generates QR codes on an LCD screen.
the code generation part seems to work just fine, but I seem to have some trouble with decoding it.
I generate the QR code via the function
QRcode *qr = QRcode_encodeString8bit("http://some/url/", 0, QR_ECLEVEL_Q);
then convert it to a format that can be read by the image library to be displayed on the screen. However, while the "QR Droid" app on Android can read it and send me to the URL just fine, another one called "Qr Barcode Scanner" doesn't seem to recognize the code, even though it seems to detect the alignment points. Same goes for iOS - some apps read it fine and some apps just act like it's not a code.
What could be the possible cause of this problem? I tried different error correction levels and that's not it.
Thanks in advance for your replies..
Edit: Apparently the code was flipped horizontally. I changed how I convert it to a 16-bit image, and it worked. I'm putting down a code snippet for future reference, in case someone else stumbles upon the same issue.
QRcode *qr = QRcode_encodeString8bit(string, 0, QR_ECLEVEL_H);
int i, j;
for (i = 0; i < qr->width; i++) {
for (j = qr->width - 1; j >= 0; j--) { //flipped this
if (qr->data[(j * qr->width) + i] & 0x1)
*(qr_img++) = COLOR_16BIT_BLACK;
else
*(qr_img++) = COLOR_16BIT_WHITE;
}
}
Upvotes: 0
Views: 1456
Reputation: 49
In my case the code that works( compare with a qr code generator which outputs the same resoult) looks like this
QRcode *qr;
qr = QRcode_encodeString("ABC012345", 0, QR_ECLEVEL_H, QR_MODE_8, 1);
int i_qr, j_qr;
for (i_qr = 0; i_qr < qr->width; i_qr++) {
for (j_qr = 0; j_qr < qr->width; j_qr++) {
if (qr->data[(i_qr * qr->width) + j_qr] & 0x1)
printf("*");
else
printf(" ");
}
printf("\n");
}
Upvotes: 4
Reputation: 66866
@smparkes I'm not sure the QR code is flipped. zxing reads it OK, and it does not allow mirrored codes (not without TRY_HARDER).
Yes, mirror images of valid QR codes are never valid; rotations are. I suppose I would be surprised if the library just generates invalid QR codes all the time. QR Droid is just based on zxing too, so would be surprised if it goes out of its way to also read these invalid codes.
But then again the other bits of evidence suggest mirroring is the issue.
Upvotes: 0