In my tkinter
GUI a video is displayed and the user is able to get a snapshot of the video. Now I am trying to save this snapshot but i can't figure out how to do it. Due to the imagetype of the file I can't save it with the common Image.save()
The Video Loop:
def stream(label):
for image in video.iter_data():
global frame_image
frame_image = ImageTk.PhotoImage(Image.fromarray(image))
label.config(image=frame_image)
label.image = frame_image
time.sleep(0.015)
The Snapshot function:
def snapshot():
global frame_image
frame_label.config(image = frame_image)
frame_label.image = frame_image
I tried several things but nothing seemed to work.
Tried to convert it to cv2
format to use cv2.imwrite
:
open_cv_image = numpy.array(frame_image)
cv2.imwrite("C:\\test.jpg", open_cv_image)
Tried to open it in a new image with PIL.Image.open
:
pic = Image.open(frame_image).convert("RGB")
pic.save("C:\\test.jpg")
Any idea how I could finally solve my problem?