DroidsOnRoids / VisionFaceDetection

An example of use a Vision framework for face landmarks detection in iOS 11
https://www.thedroidsonroids.com/blog/face-and-faces-landmarks-detection-using-vision-framework
MIT License
262 stars 31 forks source link

Updated to latest XCode 9 beta and found a couple of issues #1

Open enzyme69 opened 7 years ago

enzyme69 commented 7 years ago

Revision: if let points = landmark?.normalizedPoints, let count = landmark?.pointCount {

But getting more errors: Cannot convert value of type '[CGPoint]' to expected argument type 'UnsafePointer' (aka 'UnsafePointer')

pr0n commented 7 years ago

Did you resolve the problem? If yes, can you share or commit your method?

djk12587 commented 7 years ago

Replace the convertPointsForFace with below, and it will work.

func convertPointsForFace(_ landmark: VNFaceLandmarkRegion2D?, _ boundingBox: CGRect) {
        if let points = landmark?.normalizedPoints {
            let faceLandmarkPoints = points.map { (point: CGPoint) -> (x: CGFloat, y: CGFloat) in
                let pointX = point.x * boundingBox.width + boundingBox.origin.x
                let pointY = point.y * boundingBox.height + boundingBox.origin.y

                return (x: pointX, y: pointY)
            }

            DispatchQueue.main.async {
                self.draw(points: faceLandmarkPoints)
            }
        }
    }
pr0n commented 7 years ago

Thanks for your sharing!

pournam commented 7 years ago

Im still getting this with the new function: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [VNFaceLandmarkRegion2D normalizedPoints]: unrecognized selector sent to instance

Any ideas?

panky8070 commented 6 years ago

Thanks for sharing the code.