thiagormoreira/awsfacematch
Composer 安装命令:
composer require thiagormoreira/awsfacematch
包简介
AWS face match package for Laravel
关键字:
README 文档
README
This component integrates face recognition to conventional Laravel models such as users with avatar images. This package compares a single face image against an indexed collection of images and returns a matching model with an accuracy score greater than 80%.
This component uses the AWS Rekogniton engine. Please review the site for credentials setup and prices.
Installation
To install through composer, simply execute the following command :
composer require grananda/AwsFaceMatch
Execute the following command to copy the configuration file to your application config folder:
php artisan vendor:publish --provider="Grananda\AwsFaceMatch\FaceMatchServiceProvider"
Add your AWS AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY credentials to your .env file.
For the component to work, you need a set of AWS key and secret as well as the zone where you wish to operate. This values will be read from you .env file as usual. Other configuration parameters will be included in the facematch.php config file.
Please remember that for older versions on Laravel <5.5, it is necessary to register the component service provider in your config/app.php file under the $providers array element.
Grananda\AwsFaceMatch\FaceMatchServiceProvider::class,
Also, in the $aliases array element, add the following available facades for this package. This is only necessary if you wish to access the package services method outside the trait scope.
'FaceMatch' => Grananda\AwsFaceMatch\Facades\FaceMatch::class, 'FaceCollection' => Grananda\AwsFaceMatch\Facades\FaceCollection::class,
Finally, run thepackage migrations that will create tables where indexed information will be stored.
php artisan migrate
Setup your Eloquent models
Laravel Face Match can recognize people from different models. For example, if you have models for clients and employees, you can request an image match against any of those models.
To start using this package, you must have the model(s) registered in the face match configuration file as displayed below:
'recognize' => [ Employee::class => [ 'collection' => 'entity', 'identifier' => 'uuid,', 'media' => [ 'field' => 'avatar_image', 'binary' => false, ], ], ],
Where every element of the recognize array element correspond to an existing model class. Each element key must match the model class name. Additionally, the elements must be completed as followed per each of the used models:
- Collection: wherein AWS will the avatar images and user references be indexed. If none, a combination of the model
namespaceandclassNamewill be used as the default collection name. - Identifier: which unique field in the model database will be used to identify the record once a face match occurs. It is recommended to use a UUID field for such a purpose.
- Field: determines which field in the model database will the face image URL be stored.
- Binary: defines if the field that stores the image information is a binary or blob field. Default is
false.
To make a model suitable for face recognition, you must add the FacialRecognition trait to your models as illustrated below.
namespace App\Models; use Illuminate\Database\Eloquent\Model; use Grananda\AwsFaceMatch\Traits\FacialRecognition; class Employee extends Model { use FacialRecognition; protected $fillable = [ 'name', 'uuid', 'avatar_image', ]; }
In addition, both the field and identifier fields should be included in the model fillable array as well as in your database migrations if necessary.
You can add the face match functionality to as many models as you wish as far as they do not share the same collection.
No AWS S3 Bucket it needed but could be used for storing your model images. All that is needed is an image URL or a binary database record with the image data.
The system only accepts single face images when indexing an entity for future recognition.
How to Use it
When a model using the FacialRecognition trait creates a new object, the avatar image is stored in the AWS Rekognition services along with the record identifier. The same occurs when the record is updated with a different image URL. No Rekognition index action will take place if the record lacks a media URL or data when saving the item.
Wiselike, all stored indexed information is removed from the AWS when a model is locally removed.
Identifying models from an image
Use the following command If you wish to find a model that may match a specif image:
Employee::faceMatch('path/or/url/to/image.png');
Where Employee can be replaced by any other model using the face match feature. If there is a match, the command will return the model object corresponding to the given image or false otherwise.
Although the system can index images from binary database fields, the match or recognition process must use a file system based stored image path to function. Pure binary comparison is not yet supported. Please help us improve this component by providing a valid use case for this scenario.
Forgetting an Image
Use the following comand to remove a local record from the remote AWS Rekognition system. This feature can be useful when a user requests to be removed from the face recognition system.
Employee::faceForget($object);
Cleaning up
The following command will remove all images from a model collection. Please use it wisely.
Employee::purgeCollection();
Mass Indexing
To indexing already existing data, run the following command from the console:
php artisan facematch:index
Comming Soon
- Manually specify the accuracy threshold when detecting matches.
Please feel free to comment and make requests.
thiagormoreira/awsfacematch 适用场景与选型建议
thiagormoreira/awsfacematch 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 12 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「aws」 「Match」 「face」 「rekognition」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 thiagormoreira/awsfacematch 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 thiagormoreira/awsfacematch 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 thiagormoreira/awsfacematch 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Interface for Babel Street Text Analytics
This package includes a script and fail2ban configuration that allows you to use fail2ban when utilizing AWS elastic load balancer (ELB) and an apache webserver.
AppVerk extension of PHP Matcher, it enables you to match values with patterns
Elastic Driver for Laravel Scout
A client for Happyr match API
simple api library.
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-17