MFormats SDK: using Chroma Key plugin

It is possible to use our Chroma Key plugin (available separately) together with MFormats SDK. To do so, use the MChromaKey plugin.


In order to use chroma keying:


1. Add the reference to the chroma key library (MChromaKeyPXT.dll) to the project:



2. Create MChromaKey object:


MChromaKey m_objChromaKey = new MChromaKeyClass();


3. Process the incoming frame using ProcessFrame method. As a result, the original frame and a frame processed with a plugin, are accessible.


// Original frame received from the source
MFFrame pFrame;
int nFramesRes;

// Processed (chroma keyed) frame
MFFrame pFrameOut = null;

((MFORMATSLib.IMFProcess)m_objChromaKey).ProcessFrame(pFrame, out pFrameOut, out nFramesRes, "");
if (pFrameOut != null)
{
	// Clear memory if the original frame is no longer needed
	Marshal.ReleaseComObject(pFrame);
}

// Use the result frame (pFrameOut) as you need: overlay on another frame, send to the Preview, output to capture card, write to file, etc.


 You can try Chroma Key plugin with the Mixer Chroma Key Sample:


1. Add file (Main File) as a background (click "Load background" button):



2. Add file that chroma key will be applied to (click "Load Second File" button):



3. Initialize chroma keying:



4. Apply chroma key settings (click "Adjust chroma key" button). Configuration process is described in detail here.