softon/laravel-face-detect

A Laravel Package for Face Detection and Cropping in Images.

v0.2.2 2023-03-15 05:32 UTC

This package is auto-updated.

Last update: 2024-12-15 09:08:06 UTC


README

A Laravel Package for Face Detection and Cropping in Images.

Installation

  1. Edit the composer.json add to the require array & run composer update
     "softon/laravel-face-detect": "dev-master" 
     composer update 
  2. Add the service provider to the config/app.php file in Laravel
     'Softon\LaravelFaceDetect\FaceDetectServiceProvider', 
  3. Add an alias for the Facade to the config/app.php file in Laravel
     'FaceDetect' => 'Softon\LaravelFaceDetect\Facades\FaceDetect', 
  4. Publish the config file by running
     php artisan vendor:publish 

Usage

To extract the Face and save the cropped image use...

use \Softon\LaravelFaceDetect\Facades\FaceDetect;


FaceDetect::extract($imagefilepath)->save($savefilepath);

To extract the Face and return the cropping coordinates without cropping the image...

use \Softon\LaravelFaceDetect\Facades\FaceDetect;


$crop_params = FaceDetect::extract($imagefilepath)->face;   // return array with x,y,width

To detect if face is found in a image...

use \Softon\LaravelFaceDetect\Facades\FaceDetect;


$crop_params = FaceDetect::extract($imagefilepath)->face_found;     // returns true/false

You may edit the config file facedetect.php in the config directory to add aditional padding to the cropped Images.