Demonstration of photo taking
Written a frame and put camera.py(written before) into video().
But there appears two windows: one is opencv.imshow and the other is tkinter’s frame. Find ways to merge the two windows into one.
From some researching, it doesn’t seem easy to embed imshow into a tkinker frame, so have to get the frame every second and update it into the frame.
OpenCV represents images in BGR order, however PIL represents images in RGB order, cv2image swap the channels.
imgtk converts image to a Tkinter-compatible photo image.
Next is to get a screenshot of the video after pressing a button. Code for adding a button:
Code for opening the picture in another window:
Overall code:
Result:
References:
https://www.pyimagesearch.com/2016/05/30/displaying-a-video-feed-with-opencv-and-tkinter/