logo

IO口设置高低有点小问题

2019-01-24 14:17
6
mv新手

我想用人脸检测到 就给外界一个高电平,我用P0改写代码发现在置高电平时 万用表检测电平是从0缓慢上升到3.3 有没有什么办法能够稍微快速 或者让电平保持3.3一段时间?加上time.sleep()也是缓慢上升。

import sensor, time, image, pyb

p = pyb.Pin("P0", pyb.Pin.OUT_PP)

# Reset sensor
sensor.reset()

# Sensor settings
sensor.set_contrast(1)
sensor.set_gainceiling(16)
# HQVGA and GRAYSCALE are the best for face tracking.
sensor.set_framesize(sensor.HQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
#注意人脸识别只能用灰度图哦

# Load Haar Cascade
# By default this will use all stages, lower satges is faster but less accurate.
face_cascade = image.HaarCascade("frontalface", stages=25)
#image.HaarCascade(path, stages=Auto)加载一个haar模型。haar模型是二进制文件,
#这个模型如果是自定义的,则引号内为模型文件的路径;也可以使用内置的haar模型,
#比如“frontalface” 人脸模型或者“eye”人眼模型。
#stages值未传入时使用默认的stages。stages值设置的小一些可以加速匹配,但会降低准确率。
print(face_cascade)

# FPS clock
clock = time.clock()

while (True):
    clock.tick()

    # Capture snapshot
    img = sensor.snapshot()

    # Find objects.
    # Note: Lower scale factor scales-down the image more and detects smaller objects.
    # Higher threshold results in a higher detection rate, with more false positives.
    objects = img.find_features(face_cascade, threshold=0.75, scale=1.35)
    #image.find_features(cascade, threshold=0.5, scale=1.5),thresholds越大,
    #匹配速度越快,错误率也会上升。scale可以缩放被匹配特征的大小。
    if(objects):
        p.high()
        time.sleep(300)
    else:
        p.low()

    #在找到的目标上画框,标记出来
    # Draw objects
    for r in objects:
        img.draw_rectangle(r)

    # Print FPS.
    # Note: Actual FPS is higher, streaming the FB makes it slower.
    print(clock.fps())
I
网红小智智 星瞳科技

不要用万用表,万用表有延迟,用示波器。

2019-01-24 14:59
6
mv新手

@kidswong999 那我接单片机的话高低电平能快速反映不

I
网红小智智 星瞳科技

可以,IO的反转时间很短的。