请在这里粘贴代码import sensor, image, time,pyb
from pyb import UART
import json
green_threshold = ( 7, 100)
uart = UART(3,115200,timeout_char = 1000000)
ROI=(73,36,168,166)
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing(ROI)
sensor.skip_frames(10)
sensor.set_auto_gain(True)
sensor.set_auto_whitebal(False)
led = pyb.LED(3)
while(True):
clock.tick()
img = sensor.snapshot()
blobs = img.find_blobs([green_threshold],x_stride=2,y_stride=2,area_threshold=6)
led.on()
if blobs:
for b in blobs:
img.draw_cross(b[5],b[6])
print(b[5],b[6])
output_str=bytearray([0xff,0xee,int(b[5]),int(b[6])])
uart.write(output_str)
print(clock.fps())
程序用IDE里测试时没有问题代码有问题,你在IDE里试试就知道了。
> NameError: name 'clock' is not defined