From the course: Code Clinic: Swift

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Draw face rectangles

Draw face rectangles - Swift Tutorial

From the course: Code Clinic: Swift

Start my 1-month free trial

Draw face rectangles

- [Instructor] The workflow for drawing our face rectangles involves creating a graphic context that can draw onto an image, setting up that object's settings properly, connecting it with our image, getting the face's rectangular data from our VN face observation object, and then updating the image in our image view. So let's start by creating a shortcut to our image. So let image equal image view dot image. This is just going to be a convenience constant to save us a little bit of time. And again, I'm writing inside of the show landmarks method. And then I'm going to call UI graphics begin image context with options. Then we need to specify a size. So I'll use image dot size. Opaque will be true, and then we'll just leave scale at zero for now. Let's go to the next line, and we're going to create a constant called context. This is going to be our graphics context object. UI graphics get current context. So we'll set it equal to that, and then we need to modify this object's settings…

Contents