检测是否存在人脸例程 if语法错误
-
import sensor, time, image,pyb sensor.reset() sensor.set_contrast(3) sensor.set_gainceiling(16) sensor.set_pixformat(sensor.GRAYSCALE) sensor.set_framesize(sensor.HQVGA) green = pyb.LED(2) face_cascade = image.HaarCascade("frontalface", stages=25) print(face_cascade) clock = time.clock() while (True): clock.tick() img = sensor.snapshot() objects = img.find_features(face_cascade, threshold=0.75, scale_factor=1.25) if objects: green.on() for r in objects: img.draw_rectangle(r) print(clock.fps())
就是官方检测是否存在人脸的例程,只加了下面两行:
if objects: green.on()
编译运行时总是在green.on()处报错,更改为print("检测人脸")依旧不行
if下面缩进也是四个字符,现在没太搞懂为什么会报错,请明白的同学指点,感谢
-
把中文的冒号改成英文的冒号
:
->: