chromakey qlab quartz composer

Framework for Real-time chromakey in QLAB.

The main goal was to provide live chromakey to camera cues inside Qlab using still images or video files. My work  adapts the solution provided by George Toledo implementing it in QLAB.

—————————————————————————————————————
[Q-Chromakey-still.qtz]

Q-Chromakey-still provides an easy way to generate a real-time chromakey form inside Qlab using a still image as background.

s9

You just need to drag the Q-Chromakey-still.qtz into the Video Effects tab of a camera/video cue and define the color to key, adjust the threshold and the smoothing values and finally define the image location (path and filename).

You can download all the files above (press more)

s11

The background image is defined by the input “Image Location” in the Image Importer object and will be available in the Qlab interface as a string field. I extract the frame dimensions of the foreground video/camera sent by Qlab using a “Image Dimensions” object witch will adjust the image defined in the Image Importer using a “Image Crop” object. An object called the “Core Image Filter” receives both foreground and background images in separated inputs. This object provides a color type exposed to the exterior (Qlab) that defines the color to key, a threshold and a smoothing input values also exposed to the exterior make the amount of keying interactive from Qlab. This object implements a function script that blends the two images based on the color key (script available above). Finally the result image returns to Qlab.

// Chromakey script adapted from George Toledo
kernel vec4 multiplyEffect(sampler image, sampler backgroundImage, __color color, float threshhold, float smoothing)
{
float Y, Cb, Cr;
float maskY, maskCb, maskCr;
vec4 sourcePixel = sample(image, samplerCoord(image));
vec4 backgroundPixel = sample(backgroundImage, samplerCoord(backgroundImage));
float blendValue;maskY = 0.2989 * color.r + 0.5866 * color.g + 0.1145 * color.b;
maskCr = 0.7132 * (color.r – maskY);
maskCb = 0.5647 * (color.b – maskY);
Y = 0.2989 * sourcePixel.r + 0.5866 * sourcePixel.g + 0.1145 * sourcePixel.b;
Cr = 0.7132 * (sourcePixel.r – Y);
Cb = 0.5647 * (sourcePixel.b – Y);blendValue = smoothstep(threshhold, threshhold + smoothing , abs(Cr – maskCr) + abs(Cb – maskCb));
sourcePixel = sourcePixel * blendValue;return sourcePixel + (backgroundPixel * (1.0 – blendValue));
}

 [wpdm_file id=”3″] [Q-Chromakey-still.qtz]

File size
Total files inside the zip

—————————————————————————————————————
[Q-ChromaKey-sequence.qtz]

Q-ChromaKey-Sequence provides a live chromakey in Qlab using a sequence of images in background.

s12

This framework is a mix between the Q-Chromakey-still.qtz and the Q-ImageSequence.qtz witch were already explained in full detail in this and other posts. To load and play the background sequence of images you need to send OSC commands from QLAB and you must also run another Quartz composition, the Q-timer.qtz witch solves issues form Qlab.

[wpdm_file id=”4″] [Q-ChromaKey-sequence.qtz]

File size: 250k
Total files inside the zip:

chromakey-sequence.cues
Q-ChromaKey-sequence.qtz
Q-timer.qtz
Sequence of images

—————————————————————————————————————
[Q-Chromakey-Syphon.qtz]

Q-Chromakey-Syphon provides a live chromakey in Qlab using a video or any kind of real-time animation send via a syphon server.

s13

Again, this framework is a mix between the Q-Chromakey-still.qtz and the Syphon-Movie compositions witch were already explained in full detail in this and other posts. To load and play the background videos you need to send OSC commands from QLAB and you must also run another Quartz composition, the Q-VideoServer.qtz witch solves acts as a syphon server. You can also send any video or animation from other applications like unity or aftereffects.

NEW VERSION

[wpdm_package id=”1743″] [Q-Chromakey-Syphon-v2.zip]

[wpdm_file id=”5″] [Q-Chromakey-Syphon.qtz]

File size: 4.1M
Total files inside the zip:

mar.m4v
Q-Chromakey-Syphon.cues
Q-ChromaKey-syphon.qtz
Q-VideoServer.qtz

please contact me if you have any comments or doubts: virtual.marionette@grifu.com