From the course: Code Clinic: Swift
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Draw facial features - Swift Tutorial
From the course: Code Clinic: Swift
Draw facial features
- [Instructor] Now let's actually draw the facial features on the face, like the eyes, nose, and mouth. To do that we're going to create a method so that we can recycle code. I'll call this method drawLandmark, and it's going to receive a landmark which is of the type VNFaceLandmarkRegion2D. That's going to be optional. So the next parameter's going to be the context. That's going to be a CGContext optional. And then it will receive the face rectangle, because all of the coordinates for the landmarks are relative to the face. Call this rect. That'll be a CGRect. And then finally we'll receive a parameter called closePath. That's a Bool that we'll initialize to false. I'll close out the curly braces and scroll down so it's a little easier to see this method. So we have landmark that's our optional VNFaceLandmarkRegion2D. The context optional, rect, and closePath which is a Boolean with a default value. So let's call this method before we write any code in it, just to see if we can draw…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.