43

Looking for free/opensource code or description of algorithms to code (simple) and decode (hard) the 2D barcode QR code.

It doesn't seem like a trivial problem, but it's so popular in Japan that there must be something already available...

Adam Davis
  • 91,931
  • 60
  • 264
  • 330
  • 14
    Apparently the Japanese specification of QR codes is free, but the International Standards Committee (ISO), decided to charge over 200 Swiss francs for the English version. If the English version is just a translation of the Japanese one then I'd say for that price, it's totally unethical. – helloworlder Feb 24 '10 at 08:38
  • To understand the reed solomon error code specififcation used in qr code refer http://math.stackexchange.com/questions/76045/reed-solomon-polynomial-generator – Dungeon Hunter Nov 04 '11 at 05:27

9 Answers9

31

I have a colleague who worked on ZXing ("Zebra Crossing").

That's got a fair variety of platform support.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
12

http://www.swetake.com/qrcode/qr1_en.html

Just thought I'd mention this one which is explaining HOW they work.

Scimon Proctor
  • 4,558
  • 23
  • 22
11

(In response to those asking about QR codes in PHP)

The Google Charts QR chart type might work for you, if you don't expect a lot of traffic, or if you can cache the images. It's extremely easy to use- just put the text to encode in the URL.

Ryan Fox
  • 10,103
  • 5
  • 38
  • 48
10

Here's a good LGPL library for encoding QR code libqrencode

Libqrencode is a C library for encoding data in a QR Code symbol, a kind of 2D symbology that can be scanned by handy terminals such as a mobile phone with CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and is highly robust.

Here's a Google code project that decodes QR code - aimed at iPhone, but is LGPL and the source is available. Should be adaptable...

-Adam

Adam Davis
  • 91,931
  • 60
  • 264
  • 330
  • 1
    For those looking to encode and decode datamatrix codes (another common 2D barcode format) then http://libdmtx.sourceforge.net/ is a C library that encodes and decodes them. – Adam Davis Feb 15 '10 at 21:00
8

PyQrCodec is a Python library for encoding Qr codes to a PNG and decoding them from a variety of image formats.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Jaearess
  • 677
  • 1
  • 7
  • 10
2

You can find c# example here http://twit88.com/home/opensource/qrcode for free (only need to register)

Pablo Retyk
  • 5,690
  • 6
  • 44
  • 59
2

You can use zbar directly to decode the qrcode.

#!/usr/bin/python

from sys import argv
import zbar
import Image


# create a reader
scanner = zbar.ImageScanner()

# configure the reader
scanner.parse_config('enable')

# obtain image data    
pil = Image.open("base.png").convert('L')
width, height = pil.size
raw = pil.tostring()

# wrap image data
image = zbar.Image(width, height, 'Y800', raw)

# scan the image for barcodes
scanner.scan(image)

# extract results
for symbol in image:
    # do something useful with results
    print 'decoded', symbol.type, 'symbol', '"%s"' % symbol.data

# clean up
del(image)
1

You can try python-qrtools: https://launchpad.net/qr-tools It uses qrencode for generating and zbar for decoding (from webcam or a file ;-)

ralgozino
  • 11
  • 1