OpenCV is a huge open-source library for computer vision, machine learning, and image processing. It can process images and videos to identify objects, faces, or even the handwriting of a human. In this article, we will see how to convert a colored video to a gray-scale format.
- Import the cv2 module.
- Read the video file to be converted using the cv2.VideoCapture() method.
- Run an infinite loop.
- Inside the loop extract the frames of the video using the read() method.
- Pass the frame to the cv2.cvtColor() method with cv2.COLOR_BGR2GRAY as a parameter to convert it into gray-scale.
- Display the frame using the cv2.imshow() method.
Example: Suppose we have the video file CountdownTimer.mov as the input.
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.
- Python PIL | ImageOps.grayscale() method
- OpenCV - Facial Landmarks and Face Detection using dlib and OpenCV
- Python | Create video using multiple images using OpenCV
- Transition from OpenCV 2 to OpenCV 3.x
- Detection of a specific color(blue here) using OpenCV with Python
- Opening multiple color windows to capture using OpenCV in Python
- Multiple Color Detection in Real-Time using Python-OpenCV
- Detecting obects of similar color in Python using OpenCV
- Detect the RGB color from a webcam using Python - OpenCV
- Python | Play a video in reverse mode using OpenCV
- Python | Play a video using OpenCV
- Python - Process images of a video using OpenCV
- Python - Displaying real time FPS at which webcam/video file is processed using OpenCV
- Saving a Video using OpenCV
- Saving Operated Video from a webcam using OpenCV
- Python | OpenCV BGR color palette with trackbars
- Color Spaces in OpenCV | Python
- Python OpenCV: Capture Video from Camera
- Python OpenCv: Write text on video
- Converting WhatsApp chat data into a Word Cloud using Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.