unionMask := image.NewNRGBA(image.Rect(0, 0, scale, scale))
// Add to union mask
ellipse := ellipse.NewEllipse(row, col, int(float64(scale)*0.8/1.6), int(float64(scale)*0.8/2.2))
draw.Draw(unionMask, unionMask.Bounds(), ellipse, image.Point{X: row - scale/2, Y: col - scale/2}, draw.Over)
// Converts the buffer array to an image.
img := c.pixToImage(imgData, scale)
// Create a new image and draw the webcam frame captures into it.
newImg := image.NewNRGBA(image.Rect(0, 0, scale, scale))
draw.Draw(newImg, newImg.Bounds(), img, newImg.Bounds().Min, draw.Over)
// Apply the blur effect over the obtained pixel data converted to image.
blurred, err := c.blurFace(newImg, scale)
if err != nil {
return err
}
faceTemplate := image.NewNRGBA(image.Rect(0, 0, scale, scale))
draw.Draw(faceTemplate, img.Bounds(), blurred, image.Point{}, draw.Over)
// Draw the triangled image through the facemask and on top of the source.
draw.DrawMask(img.(draw.Image), img.Bounds(), blurred, image.Point{}, unionMask, image.Point{}, draw.Over)