naru-jpn
March 02, 2018
370

# Make faces big by Vision and CoreGraphics

“Can you make faces big?”

March 02, 2018

## Transcript

1. ### Make faces big by Vision and CoreGraphics VisionͱCoreGraphicsͰإΛσΧ͘͢Δ Naruki Chigira,

Timers inc. @naruchigi Try! Swift 2018

7. ### Vision ɾFace Detection and Recognition ɾBarcode Detection ɾText Detection ɾHorizon

Detection ɾObject Detection and Tracking
8. ### VNFaceLandmarkRegion2D Class 2D geometry information for a speciﬁc facial feature.

VNFaceObservation Class Face or facial-feature information detected by an image analysis request.

10. ### // 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

13. ### CGPoint Structure A structure that contains a point in a

two-dimensional coordinate system.

2D graphics.

rotate-1
21. ### O 1. translate 2. rotate 3. reverse + joint 4.

rotate-1 5. translate-1
22. ### O A A-1 } } 1. translate 2. rotate 3.

reverse + joint 4. rotate-1 5. translate-1
23. ### 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()) }

25. ### Summary Get facial features from Vision (iOS 11.0~) Process data

using CoreGraphics (iOS 2.0~) +