RGB图像代码:
import sensor, image, time
sensor.reset()
sensor.set_framesize(sensor.QVGA)
sensor.set_pixformat(sensor.RGB565)
sensor.skip_frames(time = 2000)
clock = time.clock()
# Use the Tools -> Machine Vision -> Threshold Edtor to pick better thresholds.
threshold_dark = (70, 100, -77, 76, 19, 74)
gray_threshold = (80, 255)
while(True):
clock.tick()
img = sensor.snapshot()
img.binary([threshold_dark])
# img.erode(100)
# img.dilate(5)
print(img)
灰度值图像代码
# Color Binary Filter Example
#
# This script shows off the binary image filter. You may pass binary any
# number of thresholds to segment the image by.
import sensor, image, time
sensor.reset()
sensor.set_framesize(sensor.QVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.skip_frames(time = 2000)
sensor.set_auto_whitebal(True) # 开启自动白平衡
clock = time.clock()
# Use the Tools -> Machine Vision -> Threshold Edtor to pick better thresholds.
threshold_dark = (70, 100, -77, 76, 19, 74)
threshold_light = (86, 100, -26, 8, -3, 45)
gray_threshold = (80, 255)
while(True):
clock.tick()
img = sensor.snapshot()
img.binary([gray_threshold])
# img.erode(100)
# img.dilate(5)
print(img)