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 converted to grayscale
- Do not exit the program by stopping the command. This won't turn off the camera. If you do this, close the terminal to stop the camera from running.