openmv/usr/examples/15-Tests/test_binary_2.py
Kwabena W. Agyeman 9e5d379c18 Remove old code.
Pixels, centroid, and orientation are calculated in the blob code now.
As for threshold, it is no longer needed (plus, it required storing a
secondary image in RAM which isn't really something we can handle).
2016-04-09 19:32:14 -04:00

33 lines
1.0 KiB
Python

import pyb, sensor, image, math
sensor.reset()
sensor.set_framesize(sensor.QVGA)
sensor.set_pixformat(sensor.RGB565)
red_threshold = (0,100, 0,127, 0,127) # L A B
green_threshold = (0,100, -128,0, 0,127) # L A B
blue_threshold = (0,100, -128,127, -128,0) # L A B
while(True):
# Test red threshold
for i in range(100):
img = sensor.snapshot()
img.binary([red_threshold])
# Test green threshold
for i in range(100):
img = sensor.snapshot()
img.binary([green_threshold])
# Test blue threshold
for i in range(100):
img = sensor.snapshot()
img.binary([blue_threshold])
# Test not red threshold
for i in range(100):
img = sensor.snapshot()
img.binary([red_threshold], invert = 1)
# Test not green threshold
for i in range(100):
img = sensor.snapshot()
img.binary([green_threshold], invert = 1)
# Test not blue threshold
for i in range(100):
img = sensor.snapshot()
img.binary([blue_threshold], invert = 1)