Capture an image by accessing the webcam of your system and save it to your machine.
- Python, v3.6.7
- Matplotlib, v3.0.2 (to view the captured images or images that have been modified. Not required for Windows machines.)
pip3 install matplotlib
- OpenCV, v3.4.4
sudo apt install python3-opencv
Please read the full document.
- Run the file webcam-capture-v1.01.py by running the command
python3 webcam-capture-v1.01.py
- The webcam will start running.
- Bring the picture that you want to save in the webcam frame.
- Once the object is in the right frame, press the key 's' to save a picture.
- If you want to quit, just press 'q'.
- After hitting 's' to save the picture,you will get a view of the saved image which will automatically close in 1.6s and a new image file will be created in the same directory as that of the program. The image will be saved as saved_image.jpg
- The file saved_image is furthered converted to grayscale and then resized to 28x28 size for further use in relevant programs, for example, machine learning, which was my primary requirement of creating this file.