任何想法,如何在面部检测中将口红涂在嘴唇上。我已经完成了颜色,但我想展示光泽和闪亮。关于如何在 MLKit ios 应用程序中使用纹理和阴影的任何想法
只需找到嘴唇点并创建 CAShapelayer 图层,然后填充颜色。在 ARKit 中,我们可以使用场景包和场景视图,因此我们可以轻松添加材质和纹理等等。但是我们如何在 mlkit 中使用
[![在此处输入图像描述][1]][1]
Q1。是否可以在 mlkit 中将场景视图用于材质和纹理。
Q2。或者如何在所有点上绘制图像(嘴唇、眼睛、眉毛)
// MARK: Contour func
private func addContours(for face: VisionFace, width: CGFloat, height: CGFloat) {
let facez = SCNScene()
guard let facez = SCNScene(named: "8.scn") else {
return
}
facez.rootNode.scale = SCNVector3(1,1,1)
let multipl :CGFloat = 200.0
let xoff :CGFloat = 0.98
let yoff : CGFloat = 1.76
let xp = ((face.frame.origin.x) / multipl) - xoff
let yp = ((face.frame.origin.y) / multipl) - yoff
facez.rootNode.position = SCNVector3(xp, yp, -1)
facez.rootNode.eulerAngles = SCNVector3(-1,1,0)
cameraView.allowsCameraControl = true
cameraView.autoenablesDefaultLighting = true
cameraView.scene = facez
let materials = facez.rootNode.geometry?.firstMaterial
materials?.diffuse.contents = UIColor.red
}
我试过这样
public static func addleftImage(
atPoint point: CGPoint,
to view: UIView,
color: UIColor,
radius: CGFloat
) {
let divisor: CGFloat = 2.0
let xCoord = point.x - radius / divisor
let yCoord = point.y - radius / divisor
let circleRect = CGRect(x: xCoord, y: yCoord, width: radius, height: radius)
let circleView = UIImageView(frame: circleRect)
circleView.image = #imageLiteral(resourceName: "leftEye")
circleView.layer.cornerRadius = radius / divisor
circleView.alpha = Constants.circleViewAlpha
circleView.backgroundColor = color
view.addSubview(circleView)
}
但没有运气!