logo

遍历x轴和y轴为什么缓冲界面会卡死?

2019-07-30 11:42
9
nowh

我想框出一个长为20,宽为20的框,然后遍历x轴和y轴,让这个框每次移动一个格子,得到每个框中的像素,为什么缓冲界面会卡死?



import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)

clock = time.clock()
   


while(True):
    clock.tick()
    img = sensor.snapshot()
    for i in range(160):
        a = i
        for j in range(120):
            b = j
            roi=(a,b,20,20)
            print(roi)
            statistics=img.get_statistics(roi=(a,b,100,100))
            color_l=statistics.l_max()
            color_a=statistics.a_max()
            print(color_l,color_a)
            #img.draw_rectangle(roi)
2019-07-30 17:12
I
网红小智智 星瞳科技

我测试了,不会卡死,只是帧率很低。

低到半分钟才能运行一张图片。

I
网红小智智 星瞳科技

不要用for循环遍历整个图片。

2019-07-30 21:25
9
nowh

那我想知道这幅图里有哪些地方像素高一点怎么处理?

2019-07-31 15:28
I
网红小智智 星瞳科技

@nowh 我没看懂你是什么意思,不过新的问题单独发帖子。