使用未解决的标识符“ drawPoint”

时间:2019-09-19 10:28:28

标签: ios swift4.2

我正在尝试使用FirebaseMLVision检测面部。我点击了以下链接:https://codelabs.developers.google.com/codelabs/mlkit-ios/#6

但是在这里,我在“ drawPoint(point,in:.orange,transform:transform)”这一行收到“未解析的标识符'drawPoint'的使用”错误。我在下面给出了我的代码。谁能帮我解决这个问题。谢谢。

  private func addContours(forFace face: VisionFace, transform: CGAffineTransform) {
        // Face
        if let faceContour = face.contour(ofType: .face) {
            for point in faceContour.points {
                drawPoint(point, in: .blue, transform: transform)
            }
        }

        // Eyebrows
        if let topLeftEyebrowContour = face.contour(ofType: .leftEyebrowTop) {
            for point in topLeftEyebrowContour.points {
                drawPoint(point, in: .orange, transform: transform)
            }
        }
        if let bottomLeftEyebrowContour = face.contour(ofType: .leftEyebrowBottom) {
            for point in bottomLeftEyebrowContour.points {
                drawPoint(point, in: .orange, transform: transform)
            }
        }
        if let topRightEyebrowContour = face.contour(ofType: .rightEyebrowTop) {
            for point in topRightEyebrowContour.points {
                drawPoint(point, in: .orange, transform: transform)
            }
        }
        if let bottomRightEyebrowContour = face.contour(ofType: .rightEyebrowBottom) {
            for point in bottomRightEyebrowContour.points {
                drawPoint(point, in: .orange, transform: transform)
            }
        }

        // Eyes
        if let leftEyeContour = face.contour(ofType: .leftEye) {
            for point in leftEyeContour.points {
                drawPoint(point, in: .cyan, transform: transform)
            }
        }
        if let rightEyeContour = face.contour(ofType: .rightEye) {
            for point in rightEyeContour.points {
                drawPoint(point, in: .cyan, transform: transform)
            }
        }

        // Lips
        if let topUpperLipContour = face.contour(ofType: .upperLipTop) {
            for point in topUpperLipContour.points {
                drawPoint(point, in: .red, transform: transform)
            }
        }
        if let bottomUpperLipContour = face.contour(ofType: .upperLipBottom) {
            for point in bottomUpperLipContour.points {
                drawPoint(point, in: .red, transform: transform)
            }
        }
        if let topLowerLipContour = face.contour(ofType: .lowerLipTop) {
            for point in topLowerLipContour.points {
                drawPoint(point, in: .red, transform: transform)
            }
        }
        if let bottomLowerLipContour = face.contour(ofType: .lowerLipBottom) {
            for point in bottomLowerLipContour.points {
                drawPoint(point, in: .red, transform: transform)
            }
        }

        // Nose
        if let noseBridgeContour = face.contour(ofType: .noseBridge) {
            for point in noseBridgeContour.points {
                drawPoint(point, in: .yellow, transform: transform)
            }
        }
        if let noseBottomContour = face.contour(ofType: .noseBottom) {
            for point in noseBottomContour.points {
                drawPoint(point, in: .yellow, transform: transform)
            }
        }
    }
    private func transformMatrix() -> CGAffineTransform {
        guard let image = imagee.image else { return CGAffineTransform() }
        let imageViewWidth = imagee.frame.size.width
        let imageViewHeight = imagee.frame.size.height
        let imageWidth = image.size.width
        let imageHeight = image.size.height

        let imageViewAspectRatio = imageViewWidth / imageViewHeight
        let imageAspectRatio = imageWidth / imageHeight
        let scale = (imageViewAspectRatio > imageAspectRatio) ?
            imageViewHeight / imageHeight :
            imageViewWidth / imageWidth

        // Image view's `contentMode` is `scaleAspectFit`, which scales the image to fit the size of the
        // image view by maintaining the aspect ratio. Multiple by `scale` to get image's original size.
        let scaledImageWidth = imageWidth * scale
        let scaledImageHeight = imageHeight * scale
        let xValue = (imageViewWidth - scaledImageWidth) / CGFloat(2.0)
        let yValue = (imageViewHeight - scaledImageHeight) / CGFloat(2.0)

        var transform = CGAffineTransform.identity.translatedBy(x: xValue, y: yValue)
        transform = transform.scaledBy(x: scale, y: scale)
        return transform
    }


}

0 个答案:

没有答案