During todays Raspberry Pi jam in Exeter. Tom Brough helped me to fix this. I now have a working program. This works on the pi, but it is slow. Do NOT enable video on the pi in terms of showing the preview screen
proc.visible = False
Should be set as above to False on the pi, if you’re running on a faster device, PC for example then it is fine to have the preview window up.
proc.visible = True
So those of you who have been following this blog will know this has been an on going project for a while and is actually linked to the Curledge street academy computer group.
#!/usr/bin/python from sys import argv import zbar import turtle import time #init turtle t = turtle.Pen() #reate array instructions =  # create a Processor proc = zbar.Processor() # configure the Processor proc.parse_config('enable') # initialize the Processor device = '/dev/video0' if len(argv) > 1: device = argv proc.init(device) # enable the preview window proc.visible = False result = "" # read at least one barcode (or until window closed) while(result != "run"): proc.process_one() # Extract (single) result from process_one() above for i in proc.results: result = i.data instructions.append(result) print result # hide the preview window proc.visible = False for i in instructions: if (i == "forward5"): print "forward 5 pixels" turtle.forward(25) elif (i =="forward10"): print"forward 10 pixels" turtle.forward(100) elif (i =="turn45"): print"turn 45" turtle.left(270) elif (i == "turn90"): print "turn 90" turtle.left(90) time.sleep(60)
Feel free to grab the code from
https://github.com/zleap/qrturtle it is turtle3,py
The rest of the files are there for legacy purposes, you will need to install the python-zbar module. which in debian, Lubuntu, raspbian is
python-zbar – bar code scanner and decoder (Python bindings)
Install in the usual way.
The code above is part based on the following
and was added to by Myself and Tom Brough. We are both members of the Devon and Cornwall GNU / Linux user group.
What this does:
Waits for a qr code
scans the qr code
waits for the next qr code
qr codes are stored in an array
if the qr code run is read, the instructions stored in the array are read and the turtle draws lines or turns depending on the instruction.