我在带有Logitech网络摄像头的Raspberry Pi 3上运行的kivy
中有以下摄像头代码:
class KivyCamera(Image):
def __init__(self, **kwargs):
super(KivyCamera, self).__init__(**kwargs)
self.capture = None
def start(self, capture, fps=30):
self.capture = capture
Clock.schedule_interval(self.update, 1.0 / fps)
def stop(self):
Clock.unschedule_interval(self.update)
self.capture = None
def update(self, dt):
ret, frame = self.capture.read()
if ret:
# convert it to texture
cv2.putText(frame, "Testing!", (0, 50), cv2.FONT_HERSHEY_COMPLEX, 2, (100, 0, 255))
buf1 = cv2.flip(frame, 0)
if (recON == 1):
out.write(frame)
#
buf = buf1.tostring()
image_texture = Texture.create(
#size=(frame.shape[1], frame.shape[0]), colorfmt='bgr')
size=(frame.shape[1], frame.shape[0]), colorfmt='rgb')
image_texture.blit_buffer(buf, colorfmt='bgr', bufferfmt='ubyte')
#self.canvas.ask_update()
self.texture = image_texture
从Logitech C920(在液晶显示屏上)显示帧约3分钟后,我得到下面的memory exception
。如果我使用Logitech C170,它将运行更长时间约5分钟: