Key out color from video

Hey guys!

I was wondering - Is it possible to key out green screen from video
and replace it with a picture? :roll_eyes:

In a result I imagined that the video is still playing, but all the green space is filled with my picture file.

1 Like

This is called chroma key. Check this: https://forum.processing.org/two/discussion/comment/104666/#Comment_104666

Kf

1 Like

There are several ways to solve the problem of green screen / chroma key to do background replacement.

The basic approach is to check for a specific color value or small value range in image A and, when you find it, replace that pixel from the same pixel in image B. This can apply to image-image, image-video, video-image, or video-video.

There are a lot of past conversations about doing chroma key in Processing.

Three basic approaches to making this happen in code:

  1. loop through pixels x, y in two nested loops, check the value, and replace if it matches. This is slow.
  2. loop through the pixels[] array, check the value, and replace if it matches. This is faster.
  3. use a PShader – this is even faster, but also requires writing a glsl shader, which is more complex. Example: https://github.com/Prince-Polka/chroma_key

In addition, there are two ways of checking the value for approaches 1 and 2:

  1. use red() green() and blue(), which is slow
  2. use >> right shift, which is fast.
1 Like