本文整理汇总了Python中sensor.set_contrast函数的典型用法代码示例。如果您正苦于以下问题:Python set_contrast函数的具体用法?Python set_contrast怎么用?Python set_contrast使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_contrast函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_color_bars
def test_color_bars():
sensor.reset()
# Set sensor settings
sensor.set_brightness(0)
sensor.set_saturation(0)
sensor.set_gainceiling(8)
sensor.set_contrast(2)
# Set sensor pixel format
sensor.set_framesize(sensor.QVGA)
sensor.set_pixformat(sensor.RGB565)
# Enable colorbar test mode
sensor.set_colorbar(True)
# Skip a few frames to allow the sensor settle down
# Note: This takes more time when exec from the IDE.
for i in range(0, 100):
image = sensor.snapshot()
# Color bars thresholds
t = [lambda r, g, b: r < 50 and g < 50 and b < 50, # Black
lambda r, g, b: r < 50 and g < 50 and b > 200, # Blue
lambda r, g, b: r > 200 and g < 50 and b < 50, # Red
lambda r, g, b: r > 200 and g < 50 and b > 200, # Purple
lambda r, g, b: r < 50 and g > 200 and b < 50, # Green
lambda r, g, b: r < 50 and g > 200 and b > 200, # Aqua
lambda r, g, b: r > 200 and g > 200 and b < 50, # Yellow
lambda r, g, b: r > 200 and g > 200 and b > 200] # White
# 320x240 image with 8 color bars each one is approx 40 pixels.
# we start from the center of the frame buffer, and average the
# values of 10 sample pixels from the center of each color bar.
for i in range(0, 8):
avg = (0, 0, 0)
idx = 40*i+20 # center of colorbars
for off in range(0, 10): # avg 10 pixels
rgb = image.get_pixel(idx+off, 120)
avg = tuple(map(sum, zip(avg, rgb)))
if not t[i](avg[0]/10, avg[1]/10, avg[2]/10):
raise Exception("COLOR BARS TEST FAILED. "
"BAR#(%d): RGB(%d,%d,%d)"%(i+1, avg[0]/10, avg[1]/10, avg[2]/10))
print("COLOR BARS TEST PASSED...")
示例2: range
import sensor, time
sensor.reset()
# Set sensor settings
sensor.set_brightness(0)
sensor.set_saturation(0)
sensor.set_gainceiling(8)
sensor.set_contrast(2)
# Set sensor pixel format
sensor.set_framesize(sensor.QVGA)
sensor.set_pixformat(sensor.RGB565)
# Enable colorbar test mode
sensor.set_colorbar(True)
# Skip a few frames to allow the sensor settle down
for i in range(0, 30):
image = sensor.snapshot()
#color bars thresholds
t = [lambda r, g, b: r < 50 and g < 50 and b < 50, # Black
lambda r, g, b: r < 50 and g < 50 and b > 200, # Blue
lambda r, g, b: r > 200 and g < 50 and b < 50, # Red
lambda r, g, b: r > 200 and g < 50 and b > 200, # Purple
lambda r, g, b: r < 50 and g > 200 and b < 50, # Green
lambda r, g, b: r < 50 and g > 200 and b > 200, # Aqua
lambda r, g, b: r > 200 and g > 200 and b < 50, # Yellow
lambda r, g, b: r > 200 and g > 200 and b > 200] # White
#320x240 image with 8 color bars each one is approx 40 pixels.
示例3:
import sensor
sensor.set_contrast(1)
sensor.set_gainceiling(8)
sensor.set_framesize(sensor.QQVGA)
sensor.set_pixformat(sensor.RGB565)
image = sensor.snapshot()
image.save("/test.ppm")
示例4: gaze
# Iris Detection 2 Example
#
# This example shows how to find the eye gaze (pupil detection) after finding
# the eyes in an image. This script uses the find_eyes function which determines
# the center point of roi that should contain a pupil. It does this by basically
# finding the center of the darkest area in the eye roi which is the pupil center.
#
# Note: This script does not detect a face first, use it with the telephoto lens.
import sensor, time, image
# Reset sensor
sensor.reset()
# Sensor settings
sensor.set_contrast(3)
sensor.set_gainceiling(16)
# Set resolution to VGA.
sensor.set_framesize(sensor.VGA)
# Bin/Crop image to 200x100, which gives more details with less data to process
sensor.set_windowing((220, 190, 200, 100))
sensor.set_pixformat(sensor.GRAYSCALE)
# Load Haar Cascade
# By default this will use all stages, lower stages is faster but less accurate.
eyes_cascade = image.HaarCascade("eye", stages=24)
print(eyes_cascade)