(an alternative to the steps here might be this: http://pyqrcode.sourceforge.net/ but that didn't work easily for me in recent Ubuntus)
These instructions:
http://hi.baidu.com/paulau/blog/item/915e860ffbf7032c6059f34c.html
cover most of the steps, but lots of details need changing now vs. 2008.
The PyQrcodec_Linux.tar.gz mentioned in various places on the web has disappeared from www.pedemonte.eu - in fact that whole domain is gone. You can get it from http://gentoo.mirrors.pair.com/distfiles/PyQrcodec_Linux.tar.gz
The instructions above say:
sudo apt-get install g++ sudo apt-get install python-dev sudo apt-get install libcv-dev libcvaux-dev
in addition you now need
sudo apt-get install libhighgui-dev
Untar and cd into the PyQrCodec folder.
then edit setup.py and add
extra_compile_args = ['-fpermissive'],
before each of the "sources = ..." lines.
then in the shell run (once and once only)
for file in $(grep -lre BEGIN ./*|grep -v svn); do sed -e "s/_BEGIN_/_CV_BEGIN_/;s/_END_/_CV_END_/" $file -i; done
now python setup.py build and sudo python setup.py install
should work (with all kinds of warnings).
The how to use example should be:
import PyQrcodec size, image = PyQrcodec.encode('www.example.com') image.save('example.png') status, text = PyQrcodec.decode('example.png') print(text)
.encode() params are:
Definition: PyQrcodec.encode(string, image_width=400, case_sensitive=True, version=5, error_correction_level='QR_ECLEVEL_L', encoding_hint='QR_MODE_AN') Docstring: Returns a PIL image of the QR code generated from the given string
Note: for http://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Wikipedia_mobile_en.svg/220px-Wikipedia_mobile_en.svg.png I had to flatten the image (replace the transparent background) for decode() to work.
No comments:
Post a Comment