Barcodes 4 Processing

"A Processing library to decode and handle barcodes inside sketches."

This library was created to integrate into processing v1.0 the wonderful barcode decoding library called ZXING that you can find on google code here

http://code.google.com/p/zxing/

So nothing big was created by me, apart from the integration process. Which is also very limited in scope.

That's why I am releasing this code with no licensing whatsoever. Do what you want with it, but please respect the licensing of the ZXINg libraries: you can find it in their software distribution packages. Please read it all up.

As for this small library: feel free and encouraged to make it better and more functional.

And please send me a note if you do something with it, as I'd love to see it and publish it over at Art is Open Source.

Best,
xDxD.vs.xDxD[at]gmail.com
http://www.artisopensource.net


NEW VERSION AVAILABLE!

use this link below to download the QRCode library:

[ download library ]

[ browse documentation ]

[ browse examples ]

[ browse sourcecode ]

The library comes complete with reference and example sketches, in standard Processing format.

Just unzip it in your libraries folder (found in the sketches directory if you're using Processing 1.0 and afterwards) and restart Processing.

The library was originally coded by me ( xDxD ) and was later completed by Rolf van Gelder of CAGE, who added the QRCode creation functionalities, and the possibility to handle the codes directly from a PImage instead than from a file.

Read below for usage examples (the syntax hasn't changed in new versions) and try out the examples in the ZIP.

OLD VERSIONS BELOW

The text below here is left solely for the sake of completeness (there will be some of you having linked files below here, right).

Please use the info above instead.


Here are some example sketches:

[ sketch 1: Barcode Music ]

Here you can download the library:

[DOWLOAD]


Thanks to Rolf van Gelder of CAGE we have a new improved version of the library!

You can download it here:

[DOWNLOAD NEW VERSION]

And here you can find the JavaDocs for your reference:

[JAVADOCS]

The JavaDocs are also included in the ZIP archive.

Just extract the ZIP archive: it contains a "zxing4processing" directory. This directory must be placed in your Processing "library" directory for it to be accessible from the development environment.

While you develop your sketches, just choose "Import Library" from the Sketch menu, and select "zxing4processing" from the list.

This import statement will be placed on top of your sketche's code:

import com.aos.zxing4processing.*;

Great! You have imported the Library.

To use it you must figure out if you intend to use it on the web or on a standalone application. There are two methods in the class to decode images, and they are different in the fact that, to satisfy Java security policies for applets, one uses the Applet's codeBase to access the barcode's image, while the other can load any image, as standalone applications can do that, opening files, URLs, anything.

You can check out the code in these pages' example, as it's really really simple. Here's a short explanation of the methods:

First instatiate the ZXING4P class:

ZXING4P barcodeDecoder;

barcodeDecoder = new ZXING4P(this);


Then have a barcode image available in a file

Feed the filename to the appropriate method.

If you are inside a standalone appication use:

Vector results = barcodeDecoder.decode(true,"\\pictures\\barcodes\\01.jpg");
The first parameter activates a recognition scheme that takes somewhat longer to complete, but is more accurate.

The method returns a Vector, as it can recognize more than one string in the barcode. You can also pass a whole directory as a second parameter for the method call, and the software will scan the whole directory and try to process any image file it finds there: all the results of the successfully decoded barcodes will be placed in teh Vector as Strings.

If you are inside an Applet use:

String relativeURL = "uploads/barcodeImages/01.png";
Vector responses = barcodeDecoder.decodeWeb(true,relativeURL,getCodeBase());


The first parameter is the same as before. The second parameter points to a relative URL where the barcode image to be decoded can be found. The third parameter is the applet's codeBase (you can use this exact code to fill in the third parameter).

And, basically, that's it! :)