Skip to content

Commit 2092909

Browse files
author
Cesar Vargas Casaseca
committed
Update Readme
1 parent 01cb8c8 commit 2092909

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

FaceLayout.jpg

898 KB
Loading

README.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import Warhol
5858
[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate Alamofire into your Xcode project using Carthage, specify it in your `Cartfile`:
5959

6060
```ogdl
61-
github "toupper/Warhol" ~> 0.1.2
61+
github "toupper/Warhol" ~> 0.2.0
6262
```
6363

6464
### Swift Package Manager
@@ -69,7 +69,7 @@ Once you have your Swift package set up, adding Warhol as a dependency is as eas
6969

7070
```swift
7171
dependencies: [
72-
.package(url: "https://github.com/toupper/Warhol.git", .upToNextMajor(from: "0.1.2"))
72+
.package(url: "https://github.com/toupper/Warhol.git", .upToNextMajor(from: "0.2.0"))
7373
]
7474
```
7575
## Manually
@@ -96,7 +96,7 @@ You can also integrate Warhol into your project manually.
9696

9797
## Usage example
9898

99-
### With Camera
99+
### From Camera, Draw on Top
100100

101101
Import Warhol in the file you are going to use it. Create an instance of ```CameraFaceDetectionViewController```, and asign the view where you are going to draw to the ```cameraFrontView``` property of the former. You can then present the view controller:
102102

@@ -134,8 +134,32 @@ final class FaceView: UIView, CameraFrontView {
134134

135135
...
136136
```
137+
138+
### From Camera, Add Images on Face Features
139+
140+
<p align="center">
141+
<img src="FaceLayout.jpg" width="375 max-width="90%" alt="FaceLayouts" />
142+
</p>
143+
144+
If you want to add images on top of each Face Features, you have to compose a ```FaceLayout``` object defining an ```ImageLayout``` object for each type of Face Landmark you want to draw. You can set the desired offset and Size Ratio for each feature. Once you have it, you should then pass it to the faceLayout property of the ```CameraFaceDetectionViewController```. Please notice that if you do that the ```cameraFrontView``` property gets overriden:
145+
146+
```
147+
let cameraViewController = CameraFaceDetectionViewController()
148+
149+
let leftEye = ImageLayout(image: UIImage(named: "leftEye")!, sizeRatio: SizeRatio(width: 1, height: 4))
150+
let rightEye = ImageLayout(image: UIImage(named: "rightEye")!, sizeRatio: SizeRatio(width: 1, height: 4))
151+
let nose = ImageLayout(image: UIImage(named: "nose")!)
152+
153+
let faceLayout = FaceLayout(landmarkLayouts: [.leftEye: leftEye,
154+
.rightEye: rightEye,
155+
.nose: nose])
156+
cameraViewController.faceLayout = faceLayout
157+
158+
present(cameraViewController, animated: true, completion: nil)
159+
```
160+
137161
Apart from that, you can implement the ```CameraFaceDetectionDelegate``` protocol to react to any change in the Face Dectection. This can be convenient for the case when you do not want to draw on top, but just get the face features (landmarks) coordinates. These are encapsulated in the given parameter ```FaceViewModel```.
138-
### With Image
162+
### From Image
139163
140164
In order to detect a face features and draw on top, we should pass the sdk the UIImageView depicting the face, and a closure where we draw on top of the image:
141165
```swift

0 commit comments

Comments
 (0)