logo

还用定时器为什么会出现内存错误的这种情况啊?

2018-09-23 16:47
C
越努力越幸运
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

face_cascade = image.HaarCascade("frontalface",stages=25 )

NUM_SUBJECTS = 3 #图像库中不同人数,一共6人
NUM_SUBJECTS_IMGS = 3 #每人有20张样本图片
flag=0

def tick(timer):            # we will receive the timer object when being called
    flag=1
    for s in range(1,NUM_SUBJECTS+1):
        dist=0
        for i in range(1,NUM_SUBJECTS_IMGS+1):
               img1=image.Image("/photos/s%d/%d.pgm"%(s,i))
               d1 = img.find_lbp((0, 0, img.width(), img.height()))
               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("差异度为:%d"%pmin)
    
    
    print("Timer callback")



while (True):
    if flag==0:
        img=sensor.snapshot()
        objects = img.find_features(face_cascade, threshold=0.75, scale=1.35)
        for r in objects:
               img.draw_rectangle(r)
               d0=img.find_lbp(r)
        if (len(objects)!=0):
               tim = Timer(4, freq=1)      # create a timer object using timer 4 - trigger at 1Hz
               tim.callback(tick)          # set the callback to our tick function
I
网红小智智 星瞳科技

请详细描述问题,

包括,目的,步骤,报错提示

2018-09-23 17:05
C
越努力越幸运
5efa4234-6e3a-4e35-9455-cfa0fc6088b4.png
I
网红小智智 星瞳科技

这不是内存错误,你看看英文?

2018-09-23 17:13
C
越努力越幸运
05da637c-ca9d-4ea4-aa84-330f07de0a9b.png