Processing QRCode Library

qrcode

Welcome to the QRCode Processing library page!

First, let me apologize for the rather poor documentation. At some point, this will be remedied. For now, here is some basic information:

Download the Processing QRCode library (includes source and example)
(Special thanks to Tom Igoe for the original code that I started with.)

This library is really nothing other than a bridge to using the Open Source QR Code library with Processing. From the QR Code web site: “QR Code is a two-dimensional barcode, used widely in Japan. The advantage of QR Code from well-known barcode is larger data capacity (more than 100 bytes, typically) and error correction.”

QRCode images can be generated at http://qrcode.kaywa.com/.

Here is a basic summary of how to use the library:

Download and install the library, and import it like so:

import pqrcode.*;

Create and initialize a decoder object:

Decoder decoder;
 
void setup() {
  decoder = new Decoder(this);
}

You can ask the Decoder object to decode any image:

PImage img = loadImage("qrcode.jpg");
decoder.decodeImage(img);

It runs in a separate thread and whenever it is finished, an event is triggered via the decoderEvent() method:

void decoderEvent(Decoder decoder) {
  String statusMsg = decoder.getDecodedString(); 
  println(statusMsg);
}

Ok, have fun everyone!!

  • http://flickr.com/photos/lennyjpg lenny

    i love processing too ! (;
    it works !
    great stuff. thanks or the effort man.

  • Jeroen

    Hi

    When trying to use your example given above, I get the following error:

    java.lang.UnsupportedClassVersionError: pqrcode/Decoder (Unsupported major.minor version 49.0)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

    Can you explain me what is going wrong here?

    Thanks

  • Manuel

    same problem as jeroen. what can I do?

  • http://www.shiffman.net Daniel

    I’ve updated the library to fix this issue, try downloading it again and let me know!

  • Manuel

    i downloaded the library and tryed an older java version, too.
    but i get the same error. thanks for your trouble

  • Manuel

    I’ve downloaded processing without java, now it works!

  • Manuel

    I’ve downloaded processing without java, now it works!

  • Pingback: Letter Never Sent by Chris Sivori » QR-Code: Linking the physical world

  • Jo

    I’m getting the (Unsupported major.minor version 49.0) error as well.

  • Pingback: imatrix / QR Codes on the iPhone | steve cooley presents

  • corne

    i’m getting the following error, tried with multiple camera’s but still getting the error:

    quicktime.std.StdQTException[QTJava:7.3.0g],-9405=couldntGetRequiredComponent,QT.vers:7308000
    at quicktime.std.StdQTException.checkError(StdQTException.java:38)

    does anybody know what to do with this one?

  • hemc

    how can i import this sample into Netbeans?

    he always says “cannot find symbol”

    can you give me a hint?

    thx

    cyaz
    Hemc

  • http://www.tinktank.it da5id.b

    Hi Dan,

    The library is great. Now i’m trying it out with my own qrcodes.
    Still have to set it, but i noticed an error that comes out frequently with the pqrcode_example you provided in this page:

    java.lang.ArrayIndexOutOfBoundsException: 100
    at jp.sourceforge.qrcode.codec.reader.QRCodeDataBlockReader.getNextBits(QRCodeDataBlockReader.java:65)

    Does somebody have an idea about the source of this error?

    Thanks!

  • hey dan

    Is it possible to inbed the app into a website? i have it working really well with a few changes so it opens new web pages from a qr code! (which is really cool)! but iam having problems inbedding it and linking it to the app.

    what do I need to do??

    Any help would be much appreciated! :)

  • http://code.google.com/p/zxing Sean Owen

    The “UnsupportedVersionError” comes from the fact that it was compiled by a later version of Java than you guys are using, and was not specifically targeted for an earlier version.

    That source code should be compilable back to Java 1.2 or maybe before. Daniel I think you just need “-target 1.2″ on your javac command.

    Or, folks with the issue, use a newer verison of Java. I think major version 49 = Java 5, which is not even that new. Go to Java 6 if you can.

  • http://code.google.com/p/zxing Sean Owen

    da5id.b that’s an error from the qrcode library. I think it is a little buggy.

    May I plug our open-source decoder, ZXing: http://code.google.com/p/zxing

    I’d happily rewrite the wrapper here to use this decoder. I’d bet dollars to donuts its faster and more accurate.

  • abnoba12

    Is it posible to have it decode many QR Codes in a single image. The project I’m working on requires it. Nice app BTW.

  • http://www.shiffman.net Daniel

    Hey Sean, thanks for the info about ZXing, I’m definitely going to investigate, might be worth making a Processing specific library for ZXing which I’d be happy to do!

  • Ramon

    Hi!
    I am 22 years old and I’m in 2 year of Electronic Art and Digital Design in a university from Barcelona, Spain.
    I’m trying to program a very simple code by myself in Processing similar to the AudioPad or the Reactable using QRCode. I don’t have lots of experience in programing, but I try hard with new things. How could I know the position of various qrcodes in the sketch? In your library is there any function that returns you the position of the qrcode? And if it’s not very complicated, the same with the rotation.
    I would be very pleased if you could say me something about this, if you know any other library, any book…. or any other thing that could help me with this.

    Thanks for all! ^^

  • Alex

    If found a good website on QR code. You can generate barcodes, decode them with mobiles, etc. : http://www.jaxo-systems.com

  • David

    Do you have any netbeans example of use this library ?

  • http://www.shiffman.net Daniel

    David: Sorry, I don’t, but the source code is there for adaptation

  • lee

    hi , plz spend some time to direct me to install this library.
    i’m intrested in using this library . i used this library as a package in my prog. but showing errors
    can u spend some time so that i can use this library..
    thankz in advance…

  • lee

    PImage img = loadImage(“qrcode.jpg”);

    when i used this,
    here “PImage” shows error…
    is it because of some missing classes???

  • http://lorocue.webs.com/ lorocue
  • Vasily

    Hello,

    I have one suggestion to change
    DecodeThread.java
    from result = new String(decoder.decode(new J2MEImage(image)));
    to result = new String(decoder.decode(new J2MEImage(image)), “UTF-8″);

    It would give an option to handle multi byte chars after decoding.

    Thanks,
    Vasily

  • Leo

    Is it possible to read more than one qr code at a time?

  • Marco

    Is it possible to switch the qrcode image with a custom image like a logotype?

  • Mikey

    Nice post. Check out the free dynamic qr code generator at http://www.bwscan.com with free scan analytics including geolocation tracking.

  • Catherine

    Hey Daniel, I was just doing a research on QR Code when I found this page. But I’ve already used
    http://generator.onbarcode.com/online-qr-code-barcode-generator.aspx
    to generate QR Code FREE online. It’s very convenient, you should really have a try~
    And I also found this barcode reader software, free demo download, with 20+barcode types supported~ Isn’t it great?
    http://www.onbarcode.com/scanner/

  • Ivy

    Of course Leo, I just found a .NET barcode reader which supports reading multiple barcodes in one image, or even scan multiple-page TIFF~
    http://onbarcode.com/products/net_barcode_reader/
    You can simply download and try it out~

  • Anderson Antunes

    Hi Daniel, you know some library to encode QR Codes in Processing? I tried to use some written in Java, but it did not work :(

  • Anonymous

    some info: http://stackoverflow.com/questions/1137415/qr-codes-image-generator-in-java-open-source-but-no-gpl