Last active
July 6, 2022 11:22
-
-
Save esimov/47ba7fb16ea14dd391481a0758074910 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c.processor = &triangle.Processor{ | |
BlurRadius: 2, | |
Noise: 0, | |
BlurFactor: 2, | |
EdgeFactor: 4, | |
PointRate: c.pointRate, | |
MaxPoints: c.trianglePoints, | |
PointsThreshold: c.pointsThreshold, | |
Wireframe: c.wireframe, | |
StrokeWidth: c.strokeWidth, | |
IsStrokeSolid: c.isSolid, | |
Grayscale: c.isGrayScaled, | |
BgColor: "#ffffff00", | |
} | |
c.triangle = &triangle.Image{*c.processor} | |
//... | |
// triangulate triangulates the detected face region | |
func (c *Canvas) triangulate(data []uint8, size image.Rectangle) ([]uint8, error) { | |
// Converts the buffer array to an image. | |
img := pixels.PixToImage(data, size) | |
// Call the face triangulation algorithm. | |
triangled, _, _, err := c.triangle.Draw(img, *c.processor, func() {}) | |
if err != nil { | |
return nil, err | |
} | |
dst := image.NewNRGBA(triangled.Bounds()) | |
draw.Draw(dst, triangled.Bounds(), triangled, image.Point{}, draw.Over) | |
return pixels.ImgToPix(dst), nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment