python-quirc Documentation

Similar documents
Nirvana Documentation

Avpy Documentation. Release sydh

Roman Numeral Converter Documentation

bottle-rest Release 0.5.0

obfuscator Documentation

Python wrapper for Viscosity.app Documentation

django-wiki Documentation

Programming for Non-Programmers

Aircrack-ng python bindings Documentation

filemagic Documentation

streamio Documentation

Pyganim Documentation

Image Slicer Documentation

Python Utils Documentation

pyautocad Documentation

Mutation Testing in Patterns Documentation

Speeding up Python using Cython

picrawler Documentation

Release Fulfil.IO Inc.

CS Lab 8. Part 1 - Basics of File I/O

Simple libtorrent streaming module Documentation

All Yarns Are Beautiful Documentation

Python Utils Documentation

TPS Documentation. Release Thomas Roten

VIP Documentation. Release Carlos Alberto Gomez Gonzalez, Olivier Wertz & VORTEX team

Blockext Documentation

lazy-object-proxy Release 1.3.1

zbarlight Release 2.1.dev0

goose3 Documentation Release maintainers

gunny Documentation Release David Blewett

nptdms Documentation Release Adam Reeve

Python Project Example Documentation

Python simple arp table reader Documentation

g-pypi Documentation Release 0.3 Domen Kožar

Archan. Release 2.0.1

Simple Binary Search Tree Documentation

pykafka Release dev.2

Lazarus Documentation

Tissu for Fabric Documentation

PyCRC Documentation. Release 1.0

YouTube API Wrapper Documentation

mole Documentation Release 1.0 Andrés J. Díaz

imread Documentation Release 0.6 Luis Pedro Coelho

openpyxl Documentation

boost Documentation Release 0.1 Carl Chenet

yagmail Documentation

django-embed-video Documentation

pysharedutils Documentation

chatterbot-weather Documentation

Image Processing (1) Basic Concepts and Introduction of OpenCV

PyTexturePacker Documentation

Django-CSP Documentation

Poetaster. Release 0.1.1

Intelligent Setup input

1. Find the type and value of each of the following expressions. Warning: several of these expressions will result in an error.

spnav Documentation Release 0.9 Stanley Seibert

tinycss Documentation

Piexif Documentation. Release 1.0.X. hmatoba

PyEFD Documentation. Release 1.0. Henrik Blidh

CS 1301 Exam 2 Fall 2013

django-embed-video Documentation

PyCPUID Documentation

AtomGen Documentation

Python Schema Generator Documentation

pynetworktables2js Documentation

PhreeqPy Documentation

python-json-patch Documentation

OpenUpgrade Library Documentation

The State of Python. and the web. Armin Ronacher

pyagar Documentation Release Roberto Abdelkader Martínez Pérez

django-embed-video Documentation

Release 0.8. Repoze Developers

Django QR Code Documentation

Piexif Documentation. Release 1.0.X. hmatoba

django-allauth-2fa Documentation

driver Documentation

Pykemon Documentation

e24paymentpipe Documentation

PYTHON IS SLOW. Make it faster with C. Ben Shaw

python-snap7 Documentation

8/16/12. Computer Organization. Architecture. Computer Organization. Computer Basics

gpib-ctypes Documentation

PySoundFile Documentation Release 0.6.0

Poulpe Documentation. Release Edouard Klein

Celery-RabbitMQ Documentation

ITESM CEM Cuauhtemoc Carbajal. Reference:

Nutmeg Documentation. Release 0.1. Christopher Ham

pymonetdb Documentation

Python AMT Tools Documentation

Python 3 10 years later

python-twitch-stream Documentation

SpongeShaker. Release 1.1

pyshk Documentation Release Jeremy Low

django-model-utils Documentation

Koalix ERP. Release 0.2

Installing and Running PyOpenGL (Windows)

PyZabbixObj Documentation

dmrlib Documentation Release Wijnand Modderman-Lenstra

maya-cmds-help Documentation

HAProxy log analyzer Documentation

Transcription:

python-quirc Documentation Release 0.8.0 SvartalF May 27, 2012

CONTENTS 1 Install 3 1.1 Requirements............................................... 3 2 Usage 5 2.1 High-level API.............................................. 5 2.2 Streaming................................................. 5 2.3 Low-level API.............................................. 6 2.4 Data format................................................ 7 3 Indices and tables 9 i

ii

python-quirc Documentation, Release 0.8.0 python-quirc is a ctypes bindings for quirc, C library for QR codes recognition. As well as a base library, it has a good features for QR code recognition: It is fast enough to be used with realtime video. It has two levels API: high-level for quick and simple decoding and low-level for those, who wants to control everything. It is small, and doesn t have any dependencies (except of the C library, of course). It has a very small memory footprint. It works under the CPython 2.5, 2.6, 2.7 and PyPy. Python 3k support is planned. Contents: CONTENTS 1

python-quirc Documentation, Release 0.8.0 2 CONTENTS

CHAPTER ONE INSTALL Install it with pip: pip install quirc Or with setuptools: easy_install -U quirc 1.1 Requirements This library optionally requires the image processing library for reading images. At now, the only one supported library is a PIL or it s fork Pillow. Ability to use any other libraries, such a ImageMagick, is in the future plans. 3

python-quirc Documentation, Release 0.8.0 4 Chapter 1. Install

CHAPTER TWO USAGE Library usage splits into a two parts: high-level and low-level API. In a sunny and beautiful world you will need only a high-level API. For decoding images from the video streaming in the realtime use Streaming decoder (TODO: link). But if you are have not so much free memory or want to control whole the process, use a low-level API. 2.1 High-level API It is very simple in use: import quirc from PIL import Image for code in quirc.decode(image.open( images/qr-code.png )): print code 2.2 Streaming In case if you are detect QR codes from video stream or something else, creating all required structures for each frame is very expensive. In that case you can operate Low-level API (TODO: Link) or use quirc.decoder. 2.2.1 Usage Create new decoder and supply to it frame width and height: quirc.decoder(640, 480). For each frame call decoder method decode() and apply to it raw pixels binary data. Attention! Streaming decoder suppress quirc.decodeexception, because if current frame cannot be decoded, it must not crash a program. import quirc # Create new decoder with frame size decoder = quirc.decoder(640, 480) while True: 5

python-quirc Documentation, Release 0.8.0 # Use OpenCV or something else here # In this example, here is a pseudo-code image = get_new_frame_from_camera() # Convert it to the grayscale, so each byte will represent one pixel image.convert( grayscale ) for code in decoder.raw(image.to_string()): print code.text 2.3 Low-level API Low-level API fully copies the C API and is contained in the quirc.api module. See example for workflow. Warning: you will need to use ctypes here manually. 2.3.1 Functions Initialization Recognition Extraction Miscellaneous 2.3.2 Classes 2.3.3 Example from quirc import api from PIL import Image image = Image.open( images/qr-code.png ) width, height = image.size # Convert image to the grayscale mode if not image.mode in ( L, 1 ): image = image.convert( L ) pixels = image.load() obj = api.new() api.resize(obj, width, height) buffer = api.begin(obj, width, height) # Fill buffer with a image pixels. One cell, one pixel. idx = 0 for i in range(width): for j in range(height): buffer[idx] = ctypes.c_uint8(pixels[j, i]) 6 Chapter 2. Usage

python-quirc Documentation, Release 0.8.0 idx += 1 # Finish image recognition api.end(obj) code = api.structures.code() data = api.structures.data() for i in range(api.count(obj)): api.extract(obj, i, code) api.decode(code, data) print ctypes.string_at(data.payload, data.payload_len) api.destroy(obj) 2.4 Data format All functions of the library receives image data in a binary format. There is some rules that must be applied to your data: Data length must be equal to the width * height of the image. Each byte must represent one pixel, so you will need manually to convert it to the grayscale or black&white mode. 2.4. Data format 7

python-quirc Documentation, Release 0.8.0 8 Chapter 2. Usage

CHAPTER THREE INDICES AND TABLES genindex modindex search 9