当我尝试使用apple faceDetection SDK时,它成功检测到右眼位置,从而形成了两只眼睛之间的贝塞尔曲线。
我需要知道张开眼睛时要在眼睛上方制作图像,并随眼睛张开角度减小图像的宽度和高度。
我使用此功能,但没有给我正确的结果
func draw(points: [(x: CGFloat, y: CGFloat)]) {
let newLayer = CAShapeLayer()
newLayer.lineWidth = 2.0
let path = UIBezierPath()
path.move(to: CGPoint(x: points[0].x, y: points[0].y))
for i in 0..<points.count - 1 {
var point: CGPoint = .zero
point = CGPoint(x: points[i].x, y: points[i].y)
path.addLine(to: point)
path.move(to: point)
path.addLine(to: CGPoint(x: points[0].x, y: points[0].y))
}
newLayer.path = path.cgPath
newLayer.contents = UIImage(named:"eye2.png")?.cgImage;
newLayer.contentsGravity = kCAGravityResizeAspectFill
newLayer.isGeometryFlipped = false
print("Hello Swift",shapeLayer.bounds)
shapeLayer.addSublayer(newLayer)
}