VisionFaceDetection icon indicating copy to clipboard operation
VisionFaceDetection copied to clipboard

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

Open enzyme69 opened this issue 7 years ago • 5 comments

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<vector_float2>' (aka 'UnsafePointer')

enzyme69 avatar Sep 02 '17 01:09 enzyme69

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

pr0n avatar Sep 10 '17 09:09 pr0n

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)
            }
        }
    }

djk12587 avatar Sep 14 '17 19:09 djk12587

Thanks for your sharing!

pr0n avatar Sep 15 '17 05:09 pr0n

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?

pournam avatar Nov 24 '17 21:11 pournam

Thanks for sharing the code.

panky8070 avatar Jan 18 '18 14:01 panky8070