@kidswong999 在 这个是什么问题,求助????怎么解决??? 中说:
请提供全部的代码,可以运行的文本
import sensor, image, time
from pyb import UART
import json
yellow_threshold = (35, 56, -6, 127, -1, 104)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(10)
sensor.set_auto_whitebal(False)
clock = time.clock()
uart = UART(3, 115200)
def find_max(blobs):
max_size=0
for blob in blobs:
if blob.pixels() > max_size:
max_blob=blob
max_size = blob.pixels()
return max_blob
def tongxin():
img = sensor.snapshot()
blobs = img.find_blobs([yellow_threshold])
if blobs:
max_blob=find_max(blobs)
print('sum :', len(blobs))
img.draw_rectangle(max_blob.rect())
img.draw_cross(max_blob.cx(), max_blob.cy())
output_str='2'
return('you send:',output_str)
uart.write(output_str)
else:
return('not found!')
while(True):
uart.write('2')
#print(a)
if uart.any():
b=uart.readline()
print(b)