Update Python examples

This commit is contained in:
iabdalkader 2014-06-19 23:21:59 +02:00
parent 2ea09a43db
commit 98a086effe
3 changed files with 25 additions and 10 deletions

View File

@ -5,4 +5,5 @@ sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_brightness(-2) sensor.set_brightness(-2)
image = sensor.snapshot() image = sensor.snapshot()
image.draw_circle((50, 50), 10) image.draw_circle((50, 50), 10)
image.draw_rectangle((10, 10, 50, 50))

View File

@ -1,4 +1,11 @@
import sensor import sensor, time, led
# Set sensor contrast
sensor.set_contrast(1)
# Set sensor brightness
sensor.set_brightness(-1)
# Set sensor pixel format
sensor.set_pixformat(sensor.RGB565) sensor.set_pixformat(sensor.RGB565)
while (True): while (True):
image = sensor.snapshot() image = sensor.snapshot()

View File

@ -1,11 +1,18 @@
import sensor, imlib, time import sensor, time
# Set sensor contrast
sensor.set_contrast(1)
# Set sensor brightness
sensor.set_brightness(-2)
# Set sensor to pixel format
sensor.set_pixformat(sensor.GRAYSCALE) sensor.set_pixformat(sensor.GRAYSCALE)
template = imlib.load_template("0:/minion.template")
clock = time.clock() # Load template
template = Image("0:/template.pgm")
# Run template matching
while (True): while (True):
clock.tick()
image = sensor.snapshot() image = sensor.snapshot()
obj = imlib.template_match(image, template, 0.7) r = image.find_template(template, 0.75)
if obj: if r:
imlib.draw_rectangle(image, obj) image.draw_rectangle(r)
print (clock.fps()) time.sleep(50)