logo

openmv内存溢出

2018-09-14 16:03
H
卷毛的小绵羊

运行Apriltag 3d定位的程序,运行时间有时一两分钟、有时八九分钟就会出现如图所示内存溢出的提示(运行的是同一个程序),请问这是怎么回事?该如何解决?

cf1e7dd2-89dd-4de8-901e-f03768ff4617.png
2018-09-14 16:21
H
卷毛的小绵羊

我只是将原程序中的:

`pixformat` 改成了`grayscale`,

`framesize`改成了`VGA`,

`skip_frames`改成了`time = 1000`,

`set_windowing`改成了`(80,90)`,

I
网红小智智 星瞳科技

需要提供全部的程序

H
卷毛的小绵羊

import sensor, image, time, math

sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA) 
sensor.skip_frames(time = 1000)
sensor.set_auto_gain(False) 
sensor.set_auto_whitebal(False) 
sensor.set_windowing((80,90))
clock = time.clock()

#通过或位运算,来决定是否识别某一种家族的tag
tag_families = 0
tag_families |= image.TAG16H5 
tag_families |= image.TAG36H11 # default family
tag_families |= image.ARTOOLKIT 

def family_name(tag):
    if(tag.family() == image.TAG16H5):
        return "TAG16H5"
    if(tag.family() == image.TAG36H11):
        return "TAG36H11"
    if(tag.family() == image.ARTOOLKIT):
        return "ARTOOLKIT"
        
f_x = (2.8 / 3.984) * 160 
f_y = (2.8 / 2.952) * 120 
c_x = 160 * 0.5 
c_y = 120 * 0.5 

def degrees(radians):
    return (180 * radians) / math.pi

while(True):
    clock.tick()
    img = sensor.snapshot()
    for tag in img.find_apriltags(families=tag_families, fx=f_x, fy=f_y, cx=c_x, cy=c_y): # defaults to TAG36H11
        img.draw_rectangle(tag.rect(), color = (255, 0, 0))
        img.draw_cross(tag.cx(), tag.cy(), color = (0, 255, 0))
        print_args = (family_name(tag),tag.id(),tag.x_translation(), tag.y_translation(), tag.z_translation(), \
            degrees(tag.x_rotation()), degrees(tag.y_rotation()), degrees(tag.z_rotation()))
        # Translation units are unknown. Rotation units are in degrees.
        print("Family: %s, ID: %d, Tx: %f, Ty %f, Tz %f, Rx %f, Ry %f, Rz %f" % print_args)
    print(clock.fps())
2018-09-14 16:56
I
网红小智智 星瞳科技

你的代码,我运行了20分钟,没有出现问题

2018-09-14 17:03
H
卷毛的小绵羊

您运行20分钟这只是偶然现象,我在描述中说了,运行时长不稳定,有时长有时短。请问这是什么问题?

I
网红小智智 星瞳科技

我没出现问题,你要提供可以出错的代码。我得先确保问题存在。

2018-09-14 17:23
H
卷毛的小绵羊

我都是用上面写出的这个代码运行的,代码没变过。而且我运行的时候是需要识别Apriltag的。您运行的时候可能只是单纯的让程序运行而没有识别tag吧?