W
wnhp
@wnhp
0
声望
2
楼层
261
资料浏览
0
粉丝
0
关注
wnhp 发布的帖子
-
多颜色识别时,有黄色和蓝色时,print(blob.code())输出不应该是6嘛?但输出是2 4,请问这是为什么?
import sensor, image, time, math thresholds = [(70, 30, 25, 61, 32, -22), # generic_red_thresholds -> index is 0 so code == (1 << 0) (31, 95, -1, 53, 71, 17), # generic_YELLOW_thresholds -> index is 1 so code == (1 << 1) (75, 25, -18, 22, -21, -63)]# generic_blue_thresholds sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) 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() while(True): clock.tick() img = sensor.snapshot() for blob in img.find_blobs(thresholds,merge=True, pixels_threshold=200, area_threshold=200): img.draw_rectangle(blob.rect()) img.draw_cross(blob.cx(), blob.cy()) print(blob.code())