Green screen is a classic video editing technique where we can make someone look like they are standing in front of a completely different background. This is widely used in weather reports, where reporters point to backgrounds of moving clouds and maps. The trick in this technique is that the reporter never wears a certain color of clothing (say, green) and stands in front of a background that is only green. Then, identifying green pixels will identify what is the background and helps replace content at only those pixels.
In this section, we will learn about leveraging the cv2.inRange and cv2.bitwise_and methods to detect the green color in any given image.
The strategy that we will adopt is as follows:
- Convert the image from RGB into HSV space.
- Specify the upper and lower limits of HSV space that correspond to the color green.
- Identify the pixels that have a green color – this will be the mask.
- Perform a bitwise_and operation between the original...