就是必须用到openmv是吗
nkfr
@nkfr
nkfr 发布的帖子
-
openmv 串口发送数据在IDE中能看到,但是在串口助手中没有数据
#官网例程
import sensor, image, time
from pyb import UART
import json
yellow_threshold = (65, 100, -10, 6, 24, 51)
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
while(True):
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="[%d,%d]" % (max_blob.cx(),max_blob.cy())
print('you send:',output_str)
uart.write(output_str+'\r\n')
else:
print('not found!')