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

我只是将原程序中的:
`pixformat` 改成了`grayscale`,
`framesize`改成了`VGA`,
`skip_frames`改成了`time = 1000`,
`set_windowing`改成了`(80,90)`,
需要提供全部的程序
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())你的代码,我运行了20分钟,没有出现问题
您运行20分钟这只是偶然现象,我在描述中说了,运行时长不稳定,有时长有时短。请问这是什么问题?
我没出现问题,你要提供可以出错的代码。我得先确保问题存在。
我都是用上面写出的这个代码运行的,代码没变过。而且我运行的时候是需要识别Apriltag的。您运行的时候可能只是单纯的让程序运行而没有识别tag吧?