Today, I did some experiments with QR codes to extend upon the structure I already had which sent 1’s 2’s and 3’s from processing to Arduino depending on key presses.
Goal: To replace the input (key presses) with QR code detection through the webcam.
One thing I know about this process is that the QR code detector will return the key code for the letter 1 rather than a number value 1. So this needs to be rectified.
Using the QR code generator that was recommended by the links in C.06 Troubleshooting and Structure and saved them as usable qr codes like so:
Before printing and testing the qrcodes on the webcam, I decided to upload them in processing to make sure they could be decoded properly (see line 72). This threw out an error ‘No QR code image found’. I tested this against a file path that was deliberately wrong and that threw a different error, so there must be something wrong with the QR code image.
I suspected that this was because I tried to use the phone number section of the qr code generator and only used one digit. Running the jpeg through an online QR code decoder, produce the correct result however.
My options from here on are: a) To try again with text instead of a number, b) To find a site that will let me download the jpg for free c) use preexisting QR codes with an if statement that uses that data as a condition for returning 1’s 2’s and 3’s.
A. Try again using a text string
I repeated the process with the text string, 1 2 and 3. This time skipping the step where I sharpen the image on photoshop (to save time) and exporting them as png files (to match the example).
Again the same error came up.
c) Use pre-existing QR codes
Just to see if the decoder works with other qr codes, I have downloaded one from the internet. Running it through the online decoder reveals that is contains the string ‘12345678’.
Interestingly, this gives a different kind of error, I thought maybe the image itself was too large. The sample image was 216 x 216 pixels so I resized the tester qr code.
This worked and the string was returned. When I tested it out on the original 1,2 and 3 (digit, not string) QR codes, it also worked! However the data returned was TEL:3 rather than just 3. So I will use the 1,2 and 3 (string) QR codes instead.
I don’t think this would have been much of a problem when printed out but I am glad I was able to fix this issue, regardless.