import sensor, time, image, pyb, machine
from pyb import UART
sensor.reset()
sensor.set_contrast(3)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.HQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
uart = UART(3, 19200, timeout_char = 1000)
face_cascade = image.HaarCascade("frontalface", stages=25)
print(face_cascade)
# FPS clock
clock = time.clock()
while (True):
clock.tick()
if uart.any():
a = uart.readline()
print (a)
start = pyb.millis()
while a==b'1':
img = sensor.snapshot()
objects = img.find_features(face_cascade, threshold=0.75, scale_factor=1.25)
for r in objects:
img.draw_rectangle(r)
if r[1]>50:
print ('incorrect')
elif r[1]<50:
print ('correct')
if pyb.millis() - start>60000:
print ('failed')
break
if objects:
print ('success')
break发烫问题不大,没什么事。