freearhey / laravel-face-detection
用于在图片中检测和裁剪人脸的Laravel扩展包。
v1.4.0
2023-12-07 19:37 UTC
Requires
- php: ^8.1
- illuminate/support: ^9.0
- intervention/image: ^2.5
Requires (Dev)
- phpunit/phpunit: ^9.0
README
Laravel人脸检测扩展包。
安装
- 通过composer安装此包
composer require freearhey/laravel-face-detection
- 将服务提供者添加到Laravel的
config/app.php
文件中
'providers' => [ ... Arhey\FaceDetection\FaceDetectionServiceProvider::class, ... ],
- 运行以下命令发布配置文件
php artisan vendor:publish
用法
use Arhey\FaceDetection\Facades\FaceDetection; $face = FaceDetection::extract('path/to/image.jpg');
检测图片中是否有人脸
if($face->found) { // face found } else { // face not found }
获取人脸边界
var_dump($face->bounds); /* array( 'x' => 292.0, 'y' => 167.0, 'w' => 204.8, 'h' => 204.8, ) */
保存检测到的人脸图片
$face->save('path/to/output.jpg');
测试
vendor/bin/phpunit