Last active
March 9, 2020 13:22
-
-
Save ochilab/a834e568c0c51999ecf979a0cb43e0f7 to your computer and use it in GitHub Desktop.
Tkinterでのカメラ映像表示
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root=tk.Tk() | |
root.title("RGB Recorder") | |
root.geometry("800x600") | |
root.resizable(width=False, height=False) | |
canvas=tk.Canvas(root, width=640, height=480, bg="white") | |
canvas.pack() | |
def update():#update | |
global img | |
global camera | |
ret, frame =camera.read() | |
#TkInterで表示できる形式に変換する | |
img=ImageTk.PhotoImage(Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))) | |
canvas.create_image(w/2,h/2,image=img) | |
root.after(1,update) #本関数を再帰的に呼び出す | |
#Cameraの設定などは省略してます | |
update() | |
root.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment