Demonstration of photo taking

Lillyzhang
UCL-COMP0016–2020-Team13
3 min readJan 18, 2021

Written a frame and put camera.py(written before) into video().

First frame

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.

Frame
video

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:

added a button

Code for opening the picture in another window:

Overall code:

Result:

overall
start interface
opens camera after pressing start
takes image

References:

https://www.pyimagesearch.com/2016/05/30/displaying-a-video-feed-with-opencv-and-tkinter/

https://www.tutorialspoint.com/python/tk_panedwindow.htm

--

--