freearhey / laravel-face-detection
A Laravel Package for Face Detection and Cropping in Images.
Installs: 1 621
Dependents: 0
Suggesters: 0
Security: 0
Stars: 32
Watchers: 5
Forks: 15
Open Issues: 3
Requires
- php: ^8.1
- illuminate/support: ^9.0
- intervention/image: ^2.5
Requires (Dev)
- phpunit/phpunit: ^9.0
README
A Laravel Package for Face Detection.
Installation
- Install the package via composer:
composer require freearhey/laravel-face-detection
- Add the service provider to the
config/app.php
file in Laravel:
'providers' => [ ... Arhey\FaceDetection\FaceDetectionServiceProvider::class, ... ],
- Publish the config file by running:
php artisan vendor:publish
Usage
use Arhey\FaceDetection\Facades\FaceDetection; $face = FaceDetection::extract('path/to/image.jpg');
To detect if face is found in a image:
if($face->found) { // face found } else { // face not found }
To get the facial boundaries:
var_dump($face->bounds); /* array( 'x' => 292.0, 'y' => 167.0, 'w' => 204.8, 'h' => 204.8, ) */
To save the found face image:
$face->save('path/to/output.jpg');
Testing
vendor/bin/phpunit