@kidswong999 请问哪里出了问题
Z
zskd
@zskd
0
声望
5
楼层
320
资料浏览
0
粉丝
0
关注
zskd 发布的帖子
-
RE: 为什么提示NameError: name 'rgb_to_grayscale' is not defined?
# Untitled - By: wx601 - 周日 2月 17 2019 import sensor, image, time #颜色追踪的例子,一定要控制环境的光,保持光线是稳定的 red_threshold = (40, 74, 22, 64, -6, 18) sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time = 2000) sensor.set_auto_gain(False) # must be turned off for color tracking sensor.set_auto_whitebal(False) # must be turned off for color tracking clock = time.clock() clock = time.clock() while(True): clock.tick() img = sensor.snapshot() gray =img.rgb_to_grayscale() rectanges = gray.find_rects() for rectange in rectanges : area = rectange.rect() blobs = img.find_blobs([red_threshold],roi=area,x_stride=5,y_stride=5) if blobs: for blob in blobs: img.draw_rectangle(blob.rect())#, color=White img.draw_cross(blob.cx(), blob.cy(), size=5)