请问怎样让整个程序运行结束再回到程序开头继续运行
-
import sensor, time, image, pyb
from pyb import UARTsensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # or sensor.GRAYSCALE
sensor.set_framesize(sensor.B128X128) # or sensor.QQVGA (or others)
sensor.set_windowing((92,112))
sensor.skip_frames(10) # Let new settings take affect.
sensor.skip_frames(time = 5000) #等待5suart = UART(3, 115200)
while(True):
if uart.any():
a=uart.readline().decode().strip()
print(a)
break#SUB = "s1"
NUM_SUBJECTS = 2 #图像库中不同人数,一共6人
NUM_SUBJECTS_IMGS = 20 #每人有20张样本图片img = sensor.snapshot()
#img = image.Image("singtown/%s/1.pgm"%(SUB))
d0 = img.find_lbp((0, 0, img.width(), img.height()))
#d0为当前人脸的lbp特征
img = None
pmin = 999999
num=0def min(pmin, a, s):
global num
if a<pmin:
pmin=a
num=s
return pminfor 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()))
#d1为第s文件夹中的第i张图片的lbp特征
dist += image.match_descriptor(d0, d1)#计算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(2)print(num) # num为当前最匹配的人的编号。
uart.write(str(num)+'\r\n')我想让人脸识别结束后,将结果发送出去后,再回到程序开始的串口接收部分继续运行程序,请问该怎样弄?