Prerequisite: Introduction to pyqt-5
PyQt5 is a cross-platform GUI toolkit, a set of python bindings for Qt v5. One can develop an interactive desktop application with so much ease because of the tools and simplicity provided by this library.
In this article, we will see how we can create a simple camera application using PyQt5, which will capture the images and save them in the desired location which can be changed any time.
GUI Implementation Steps :
- Create the main window.
- Add QCameraViewfinder object as the central widget to the main window.
- Add a status bar to the window for status tips.
- Add the toolbar to the window.
- Add Click and change location actions to the toolbar, and a combo box for selecting the camera, below is how toolbar will look like.
Back-End Implementation Steps :
- Create a path variable and set it currently to blank.
- Add available cameras to the combo box and set the first camera as default.
- Add action to the Take Photo button.
- Inside the click action, capture the photo at the given path with name as a timestamp and increment the count.
- Add action to the change location button.
- Inside the change location action, open the dialog box to get the path and update the path and the counter.
- Add action to the combo box.
- Inside the combo, box action get the selected camera, set viewfinder to it, and the mode of capture.
- Create an alert method that shows an error message if any error is shown while selecting the path and changing the camera.
Below is the implementation :
When we click on the change location, this dialog will appear
Let’s go to this folder and see if the images are captured or not
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Computer Vision module application for finding a target in a live camera
- Check if the camera is opened or not using OpenCV-Python
- Python OpenCV: Capture Video from Camera
- Camera Calibration with Python - OpenCV
- Build an Application to Search Installed Application using Python
- Flask - (Creating first simple application)
- Creating Your First Application in Python
- Creating a tabbed browser using PyQt5
- Creating a simple browser using PyQt5
- Creating NotePad using PyQt5 - Python
- Creating Golden Ratio Calculator using PyQt5
- Timer Application using PyQt5
- Building QR Code Generator Application using PyQt5
- Creating Custom Widgets in PyQt5
- PyQt5 - Creating String Spin Box
- PyQt5 - Application to get the price of BitCoin
- PyQt5 - Create Paint Application
- PyQt5 - GUI Application to get IP address
- Creating child process using fork() in Python
- Python | Creating tensors using different functions in Tensorflow
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.