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. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course