Andrey
Andrey

Reputation: 71

How to mask on emgu cv C#

i'd want to add mask on my recognised face during live video capturing with EMGU CV, C#, WPF, I've already done live video capturing and had a PNG mask, how to impose PNG image to my video? faces are recognised and imposed by small non-filled rectangles, so I can easily get coordinates of faces center

Upvotes: 0

Views: 2725

Answers (1)

Mark Miller
Mark Miller

Reputation: 706

It appears the answer is as simple as overlaying the PNG image to the video. Here's some example code, originally from here:

public static Image<Bgra, Byte> Overlay(Image<Bgra, Byte> target, Point targetPoint, Image<Bgra, Byte> overlay)
{
    Bitmap bmp = target.Bitmap;
    Graphics gra = Graphics.FromImage(bmp);
    gra.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
    gra.DrawImage(overlay.Bitmap, targetPoint);
    return target;
}

Upvotes: 1

Related Questions