logo

报错出现MemoryError:。。请问是什么问题呢?

2019-07-16 15:41
M
isdz

下面的代码报错:MemoryError: Out of fast Frame Buffer Stack Memory! Please reduce the resolution of the image you are running this algorithm on to bypass this issue!

# 颜色二值化滤波例子

#

# 这个脚本展示了二值图像滤波。

# 您可以传递二进制任意的阈值来分割图像。



import sensor, image, time

sensor.reset()

sensor.set_framesize(sensor.QVGA)

sensor.set_pixformat(sensor.RGB565)


#如果是灰度图,则只需设置(min, max)两个数字即可。

red_threshold = (25, 95, 77, 22, -16, 63) # L A B

green_threshold = (0,100,   -128,0,   0,127) # L A B

blue_threshold = (0,100,   -128,127,   -128,0) # L A B

sensor.skip_frames(time = 2000)

clock = time.clock()


while(True):
        clock.tick()
        img = sensor.snapshot()
        img.binary([red_threshold])        
        rects = img.find_rects(threshold = 40000)
        circles = img.find_circles(threshold = 5500, x_margin = 10, y_margin = 10, r_margin = 10,r_min = 5, r_max = 100, r_step = 2)
        blobs = img.find_blobs([black],area_threshold=50, pixels_threshold=50)
        if rects:
            for r in rects:
                img.draw_rectangle(r.rect(), color = (255, 0, 0))
                for p in r.corners(): img.draw_circle(p[0], p[1], 5, color = (0, 255, 0))
                print("find rects")
            continue
        if circles:
            for c in circles:
                img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0))
                print("find circles")
            continue
        if blobs:
            max_blob=find_max(blobs)
            img.draw_rectangle(max_blob.rect())
            img.draw_cross(max_blob.cx(),max_blob.cy())
            k = max_blob.pixels() / max_blob.area()
            if(k <= 0.6):
                print("find sanjiao")
            continue
2019-07-17 13:48
I
网红小智智 星瞳科技

使用QQVGA替代QVGA。

2019-07-17 16:11
M
isdz

嗯嗯 ,解决啦,谢谢

2021-09-24 19:49
Z
vze3

@kidswong999 改了之后还是报错,怎么办呢?

2021-09-24 21:31
I
网红小智智 星瞳科技

@vze3 发新的帖子,附上全部的代码和使用的硬件型号等信息。