Example: 02-Image-Processing/01-Image-Filters/grayscale_binary_filter.py
import sensor
import time
sensor.reset()
sensor.set_framesize(sensor.QVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.skip_frames(time=2000)
clock = time.clock()
low_threshold = (0, 50)
high_threshold = (205, 255)
while True:
for i in range(100):
clock.tick()
img = sensor.snapshot()
img.binary([low_threshold])
print(clock.fps())
for i in range(100):
clock.tick()
img = sensor.snapshot()
img.binary([high_threshold])
print(clock.fps())
for i in range(100):
clock.tick()
img = sensor.snapshot()
img.binary([low_threshold], invert=1)
print(clock.fps())
for i in range(100):
clock.tick()
img = sensor.snapshot()
img.binary([high_threshold], invert=1)
print(clock.fps())