logo

串口发送信息,有错误,但不知道怎么解决

2019-05-18 13:04
L
a2tb

:frowning_face:

import sensor, time, image, pyb
from pyb import UART
uart = UART(3, 115200)
uart.init(115200, bits=8, parity=None, stop=1)
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.B128X128)
sensor.set_windowing((92,112))
sensor.skip_frames(10)
sensor.skip_frames(time = 5000)
NUM_SUBJECTS = 6
NUM_SUBJECTS_IMGS = 20
img = sensor.snapshot()
d0 = img.find_lbp((0, 0, img.width(), img.height()))
img = None
pmin = 999999
num=0
def min(pmin, a, s):
	global num
	if a<pmin:
		pmin=a
		num=s
	return pmin
for s in range(1, NUM_SUBJECTS+1):
	dist = 0
	for i in range(2, NUM_SUBJECTS_IMGS+1):
		img = image.Image("singtown/s%d/%d.pgm"%(s, i))
		d1 = img.find_lbp((0, 0, img.width(), img.height()))
		dist += image.match_descriptor(d0, d1)
	print("Average dist for subject %d: %d"%(s, dist/NUM_SUBJECTS_IMGS))
	pmin = min(pmin, dist/NUM_SUBJECTS_IMGS, s)
	print(pmin)
print(num)
uart.any(2)
uart.write(num)
time.sleep(1000)
499c0b1c-3076-4c1f-adbb-2313770f2041.PNG
2019-05-20 18:39
I
网红小智智 星瞳科技

uart.any(2)

不能传参数。