logo

这个是什么问题,求助????怎么解决???

2018-12-14 20:48
Z
_6vdo
17f99a76-ef9e-4202-bfd1-734cce2827b1.png
2018-12-15 12:35
I
网红小智智 星瞳科技

请提供全部的代码,可以运行的文本

2018-12-15 19:33
Z
_6vdo

这个不能运行吗?

Z
_6vdo

@kidswong999 在 [这个是什么问题,求助????怎么解决???](/post/7214) 中说:

>

> 请提供全部的代码,可以运行的文本

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)