GRAYSCALE+SVGA+find_line_segments 报堆栈错误,如何处理。

Viewed 323
'''
实验名称:摄像头使用
实验平台:01Studio CanMV K230
说明:实现摄像头图像采集显示
'''

import time, os, sys,image

from media.sensor import * #导入sensor模块,使用摄像头相关接口
from media.display import * #导入display模块,使用display相关接口
from media.media import * #导入media模块,使用meida相关接口

sensor = Sensor() #构建摄像头对象 标配70°,可选140°
sensor.reset() #复位和初始化摄像头
sensor.set_framesize(Sensor.SVGA) #设置帧大小FHD(1920x1080),默认通道0
sensor.set_pixformat(Sensor.GRAYSCALE) #设置输出图像格式,默认通道0 RGB565

#使用IDE缓冲区输出图像,显示尺寸和sensor配置一致。
Display.init(Display.VIRT, sensor.width(), sensor.height())

MediaManager.init() #初始化media资源管理器

sensor.run() #启动sensor

clock = time.clock()

while True:

    ################
    ## 这里编写代码 ##
    ################
    clock.tick()

    img = sensor.snapshot() #拍摄一张图

    for l in img.find_line_segments(merge_distance = 0, max_theta_diff = 5):
        img.draw_line(l.line(), color = (255, 0, 0))
    Display.show_image(img) #显示图片
    print(clock.fps()) #打印FPS


Traceback (most recent call last):
File "", line 36, in
MemoryError: Out of fast frame buffer stack memory
MPY: soft reboot
CanMV v1.2.2(based on Micropython e00a144) on 2024-12-18; k230_canmv_01studio with K230


01的canmv k230开发板,2G内存。

3 Answers

您好,您可以添加打印,查看在哪一行代码造成的错误,以便更好地定位问题。

image.png
sensor(0), mode 0, buffer_num 4, buffer_size 0

Traceback (most recent call last):
File "", line 30, in
MemoryError: Out of fast frame buffer stack memory
MPY: soft reboot
CanMV v1.2.2(based on Micropython e00a144) on 2024-12-18; k230_canmv_01studio with K230

第30行喔。

程序就拍照和find_line_segments两个功能,去掉find_line_segments和下一句,没有问题。看看是不是固件或者哪个设置需要修改。希望早日解决这个bug。

你好我也遇到了同样的问题。但是可能是我之前固件的版本太低了导致的,今天我换成了最新的固件版本就解决了