Example: 02-Image-Processing/01-Image-Filters/color_binary_filter.py
import sensor
import time
sensor.reset()
sensor.set_framesize(sensor.QVGA)
sensor.set_pixformat(sensor.RGB565)
sensor.skip_frames(time=2000)
clock = time.clock()
red_threshold = (0, 100, 0, 127, 0, 127)
green_threshold = (0, 100, -128, 0, 0, 127)
blue_threshold = (0, 100, -128, 127, -128, 0)
while True:
for i in range(100):
clock.tick()
img = sensor.snapshot()
img.binary([red_threshold])
print(clock.fps())
for i in range(100):
clock.tick()
img = sensor.snapshot()
img.binary([green_threshold])
print(clock.fps())
for i in range(100):
clock.tick()
img = sensor.snapshot()
img.binary([blue_threshold])
print(clock.fps())
for i in range(100):
clock.tick()
img = sensor.snapshot()
img.binary([red_threshold], invert=1)
print(clock.fps())
for i in range(100):
clock.tick()
img = sensor.snapshot()
img.binary([green_threshold], invert=1)
print(clock.fps())
for i in range(100):
clock.tick()
img = sensor.snapshot()
img.binary([blue_threshold], invert=1)
print(clock.fps())