mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Update Python examples
This commit is contained in:
parent
2ea09a43db
commit
98a086effe
@ -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))
|
||||||
@ -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()
|
||||||
|
|||||||
@ -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)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user