{"id":19857974,"url":"https://github.com/boldare/xsolve-face-validator-bundle","last_synced_at":"2025-05-02T02:30:44.407Z","repository":{"id":57085020,"uuid":"102084452","full_name":"boldare/xsolve-face-validator-bundle","owner":"boldare","description":"Open-source Symfony3 bundle for validating faces on pictures","archived":false,"fork":false,"pushed_at":"2018-01-19T15:56:23.000Z","size":116,"stargazers_count":17,"open_issues_count":4,"forks_count":2,"subscribers_count":51,"default_branch":"master","last_synced_at":"2025-04-06T21:08:38.075Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://xsolve.software/blog/face-detection-open-source-symfony3/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boldare.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-01T07:10:20.000Z","updated_at":"2021-03-01T13:57:46.000Z","dependencies_parsed_at":"2022-08-24T14:10:14.670Z","dependency_job_id":null,"html_url":"https://github.com/boldare/xsolve-face-validator-bundle","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boldare%2Fxsolve-face-validator-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boldare%2Fxsolve-face-validator-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boldare%2Fxsolve-face-validator-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boldare%2Fxsolve-face-validator-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boldare","download_url":"https://codeload.github.com/boldare/xsolve-face-validator-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251972432,"owners_count":21673602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T14:20:34.182Z","updated_at":"2025-05-02T02:30:43.368Z","avatar_url":"https://github.com/boldare.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"----------\n# XSolve Face Validator Bundle\n\n[![Build Status](https://travis-ci.org/xsolve-pl/xsolve-face-validator-bundle.svg?branch=master)](https://travis-ci.org/xsolve-pl/xsolve-face-validator-bundle)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/xsolve-pl/xsolve-face-validator-bundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/xsolve-pl/xsolve-face-validator-bundle/?branch=master)\n\n============================\n\nTable of contents\n=================\n\n  * [Introduction](#introduction)\n  * [License](#license)\n  * [Getting started](#getting-started)\n  * [Usage](#usage)\n\nIntroduction\n=================\nThis Symfony3 bundle allows to validate whether an image (for instance uploaded by a user of your app) contains person's face.\nInternally it uses MS Azure Face API so in order to use it you need an account in MS Azure. In free plan the API allows\nto make 30 000 requests per month and 20 per minute so it should be enough to be useful for low traffic apps.\n\nAll the following features are configurable on the constraint level and can be easily enabled/disabled:\n  * requiring certain face size (ratio to the image size)\n  * disallowing an image when the face is covered\n  * requiring the hair to be visible (the image must not be cut)\n  * allowing the face to be rotated in any of the 3 axes to given level\n  * disallowing to wear glasses\n  * disallowing to wear sunglasses\n  * disallowing any makeup\n  * requiring an image not to be blurred over given level (low/medium/high)\n  * requiring an image not to contain noises over given level (low/medium/high)\n\nLicence\n=================\nThis library is under the MIT license. See the complete license in [LICENSE](LICENSE) file.\n\nGetting started\n=================\nAdd the bundle to your Symfony3 project using [Composer](https://getcomposer.org/):\n```bash\n$ composer require xsolve-pl/face-validator-bundle\n```\n\nYou'll need also to register the bundle in your kernel:\n```php\n\u003c?php\n// app/AppKernel.php\n\nclass AppKernel extends Kernel\n{\n    public function registerBundles()\n    {\n        $bundles = [\n            // ...\n            new XSolve\\FaceValidatorBundle\\XSolveFaceValidatorBundle(),\n        ];\n    }\n}\n```\n\nIn the configuration file you must provide your [MS Azure subscription key for Face API](https://azure.microsoft.com/en-us/try/cognitive-services/?api=face-api)\nand the region name (can be taken from the `Endpoint` section in MS Azure portal). Available regions can be previewed by running:\n\n```bash\n$ bin/console config:dump-reference xsolve_face_validator\n```\n\nExample configuration:\n\n```yml\n# app/config/config.yml\n\nxsolve_face_validator:\n    azure_subscription_key: your-subscription-key\n    region: westeurope\n```\n\nUsage\n=================\nCheck [this documentation](https://symfony.com/doc/current/controller/upload_file.html) if you'd like to know\nhow to allow users to upload files using Symfony forms and validation.\nAssuming in your application you already have some model representing a user (for instance Doctrine entity) and it's\nused in a form to gather the data from users and perform validation, it already contains a profile picture:\n\n```php\n// src/AppBundle/Entity/User.php\n\nuse Symfony\\Component\\HttpFoundation\\File\\UploadedFile;\nuse Symfony\\Component\\Validator\\Constraints as Assert;\nuse XSolve\\FaceValidatorBundle\\Validator\\Constraints as XSolveAssert;\n\nclass User\n{\n    /**\n     * @var UploadedFile\n     *\n     * @Assert\\Image()\n     * @XSolveAssert\\Face()\n     */\n    public $profilePicture;\n}\n```\n\nor with YML:\n```yml\n# src/AppBundle/Resources/config/validation.yml\nAppBundle\\Entity\\User:\n    properties:\n        profilePicture:\n            - Image\n            - XSolve\\FaceValidatorBundle\\Validator\\Constraints\\Face\n```\n\nFor other validation config formats please check [dedicated documentation section](http://symfony.com/doc/current/validation.html#constraint-configuration)\n\nNow when executing regular validation, for instance in your controller:\n```php\n// src/AppBundle/Controller/UserController.php\n\nnamespace AppBundle\\Controller;\n\nuse Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Route;\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller;\nuse Symfony\\Component\\Form\\Extension\\Core\\Type\\FileType;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse AppBundle\\Entity\\User;\n\nclass UserController extends Controller\n{\n    /**\n     * @Route(\"/user/new\", name=\"app_user_new\")\n     */\n    public function newAction(Request $request)\n    {\n        $user = new User();\n        $form = $this-\u003ecreateFormBuilder($user)\n            -\u003eadd('profilePicture', FileType::class)\n            -\u003egetForm();\n        $form-\u003ehandleRequest($request);\n\n        if ($form-\u003eisSubmitted() \u0026\u0026 $form-\u003eisValid()) {\n            // ...\n        }\n\n        // ...\n    }\n}\n```\n\nthe image will be validated whether it contains a face. The way the face is being validated is customizable, all the possible\noptions with their default values are shown on the example below:\n\n```php\n// src/AppBundle/Entity/User.php\n\nuse Symfony\\Component\\Validator\\Constraints as Assert;\nuse XSolve\\FaceValidatorBundle\\Validator\\Constraints as XSolveAssert;\n\nclass User\n{\n    /**\n     * @var Symfony\\Component\\HttpFoundation\\File\\UploadedFile\n\n     * @Assert\\Image()\n     * @XSolveAssert\\Face(\n     *     minFaceRatio = 0.15,\n     *     allowCoveringFace = true,\n     *     maxFaceRotation = 20.0,\n     *     allowGlasses = true,\n     *     allowSunglasses = true,\n     *     allowMakeup = true,\n     *     allowNoHair = true,\n     *     maxBlurLevel = high,\n     *     maxNoiseLevel = high,\n     *     noFaceMessage = 'Face is not visible.',\n     *     faceTooSmallMessage = 'Face is too small.',\n     *     faceCoveredMessage = 'Face cannot be covered.',\n     *     hairCoveredMessage = 'Hair cannot be covered.',\n     *     tooMuchRotatedMessage = 'Face is too much rotated.',\n     *     glassesMessage = 'There should be no glasses in the picture.',\n     *     sunglassesMessage = 'There should be no sunglasses in the picture.',\n     *     makeupMessage = 'The person should not be wearing any makeup.',\n     *     blurredMessage = 'The picture is too blurred.',\n     *     noiseMessage = 'The picture is too noisy.'\n     * )\n     */\n    public $profilePicture;\n}\n```\n\nNote that you can omit any (or even all) of the options listed above, then the defaults will be used.\n\nFor blur and noise levels the possible options are:\n  * low\n  * medium\n  * high\n\nIt's also possible, just like with any other Symfony validator, to use it directly against given value (either file path or an instance of \\SplFileInfo).\n\n```php\n// src/AppBundle/Controller/ImageController.php\n\nnamespace AppBundle\\Controller;\n\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller;\nuse Symfony\\Component\\Validator\\Validator\\ValidatorInterface;\n\nclass ImageController extends Controller\n{\n    public function validateAction(Request $request)\n    {\n        /* @var $validator ValidatorInterface */\n        $validator = $this-\u003eget('validator');\n        $constraintViolations = $validator-\u003evalidate(\n            '/path/to/your/image/file.png',\n            new Face([\n                // you can pass the options mentioned before to the validation constraint\n            ])\n        );\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboldare%2Fxsolve-face-validator-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboldare%2Fxsolve-face-validator-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboldare%2Fxsolve-face-validator-bundle/lists"}