def interactive_save(image):
img_str = cv2.imencode('.png', image)[1].tostring()
imgpil = Image.open(StringIO(img_str))
root = Tkinter.Tk()
root.geometry('{}x{}'.format(400, 400))
imgtk = ImageTk.PhotoImage(image=imgpil)
panel = Tkinter.Label(root, image=imgtk) #.pack()
panel.pack(side="bottom", fill="both", expand="yes")
Tkinter.Button(root, text="Hello!").pack()
save_to = tkSimpleDialog.askstring("Save cropped image", "Enter filename")
if save_to:
if save_to.find('.') == -1:
save_to += '.png'
print 'Save to:', save_to
cv2.imwrite(save_to, image)
root.destroy()
评论列表
文章目录