mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
24 lines
488 B
Python
24 lines
488 B
Python
import time, sensor, image
|
|
|
|
# Reset sensor
|
|
sensor.reset()
|
|
|
|
# Set sensor settings
|
|
sensor.set_brightness(0)
|
|
sensor.set_saturation(0)
|
|
sensor.set_gainceiling(16)
|
|
sensor.set_contrast(2)
|
|
sensor.set_framesize(sensor.QQVGA)
|
|
sensor.set_pixformat(sensor.GRAYSCALE)
|
|
|
|
# Load template
|
|
template = image.Image("/template.pgm")
|
|
|
|
# Run template matching
|
|
while (True):
|
|
img = sensor.snapshot()
|
|
r = img.find_template(template, 0.75)
|
|
if r:
|
|
img.draw_rectangle(r)
|
|
time.sleep(50)
|