Landmark detection (custom model and class-based)

This change extends existing landmark detection in new ways:
1. Existing logic is hiding HOG model (frontal_face_detector)
underneath and user cannot use other models (CNN model, for example).
2. Bounding box is exposed as additional argument, and user
can define custom bounding box (which is needed, if image used to detect
faces is changed (for example scaled), and we want to crop only face
from original image to feed into shape predictor).
3. This approach is class-based, so no need for multiple loadings of
shape predictor model (only once, in ctor)
This commit is contained in:
Branko Kokanovic
2018-08-27 20:46:47 +02:00
parent 3f60326661
commit 1a402fc63c
5 changed files with 205 additions and 5 deletions
+14 -2
View File
@@ -1,5 +1,5 @@
# PDlib - A PHP extension for Dlib
A PHP extension
A PHP extension
## Requirements
- Dlib 19.13+
@@ -71,7 +71,19 @@ var_dump($landmarks);
```
#### chinese whisers
Additionally, you can also use class-based approach:
```php
$rect = array("left"=>value, "top"=>value, "right"=>value, "bottom"=>value);
// You can download a trained facial shape predictor from:
// http://dlib.net/files/shape_predictor_5_face_landmarks.dat.bz2
$fld = new FaceLandmarkDetection("path/to/shape/predictor/model");
$parts = $fld->detect("path/to/image.jpg", $rect);
// $parts is integer array where keys are associative values with "x" and "y" for keys
```
Note that, if you use class-based approach, you need to feed bounding box rectangle with values obtained from `dlib_face_detection`. If you use `dlib_face_landmark_detection`, everything is already done for you (and you are using HOG face detection model).
#### chinese whispers
Provides raw access to dlib's `chinese_whispers` function.
Client need to build and provide edges. Edges are provided