0
画像をPILで読み込み、それを配列に変換してから、画像に変換してTkinter Label要素に表示します。 (<PIL.Image.Image image mode=RGB size=295x400 at 0x28CAB9F5630>
を)それを見つけるように見えるが、いくつかの理由が存在しないことを印刷PILでTkinterのnumpy配列に変換した画像を表示
File "C:/Users/lazar/Documents/GitHub/Face-Features-Detection/ui.py", line 19, in <module>
img_panel.configure(image=img)
File "C:\Users\a\Miniconda3\lib\tkinter\__init__.py", line 1479, in configure
return self._configure('configure', cnf, kw)
File "C:\Users\a\Miniconda3\lib\tkinter\__init__.py", line 1470, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: image "<PIL.Image.Image image mode=RGB size=295x400 at 0x28CAB9F5630>" doesn't exist
:私はそれは間違いだ実行すると
from tkinter import *
import PIL as pl
from PIL import ImageTk, Image
import numpy as np
root = Tk()
root_panel = Frame(root)
root_panel.pack(side="bottom", fill="both", expand="yes")
img_src = 'pic.jpg'
img = pl.Image.open(img_src)
img_arr = np.array(img)
img = pl.Image.fromarray(img_arr)
img_panel = Label(root_panel)
img_panel.configure(image=img)
img_panel.pack(side="bottom", fill="both", expand="yes")
root.mainloop()
:私は、次のコードを持っています。誰もこの問題を引き起こす可能性があることをお勧めしますか?それは(のみ `ImageTk.PhotoImageを表示することができます)` -
img_tk = ImageTk.PhotoImage(img)
img_panel = Label(root_panel)
img_panel.configure(image=img_tk)
'' tkinter' Image'を表示することはできません。 – furas