Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Make faces big by Vision and CoreGraphics

naru-jpn
March 02, 2018

Make faces big by Vision and CoreGraphics

“Can you make faces big?”

naru-jpn

March 02, 2018
Tweet

More Decks by naru-jpn

Other Decks in Technology

Transcript

  1. VNFaceLandmarkRegion2D Class 2D geometry information for a specific facial feature.

    VNFaceObservation Class Face or facial-feature information detected by an image analysis request.
  2. // 1. Create VNDetectFaceLandmarksRequest let request = VNDetectFaceLandmarksRequest() { (request,

    error) in guard let results = request.results else { return } let faceObservations = results.flatMap({ $0 as? VNFaceObservation }) // 3. Handle results // … } // 2. Create VNImageRequestHandler and perform let handler = VNImageRequestHandler(cgImage: cgImage, options: [:]) try! handler.perform([request]) How to get VNFaceLandmarkRegion2D
  3. O

  4. O A A-1 } } 1. translate 2. rotate 3.

    reverse + joint 4. rotate-1 5. translate-1
  5. Modify [CGPoint] in Swift // 1. Create CGAffineTransform A let

    A = CGAffineTransform(rotationAngle: -theta).translatedBy(x: x, y: y) // 2. Apply A let transformed = points.map { $0.applying(A) } // 3. Reverse & Joint let oval = transformed + transformed.map { CGPoint(x: -$0.x, y: -$0.y) } // 4. Apply A-1 let result = oval.map { $0.applying(A.inverted()) }