openmv/usr/examples/10-Tests/test_binary_2.py
Kwabena W. Agyeman 94bc225542 Moved examples arround.
Tried to emulate Arduino's 11 folders... I'd perfer to have all the
shield scripts in one folder... but, that might not make sense. I don't
really want one script per folder however. So, I might merge some more
stuff in the future. I have a grand idea here that will become evident as
I work though the examples.

Anyway, the current structure is not final. It will be in flux for a
little while.

As for Git History, folder history is the best we're going to get. Git
and GitHub don't seem to deal with moves too well.
2016-03-30 21:30:11 -04:00

45 lines
1.8 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])
sum, x, y, rads = img.orientation_radians()
img.draw_keypoints([(x, y, rads)], color = (255, 0, 0), size = 20)
# Test green threshold
for i in range(100):
img = sensor.snapshot()
img.binary([green_threshold])
sum, x, y, rads = img.orientation_radians()
img.draw_keypoints([(x, y, rads)], color = (0, 255, 0), size = 20)
# Test blue threshold
for i in range(100):
img = sensor.snapshot()
img.binary([blue_threshold])
sum, x, y, rads = img.orientation_radians()
img.draw_keypoints([(x, y, rads)], color = (0, 0, 255), size = 20)
# Test not red threshold
for i in range(100):
img = sensor.snapshot()
img.binary([red_threshold], invert = 1)
sum, x, y, rads = img.orientation_radians()
img.draw_keypoints([(x, y, rads)], color = (255, 0, 0), size = 20)
# Test not green threshold
for i in range(100):
img = sensor.snapshot()
img.binary([green_threshold], invert = 1)
sum, x, y, rads = img.orientation_radians()
img.draw_keypoints([(x, y, rads)], color = (0, 255, 0), size = 20)
# Test not blue threshold
for i in range(100):
img = sensor.snapshot()
img.binary([blue_threshold], invert = 1)
sum, x, y, rads = img.orientation_radians()
img.draw_keypoints([(x, y, rads)], color = (0, 0, 255), size = 20)