小bug修改
This commit is contained in:
@@ -283,6 +283,7 @@ class PreviewWindow:
|
||||
photo = ImageTk.PhotoImage(image=pil_image)
|
||||
# 保持引用,避免被GC
|
||||
self.photo_objects[idx] = photo
|
||||
self._grid_photos.append(photo)
|
||||
|
||||
images_to_draw.append((photo, center_x, center_y))
|
||||
texts_to_draw.append((center_x, y + 15, name, 'white'))
|
||||
@@ -416,6 +417,8 @@ class PreviewWindow:
|
||||
canvas.pack(fill=tk.BOTH, expand=True)
|
||||
|
||||
photo_obj = {}
|
||||
# 持久引用大窗当前帧 PhotoImage,避免GC
|
||||
self._large_photos = []
|
||||
|
||||
def update_large_once():
|
||||
if not self.running or not self.large_window.winfo_exists():
|
||||
@@ -441,8 +444,9 @@ class PreviewWindow:
|
||||
resized_frame = cv2.cvtColor(resized_frame, cv2.COLOR_BGR2RGB)
|
||||
pil_image = Image.fromarray(resized_frame)
|
||||
photo = ImageTk.PhotoImage(image=pil_image)
|
||||
# 保存引用到字典,确保不被GC
|
||||
# 保存引用到字典和列表,确保不被GC
|
||||
photo_obj['img'] = photo
|
||||
self._large_photos = [photo]
|
||||
|
||||
# 清空并绘制新图像
|
||||
canvas.delete("all")
|
||||
|
||||
Reference in New Issue
Block a user