D
@kidswong999
没有出现报错 就是会时不时出现上面的问题
import sensor, image, time
from pyb import UART
thresholds = [(67, 100, -21, 127, -9, 127)]
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False)
sensor.set_auto_whitebal(False)
clock = time.clock()
uart = UART(3, 9600)
while(True):
clock.tick()
img = sensor.snapshot()
for blob in img.find_blobs([thresholds[0]] , x_stride = 2, y_stride = 1):
img.draw_rectangle(blob.rect())
img.draw_cross(blob.cx(),blob.cy())
if blob.cx() > 527 or blob.cx() < 143 or blob.cy() > 383 or blob.cy() < 89:
time.sleep_ms(1250)
break
else:
x_location = (blob.cx() - 335)(105 / 384)
y_location = (blob.cy() - 236)(80 / 294)
str1 = "*0,%.2f,%.2f=" % (x_location,y_location)
if len(str1) > 17 or len(str1) < 13:
time.sleep_ms(1250)
break
# print(str1)
uart.write(str1)
time.sleep_ms(1250)