logo

求助关于人脸分辨的相关问题

2021-01-05 18:33
8
pt6u

你好请问这个人脸识别代码为什么不能输出num的值,串行口显示没有输出值,万分感谢

530908e6-c427-4ed1-bc65-96a791b826a8.png
import sensor, time, image, pyb

sensor.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) #等待5s
num = 0
def min(pmin, a, s):
    global num
    print(00000000)
    if a < pmin:
        pmin = a
        num = s
        
    return pmin
    sensor.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) #等待5s
    
    NUM_SUBJECTS = 2
    NUM_SUBJECTS_IMGS = 20
    img = sensor.snapshot()
    d0 = img.find_lbp((0, 0, img.width(), img.height()))
    img = None
    pmin = 999999
    num = 0
    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)
        if dist / NUM_SUBJECTS_IMGS == pmin:
            num = s
    print(num)
2021-01-06 16:26
I
网红小智智 星瞳科技

https://singtown.com/learn/50033/

有没有按照视频的步骤操作?

2021-01-07 16:07
K
崔子

确实跟着教程一步一步走 但就是分辨不出来

2021-01-08 18:47
8
pt6u

@kidswong999 是按照视频的步骤进行的