Python 3 Tkinter to Show Webcam Video & Capture Image Using OpenCV & Pillow Library GUI Desktop App

 

In this tutorial, we will create a Python GUI desktop application using Tkinter that displays a live webcam feed and allows users to capture images using OpenCV and Pillow.

Prerequisites

 

 

Make sure you have Python 3 installed along with the required dependencies:

 

 

 

 

Full Code for Webcam GUI App

 

 

Explanation

 

  • We use cv2.VideoCapture(0) to access the webcam.
  • The update_frame function continuously updates the Tkinter label with the live feed.
  • The capture_image function captures an image when the button is clicked and saves it as captured_image.jpg.
  • The on_closing function ensures proper cleanup when the window is closed.

 

Running the Application

 

Save the script as webcam_app.py and run it using:

 

 

 

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *