O'Reilly logo

Raspberry Pi Computer Vision Programming by Ashwin Pajankar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chroma key with green screen

Chroma key is a special effect and a post-production technique in which multiple images can be combined together. This technique is widely used to replace green or blue backgrounds in an image with another image or live video to create special effects in live action or animation movies and weather forecasting. The logic on which the chroma key technique is based is very simple. We use a uniform-colored background, usually bright green or blue, and then replace that with an image or another live video.

Let's get started by importing the needed packages and by initializing the capture:

import numpy as np
import cv2

cam = cv2.VideoCapture(0)

For better results, we can set the camera resolution to 640 x 480, as at this resolution ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required