Pygame显示图像时真循环内存问题

2024-09-30 22:18:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一张不断变化的照片。我想在pygame中演示这些,就像一个视频。内存已满,无法释放。哪里出错了?你知道吗

def showLive(file):
   picture = pygame.transform.scale(pygame.image.load(file),(width,high))
   main_surface.blit(picture, (0, 0))
   pygame.display.flip()

while True:
   #takePicture take always a new picture
   takePicture("test.jpeg") 
   showLive("test.jpeg")

非常感谢。你知道吗

更新:04.01.2018

我使用https://github.com/alexdu/piggyphoto。从我的单反相机预览。你知道吗

当我启动程序时,我会看到“实时视图”。记忆越来越丰富了。大约8分钟后,它是充分的覆盆子皮3b

import piggyphoto, pygame

def showLive(file):
   C.capture_preview(file)
   picture = pygame.transform.scale(pygame.image.load(file),(width,high))
   display.blit(picture, (0, 0))
   pygame.display.flip()

width = 1275
high = 850
file = 'preview.jpg'

C = piggyphoto.camera()
C.leave_locked()
C.capture_preview(file)

global display
pygame.init()
picture = pygame.image.load(file)
display = pygame.display.set_mode((width,high),pygame.FULLSCREEN)
pygame.mouse.set_visible(False)

while True:
   showLive(file)

Tags: imagedefdisplaytransformloadpreviewwidthpygame