Использование неразрешенного идентификатора 'drawPoint' - PullRequest
0 голосов
/ 19 сентября 2019

Я пытаюсь определить лицо с помощью FirebaseMLVision.Я перешел по ссылке ниже: https://codelabs.developers.google.com/codelabs/mlkit-ios/#6

Но здесь я получаю сообщение об ошибке «Использование неразрешенного идентификатора« drawPoint »» в строке «drawPoint (point, in: .orange, transform: transform)»Я дал мой код ниже. Может ли кто-нибудь помочь мне решить эту проблему. Спасибо заранее.

  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
    }


}
...