import sensor, image, time
from pyb import UART
uart = UART(3,19200)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
A=uart.read()==b'0x31'
B=uart.read()==b'0x32'
while(True):
clock.tick()
img=sensor.snapshot()
while(A):
#clock.tick()
#img = sensor.snapshot()
for c in img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10,r_min = 2, r_max = 100, r_step = 2):
img.draw_circle(c.x(), c.y(), c.r(), color = (0, 255, 0))
if(c.x()>90):
uart.write("d\r")
else:
if(c.x()<70):
uart.write("c\r")
else:uart.write("e\r")
if(c.y()>70):
uart.write("a\r")
else:
if(c.x()<50):
uart.write("b\r")
else:uart.write("e\r")
time.sleep(1)
while(B):
#clock.tick()
thresholds1 = [(30,100,15,127,15,127),(0, 60, -8, 69, -125, -3),(25, 53, -74, -23, 28, 58)]
#img = sensor.snapshot()
for blob in img.find_blobs(thresholds1, pixels_threshold=500, area_threshold=2000):
img.draw_rectangle(blob.rect())
img.draw_cross(blob.cx(), blob.cy())
uart.write(blob.code())
我开始运行后,他软件内显示到的图像活动几秒后就不动了,然后自动结束进程,请问这怎么解决?