代码出现问题
-
import sensor, image, time sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time=2000) sensor.set_auto_gain(False) sensor.set_auto_whitebal(False) clock=time.clock() threshold=[(23, 73, 19, 93, 8, 54),(70, 27, -71, -18, -21, 41), (32, 61, -66, 58, -99, -58)] #红色 绿色 蓝色 while(True): clock.tick() img=sensor.snapshot() for blob in img.find_blobs(threshold,pixels_threshold=400,area_threshold=400): img.draw_rectangle(blob.rect()) img.draw_cross(blob.cx(),blob.cy()) red_blobs=img.find_blobs[(23, 73, 19, 93, 8, 54)] green_blobs=img.find_blobs[(70, 27, -71, -18, -21, 41)] blue_bobs=img.fing_blobs[(32, 61, -66, 58, -99, -58)] red_blob=red_blobs[0] green_blob=green_blobs[0] blue_blob=blue_blobs[0] redX=red_blob.cx() greenX=green_blob.cx() blueX=blue_blob.cx() if(redX>=greenX): print('red')
-
函数的调用应该用小括号扩起来(,而不是中括号[
img.find_blobs(阈值)
而不是
img.find_blobs[阈值]