PHPackages                             aoding9/compreface-laravel-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. aoding9/compreface-laravel-sdk

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

aoding9/compreface-laravel-sdk
==============================

本sdk是根据compreface-javascript-sdk开发的laravel版本，仅做封装，将js改为laravel的写法，文档后半部分demo代码仍为js语法，参考前面即可

1.0(2y ago)1321Apache-2.0PHPPHP &gt;=7.4

Since Apr 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/aoding9/compreface-laravel-sdk)[ Packagist](https://packagist.org/packages/aoding9/compreface-laravel-sdk)[ RSS](/packages/aoding9-compreface-laravel-sdk/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (2)Used By (0)

CompreFace Laravel SDK
======================

[](#compreface-laravel-sdk)

CompreFace Laravel SDK makes face recognition into your application even easier.

> 注意：本sdk是根据[compreface-javascript-sdk](https://github.com/exadel-inc/compreface-javascript-sdk)开发的laravel版本，仅做封装，将js改为laravel的写法，文档后半部分demo代码仍为js语法，参考前面即可

Table of content
================

[](#table-of-content)

- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
    - [Initialization](#initialization)
    - [Adding faces into a face collection](#adding-faces-into-a-face-collection)
    - [Recognition](#recognition)
    - [Environments](#environments)
    - [Webcam demo](#webcam-demo)
- [Reference](#reference)
    - [CompreFace Global Object](#compreface-global-object)
        - [Methods](#methods)
    - [Recognition Service](#recognition-service)
        - [Recognize Faces from a Given Image](#recognize-faces-from-a-given-image)
        - [Get Face Collection](#get-face-collection)
            - [Add an Example of a Subject](#add-an-example-of-a-subject)
            - [List of All Saved Examples of the Subject](#list-of-all-saved-examples-of-the-subject)
            - [Delete All Examples of the Subject by Name](#delete-all-examples-of-the-subject-by-name)
            - [Delete an Example of the Subject by ID](#delete-an-example-of-the-subject-by-id)
            - [Verify Faces from a Given Image](#verify-faces-from-a-given-image)
        - [Get Subjects](#get-subjects)
            - [Add a Subject](#add-a-subject)
            - [List Subjects](#list-subjects)
            - [Rename a Subject](#rename-a-subject)
            - [Delete a Subject](#delete-a-subject)
            - [Delete All Subjects](#delete-all-subjects)
    - [Face Detection Service](#face-detection-service)
        - [Detect](#detect)
    - [Face Verification Service](#face-verification-service)
        - [Verify](#verify)
- [Contributing](#contributing)
    - [Report Bugs](#report-bugs)
    - [Submit Feedback](#submit-feedback)
- [License info](#license-info)

Requirements
============

[](#requirements)

Before using our SDK make sure you have installed CompreFace and Nodejs on your machine.

1. [CompreFace](https://github.com/exadel-inc/CompreFace#getting-started-with-compreface) (See below compatibility matrix)
2. [Nodejs](https://nodejs.org/en/) (Version 10+)

CompreFace compatibility matrix
-------------------------------

[](#compreface-compatibility-matrix)

CompreFace Laravel SDK versionCompreFace 0.4.xCompreFace 0.5.xCompreFace 0.6.xCompreFace 1.0.x1.0.x✘🟡🟡✔Explanation:

- ✔ SDK supports all functionality from CompreFace.
- 🟡 SDK works with this CompreFace version. In case if CompreFace version is newer - SDK won't support new features of CompreFace. In case if CompreFace version is older - new SDK features will fail.
- ✘ There are major backward compatibility issues. It is not recommended to use these versions together

Installation
============

[](#installation)

To add CompreFace Laravel SDK to your project, run the following command in the project folder:

> composer require aoding9/compreface-laravel-sdk

Usage
=====

[](#usage)

Initialization
--------------

[](#initialization)

To start using Laravel SDK you need to publish the SDK config file:

> php artisan vendor:publish --provider="Aoding9\\CompreFace\\CompreFaceServiceProvider"

Then you need to set `url` and `port` in `config/compreFace.php` or in `.env` file`. By default, if you run CompreFace on your local machine, it's `[http://localhost`](http://localhost%60) and `8000` respectively. You can pass optional `options` object when creating CompreFace to set default parameters, see reference for [more information](#compreface-global-object).

```
# .env
COMPRE_FACE_SEVER=http://localhost
COMPRE_FACE_PORT=8000
```

After you initialized `CompreFace` object you need to init the service object with the `api key` of your face service. You can use this service object to recognize faces.

However, before recognizing you need first to add faces into the face collection. To do this, get the face collection object from the service object.

```
use Aoding9\CompreFace\CompreFace;

$compreFace = app(CompreFace::class);
$recognitionService = $compreFace->initFaceRecognitionService($api_key); // initialize service

$faceCollection = $recognitionService->getFaceCollection(); // use face collection to fill it with known faces
$list = $faceCollection->list();

$subjects = $recognitionService->getSubjects(); // use subjects object to work with subjects directely

$path_to_image = public_path("uploads/images/wujing2.jpg");

$options = [
    'limit'              => 0,
    //'det_prob_threshold' => 0.8,
    //'prediction_count'   => 1,
    //'face_plugins'       => "calculator,age,gender,landmarks",
    //'status'             => "true",
];

$recognize = $recognitionService->recognize($path_to_image, $options);
dd($recognize['result'][0]['subjects'][0]['subject'] ?? $recognize); // 0.98546;
```

Adding faces into a face collection
-----------------------------------

[](#adding-faces-into-a-face-collection)

Here is Laravel code example that shows how to add an image to your face collection from your file system:

```
$path_to_image = public_path("images/boy.jpg");
$name ='Tom';
$faceCollection->add($path_to_image, $name);
```

Recognition
-----------

[](#recognition)

This code snippet shows how to recognize unknown face:

```
$path_to_image = public_path("images/boy.jpg");

$recognitionService->recognize($path_to_image);
```

Environments
------------

[](#environments)

NOTE: We provide 3 ways of uploading image to our SDK. They are url, blob and **absolute path** (from local machine).

Enviromentsfrom URLwith Blob formatfrom local machineBrowser✔✔✘Laravel✔✔✔Reference
=========

[](#reference)

CompreFace Global Object
------------------------

[](#compreface-global-object)

Global CompreFace Object is used for initializing connection to CompreFace and setting default values for options. Default values will be used in every service method if applicable. If the option’s value is set in the global object and passed as a function argument then the function argument value will be used.

**Constructor:**

`new CompreFace(server, port, options)`

ArgumentTypeRequiredNotesurlstringrequiredURL with protocol where CompreFace is located. E.g. `http://localhost`portstringrequiredCompreFace port. E.g. `8000`optionsobjectoptionalDefault values for face recognition servicesPossible options:

OptionTypeNotesdet\_prob\_thresholdstringminimum required confidence that a recognized face is actually a face. Value is between 0.0 and 1.0limitintegermaximum number of faces on the image to be recognized. It recognizes the biggest faces first. Value of 0 represents no limit. Default value: 0prediction\_countintegermaximum number of subject predictions per face. It returns the most similar subjects. Default value: 1face\_pluginsstringcomma-separated slugs of face plugins. If empty, no additional information is returned. [Learn more](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md)statusbooleanif true includes system information like execution\_time and plugin\_version fields. Default value is falseExample:

```
$server = "http://localhost";
$port = 8000;
$options = [
  'limit'=> 0,
  'det_prob_threshold'=> 0.8,
  'prediction_count'=> 1,
  'face_plugins'=> "calculator,age,gender,landmarks",
  'status'=> "true"
];

$compreFace = new CompreFace($server, $port, $options);
```

### Methods

[](#methods)

1. `compreFace.initFaceRecognitionService(api_key)`

Inits face recognition service object.

ArgumentTypeRequiredNotesapi\_keystringrequiredFace Recognition Api Key in UUID formatExample:

```
let recognitionService = compreFace.initFaceRecognitionService(api_key);
```

2. `compreFace.initFaceDetectionService(api_key)`

Inits face detection service object.

ArgumentTypeRequiredNotesapi\_keystringrequiredFace Detection Api Key in UUID formatExample:

```
let detectionService = compreFace.initFaceDetectionService(api_key);
```

3. `compreFace.initFaceVerificationService(api_key)`

Inits face verification service object.

ArgumentTypeRequiredNotesapi\_keystringrequiredFace Verification Api Key in UUID formatExample:

```
let verificationService = compreFace.initFaceVerificationService(api_key);
```

Recognition Service
-------------------

[](#recognition-service)

Face recognition service is used for face identification. This means that you first need to upload known faces to face collection and then recognize unknown faces among them. When you upload an unknown face, the service returns the most similar faces to it. Also, face recognition service supports verify endpoint to check if this person from face collection is the correct one. For more information, see [CompreFace page](https://github.com/exadel-inc/CompreFace).

### Recognize Faces from a Given Image

[](#recognize-faces-from-a-given-image)

`recognitionService.recognize(image_location, options)`

Recognizes all faces from the image. The first argument is the image location, it could be a URL or a path on the local machine.

ArgumentTypeRequiredNotesimage\_locationstringrequiredURL, image in BLOB format or image from your local machineoptionsstringoptionalObject that defines recognition optionsSupported options:

OptionTypeNotesdet\_prob\_thresholdstringminimum required confidence that a recognized face is actually a face. Value is between 0.0 and 1.0limitintegermaximum number of faces on the image to be recognized. It recognizes the biggest faces first. Value of 0 represents no limit. Default value: 0prediction\_countobjectmaximum number of subject predictions per face. It returns the most similar subjects. Default value: 1face\_pluginsstringcomma-separated slugs of face plugins. If empty, no additional information is returned. [Learn more](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md)statusbooleanif true includes system information like execution\_time and plugin\_version fields. Default value is falseResponse:

```
{
 "result" : [ {
   "age" : {
     "probability": 0.9308982491493225,
     "high": 32,
     "low": 25
   },
   "gender" : {
     "probability": 0.9898611307144165,
     "value": "female"
   },
   "mask" : {
     "probability": 0.9999470710754395,
     "value": "without_mask"
   },
   "embedding" : [ 9.424854069948196E-4, "...", -0.011415496468544006 ],
   "box" : {
     "probability" : 1.0,
     "x_max" : 1420,
     "y_max" : 1368,
     "x_min" : 548,
     "y_min" : 295
   },
   "landmarks" : [ [ 814, 713 ], [ 1104, 829 ], [ 832, 937 ], [ 704, 1030 ], [ 1017, 1133 ] ],
   "subjects" : [ {
     "similarity" : 0.97858,
     "subject" : "subject1"
   } ],
   "execution_time" : {
     "age" : 28.0,
     "gender" : 26.0,
     "detector" : 117.0,
     "calculator" : 45.0,
     "mask": 36.0
   }
 } ],
 "plugins_versions" : {
   "age" : "agegender.AgeDetector",
   "gender" : "agegender.GenderDetector",
   "detector" : "facenet.FaceDetector",
   "calculator" : "facenet.Calculator",
   "mask": "facemask.MaskDetector"
 }
}
```

ElementTypeDescriptionageobjectdetected age range. Return only if [age plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledgenderobjectdetected gender. Return only if [gender plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledmaskobjectdetected mask. Return only if [face mask plugin](https://github.com/exadel-inc/CompreFace/blob/master/docs/Face-services-and-plugins.md) is enabled.embeddingarrayface embeddings. Return only if [calculator plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledboxobjectlist of parameters of the bounding box for this faceprobabilityfloatprobability that a found face is actually a facex\_max, y\_max, x\_min, y\_minintegercoordinates of the frame containing the facelandmarksarraylist of the coordinates of the frame containing the face-landmarks. Return only if [landmarks plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledsubjectslistlist of similar subjects with size of &lt;prediction\_count&gt; order by similaritysimilarityfloatsimilarity that on that image predicted personsubjectstringname of the subject in Face Collectionexecution\_timeobjectexecution time of all pluginsplugins\_versionsobjectcontains information about plugin versionsExample:

```
$image_location = public_path("images/team.jpg");
$options = {
    'limit'=> 0,
    'det_prob_threshold'=> 0.8,
    'prediction_count'=> 1,
    'face_plugins'=> "calculator,age,gender,landmarks",
    'status'=> "true"
}

$recognitionService->recognize($image_location, $options)
```

### Get Face Collection

[](#get-face-collection)

`recognitionService.getFaceCollection()`

Returns Face collection object

Face collection could be used to manage known faces, e.g. add, list, or delete them.

Face recognition is performed for the saved known faces in face collection, so before using the `recognize` method you need to save at least one face into the face collection.

More information about face collection and managing examples [here](https://github.com/exadel-inc/CompreFace/blob/master/docs/Rest-API-description.md#managing-subject-examples)

**Methods:**

#### Add an Example of a Subject

[](#add-an-example-of-a-subject)

`faceCollection.add(image_location, subject, options)`

Adds an image to your face collection.

ArgumentTypeRequiredNotesimage\_locationstringrequiredURL, image in BLOB format or image from your local machinesubjectstringrequiredName or any other person ID. It can be just a random string you generate and save for further identificationoptionsstringoptionalObject that defines adding optionsSupported options:

OptionTypeNotesdet\_prob\_thresholdstringminimum required confidence that a recognized face is actually a face. Value is between 0.0 and 1.0Response:

```
{
 "image_id": "string",
 "subject": "string"
}
```

FieldstringNotesimage\_idstringID of the saved imagesubjectstringName or any other person IDExample:

```
$image_location = public_path("images/boy.jpg");
$name = 'Tom';
$options = [
    'det_prob_threshold'=> 0.8
];

$faceCollection->add($image_location, $name, $options);
```

#### List of All Saved Examples of the Subject

[](#list-of-all-saved-examples-of-the-subject)

`faceCollection.list()`

Retrieve a list of images saved in a Face Collection

Response:

```
{
  "faces": [
    {
      "image_id": "string",
      "subject": "string"
    }
  ]
}
```

FieldstringNotesimage\_idstringID of the saved imagesubjectstringName or any other person IDExample:

```
faceCollection.list()
    .then(response => {
        console.log(JSON.stringify(response));
    })
    .catch(error => {
        console.log(`Oops! There is problem: ${error}`)
    })
```

#### Delete All Examples of the Subject by Name

[](#delete-all-examples-of-the-subject-by-name)

`faceCollection.delete_all_subject(subject)`

Removes image(s) according to their given subject.

ArgumentTypeRequiredNotessubjectstringoptionalName or any other person ID. If empty deletes all images in the face collectionResponse:

```
{
    "deleted":
}

```

ElementTypeDescriptiondeletedintegerNumber of deleted facesExample:

```
let subject = "Tom";

faceCollection.delete(subject)
    .then(response => {
        console.log(JSON.stringify(response));
    })
    .catch(error => {
        console.log(`Oops! There is problem ${error}`)
    })
```

#### Delete an Example of the Subject by ID

[](#delete-an-example-of-the-subject-by-id)

`faceCollection.delete(image_id)`

Remove image from face collection.

ArgumentTypeRequiredNotesimage\_idstringrequiredID of the saved imageResponse:

```
{
 "image_id": "string",
 "subject": "string"
}
```

FieldstringNotesimage\_idstringID of the deleted imagesubjectstringName or any other person IDExample:

```
let image_id = "79ed78d8-f015-4947-b297-a24306ebbdad";

faceCollection.delete(image_id)
    .then(response => {
        console.log(JSON.stringify(response));
    })
    .catch(error => {
        console.log(`Oops! There is problem ${error}`)
    })
```

#### Delete Multiple Examples

[](#delete-multiple-examples)

`faceCollection.delete_multiple_images(image_ids)`

Remove images from face collection.

ArgumentTypeRequiredNotesimage\_idsstring\[\]requiredIDs of the saved images to deleteResponse:

```
{
 "image_id": "string",
 "subject": "string"
}
```

FieldstringNotesimage\_idstringID of the deleted imagesubjectstringName or any other person IDExample:

```
let image_id = "79ed78d8-f015-4947-b297-a24306ebbdad";

faceCollection.delete(image_id)
    .then(response => {
        console.log(JSON.stringify(response));
    })
    .catch(error => {
        console.log(`Oops! There is problem ${error}`)
    })
```

#### Verify Faces from a Given Image

[](#verify-faces-from-a-given-image)

`faceCollection.verify(image_path, image_id, options)`

Compares similarities of given image with image from your face collection.

ArgumentTypeRequiredNotesimage\_locationstringrequiredURL, image in BLOB format or image from your local machineoptionsstringoptionalObject that defines recognition optionsSupported options:

OptionTypeNotesdet\_prob\_thresholdstringminimum required confidence that a recognized face is actually a face. Value is between 0.0 and 1.0limitintegermaximum number of faces on the image to be recognized. It recognizes the biggest faces first. Value of 0 represents no limit. Default value: 0prediction\_countobjectmaximum number of subject predictions per face. It returns the most similar subjects. Default value: 1face\_pluginsstringcomma-separated slugs of face plugins. If empty, no additional information is returned. [Learn more](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md)statusbooleanif true includes system information like execution\_time and plugin\_version fields. Default value is falseResponse:

```
{
  "result" : [ {
    "age" : {
      "probability": 0.9308982491493225,
      "high": 32,
      "low": 25
    },
    "gender" : {
      "probability": 0.9898611307144165,
      "value": "female"
    },
    "mask" : {
      "probability": 0.9999470710754395,
      "value": "without_mask"
    },
    "embedding" : [ 9.424854069948196E-4, "...", -0.011415496468544006 ],
    "box" : {
      "probability" : 1.0,
      "x_max" : 1420,
      "y_max" : 1368,
      "x_min" : 548,
      "y_min" : 295
    },
    "landmarks" : [ [ 814, 713 ], [ 1104, 829 ], [ 832, 937 ], [ 704, 1030 ], [ 1017, 1133 ] ],
    "subjects" : [ {
      "similarity" : 0.97858,
      "subject" : "subject1"
    } ],
    "execution_time" : {
      "age" : 28.0,
      "gender" : 26.0,
      "detector" : 117.0,
      "calculator" : 45.0,
      "mask": 36.0
    }
  } ],
  "plugins_versions" : {
    "age" : "agegender.AgeDetector",
    "gender" : "agegender.GenderDetector",
    "detector" : "facenet.FaceDetector",
    "calculator" : "facenet.Calculator",
    "mask": "facemask.MaskDetector"
  }
}
```

ElementTypeDescriptionageobjectdetected age range. Return only if [age plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledgenderobjectdetected gender. Return only if [gender plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledmaskobjectdetected mask. Return only if [face mask plugin](https://github.com/exadel-inc/CompreFace/blob/master/docs/Face-services-and-plugins.md) is enabled.embeddingarrayface embeddings. Return only if [calculator plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledboxobjectlist of parameters of the bounding box for this faceprobabilityfloatprobability that a found face is actually a facex\_max, y\_max, x\_min, y\_minintegercoordinates of the frame containing the facelandmarksarraylist of the coordinates of the frame containing the face-landmarks. Return only if [landmarks plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledsimilarityfloatsimilarity that on that image predicted personexecution\_timeobjectexecution time of all pluginsplugins\_versionsobjectcontains information about plugin versions```
let image_location = "../images/team.jpg";
let image_id = "79ed78d8-f015-4947-b297-a24306ebbdad";
let options = {
    limit: 0,
    det_prob_threshold: 0.8,
    prediction_count: 1,
    face_plugins: "calculator,age,gender,landmarks,mask",
    status: "true"
}

faceCollection.verify(image_location, image_id, options)
    .then(response => {
        console.log(JSON.stringify(response));
    })
    .catch(error => {
        console.log(`Oops! There is problem with verifying image ${error}`)
    })
```

### Get Subjects

[](#get-subjects)

```
recognitionService.getSubjects()
```

Returns subjects object

Subjects object allows working with subjects directly (not via subject examples).

More information about subjects [here](https://github.com/exadel-inc/CompreFace/blob/master/docs/Rest-API-description.md#managing-subjects)

```
let subjects = recognitionService.getSubjects();
```

**Methods:**

#### Add a Subject

[](#add-a-subject)

Create a new subject in Face Collection.

```
subjects.add(subject)
```

ArgumentTypeRequiredNotessubjectstringrequiredis the name of the subject. It can be any stringResponse:

```
{
  "subject": "subject1"
}
```

ElementTypeDescriptionsubjectstringis the name of the subject```
let subjects = recognitionService.getSubjects();
subjects.add("John");
```

#### List Subjects

[](#list-subjects)

Returns all subject related to Face Collection.

```
subjects.list()
```

Response:

```
{
  "subjects": [
    "",
    ""
  ]
}
```

ElementTypeDescriptionsubjectsarraythe list of subjects in Face Collection```
let subjects = recognitionService.getSubjects();
console.log(subjects.list());
```

#### Rename a Subject

[](#rename-a-subject)

Rename existing subject. If a new subject name already exists, subjects are merged - all faces from the old subject name are reassigned to the subject with the new name, old subject removed.

```
subjects.rename(subject, new_name)
```

ArgumentTypeRequiredNotessubjectstringrequiredis the name of the subject that will be updatednew\_namestringrequiredis the name of the subject. It can be any stringResponse:

```
{
  "updated": "true|false"
}
```

ElementTypeDescriptionupdatedbooleanfailed or success```
let subjects = recognitionService.getSubjects();
subjects.add("John");
console.log(subjects.list());
subjects.rename("John", "Jane");
console.log(subjects.list());
```

#### Delete a Subject

[](#delete-a-subject)

Delete existing subject and all saved faces.

```
subjects.delete(subject)
```

ArgumentTypeRequiredNotessubjectstringrequiredis the name of the subject.Response:

```
{
  "subject": "subject1"
}
```

ElementTypeDescriptionsubjectstringis the name of the subject```
let subjects = recognitionService.getSubjects();
subjects.add("John");
console.log(subjects.list());
subjects.delete("John");
console.log(subjects.list());
```

#### Delete All Subjects

[](#delete-all-subjects)

Delete all existing subjects and all saved faces.

```
subjects.deleteAll()
```

Response:

```
{
  "deleted": ""
}
```

ElementTypeDescriptiondeletedintegernumber of deleted subjects```
let subjects = recognitionService.getSubjects();
subjects.add("John");
subjects.add("Jane");
console.log(subjects.list());
subjects.deleteAll();
console.log(subjects.list());
```

Face Detection Service
----------------------

[](#face-detection-service)

Face detection service is used for detecting faces in the image.

**Methods:**

### Detect

[](#detect)

`detectionService.detect(image_location, options)`

Finds all faces on the image. The first argument is the image location, it could be a URL or a path on the local machine.

ArgumentTypeRequiredNotesimage\_locationstringrequiredURL, image in BLOB format or image from your local machineoptionsstringoptionalObject that defines detection optionsSupported options:

OptionTypeNotesdet\_prob\_thresholdstringminimum required confidence that a recognized face is actually a face. Value is between 0.0 and 1.0limitintegermaximum number of faces on the image to be recognized. It recognizes the biggest faces first. Value of 0 represents no limit. Default value: 0face\_pluginsstringcomma-separated slugs of face plugins. If empty, no additional information is returned. [Learn more](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md)statusbooleanif true includes system information like execution\_time and plugin\_version fields. Default value is falseResponse:

```
{
  "result" : [ {
    "age" : {
      "probability": 0.9308982491493225,
      "high": 32,
      "low": 25
    },
    "gender" : {
      "probability": 0.9898611307144165,
      "value": "female"
    },
    "mask" : {
      "probability": 0.9999470710754395,
      "value": "without_mask"
    },
    "embedding" : [ -0.03027934394776821, "...", -0.05117142200469971 ],
    "box" : {
      "probability" : 0.9987509250640869,
      "x_max" : 376,
      "y_max" : 479,
      "x_min" : 68,
      "y_min" : 77
    },
    "landmarks" : [ [ 156, 245 ], [ 277, 253 ], [ 202, 311 ], [ 148, 358 ], [ 274, 365 ] ],
    "execution_time" : {
      "age" : 30.0,
      "gender" : 26.0,
      "detector" : 130.0,
      "calculator" : 49.0,
      "mask": 36.0
    }
  } ],
  "plugins_versions" : {
    "age" : "agegender.AgeDetector",
    "gender" : "agegender.GenderDetector",
    "detector" : "facenet.FaceDetector",
    "calculator" : "facenet.Calculator",
    "mask": "facemask.MaskDetector"
  }
}
```

ElementTypeDescriptionageobjectdetected age range. Return only if [age plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledgenderobjectdetected gender. Return only if [gender plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledmaskobjectdetected mask. Return only if [face mask plugin](https://github.com/exadel-inc/CompreFace/blob/master/docs/Face-services-and-plugins.md) is enabled.embeddingarrayface embeddings. Return only if [calculator plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledboxobjectlist of parameters of the bounding box for this face (on processedImage)probabilityfloatprobability that a found face is actually a face (on processedImage)x\_max, y\_max, x\_min, y\_minintegercoordinates of the frame containing the face (on processedImage)landmarksarraylist of the coordinates of the frame containing the face-landmarks. Return only if [landmarks plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledexecution\_timeobjectexecution time of all pluginsplugins\_versionsobjectcontains information about plugin versionsExample:

```
let image_location = "../images/team.jpg";
let options = {
    limit: 0,
    det_prob_threshold: 0.8,
    face_plugins: "calculator,age,gender,landmarks",
    status: "true"
}

detectionService.detect(image_location, options)
    .then(response => {
        console.log(JSON.stringify(response));
    })
    .catch(error => {
        console.log(`Oops! There is problem with recognizing image ${error}`)
    })
```

Face Verification Service
-------------------------

[](#face-verification-service)

Face verification service is used for comparing two images. A source image should contain only one face which will be compared to all faces on the target image.

**Methods:**

### Verify

[](#verify)

`verificationService.verify(source_image_location, target_image_location, options)`

Compares two images provided in arguments. Source image should contain only one face, it will be compared to all faces in the target image. The first two arguments are the image location, it could be a URL or a path on the local machine.

ArgumentTypeRequiredNotessource\_image\_locationstringrequiredURL, source image in BLOB format or source image from your local machinetarget\_image\_locationstringrequiredURL, target image in BLOB format or target image from your local machineoptionsstringoptionalObject that defines detection optionsSupported options:

OptionTypeNotesdet\_prob\_thresholdstringminimum required confidence that a recognized face is actually a face. Value is between 0.0 and 1.0limitintegermaximum number of faces on the image to be recognized. It recognizes the biggest faces first. Value of 0 represents no limit. Default value: 0face\_pluginsstringcomma-separated slugs of face plugins. If empty, no additional information is returned. [Learn more](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md)statusbooleanif true includes system information like execution\_time and plugin\_version fields. Default value is falseResponse:

```
{
  "result" : [{
    "source_image_face" : {
      "age" : {
        "probability": 0.9308982491493225,
        "high": 32,
        "low": 25
      },
      "gender" : {
        "probability": 0.9898611307144165,
        "value": "female"
      },
      "mask" : {
        "probability": 0.9999470710754395,
        "value": "without_mask"
      },
      "embedding" : [ -0.0010271212086081505, "...", -0.008746841922402382 ],
      "box" : {
        "probability" : 0.9997453093528748,
        "x_max" : 205,
        "y_max" : 167,
        "x_min" : 48,
        "y_min" : 0
      },
      "landmarks" : [ [ 92, 44 ], [ 130, 68 ], [ 71, 76 ], [ 60, 104 ], [ 95, 125 ] ],
      "execution_time" : {
        "age" : 85.0,
        "gender" : 51.0,
        "detector" : 67.0,
        "calculator" : 116.0,
        "mask": 36.0
      }
    },
    "face_matches": [
      {
        "age" : {
          "probability": 0.9308982491493225,
          "high": 32,
          "low": 25
        },
        "gender" : {
          "probability": 0.9898611307144165,
          "value": "female"
        },
        "mask" : {
          "probability": 0.9999470710754395,
          "value": "without_mask"
        },
        "embedding" : [ -0.049007344990968704, "...", -0.01753818802535534 ],
        "box" : {
          "probability" : 0.99975,
          "x_max" : 308,
          "y_max" : 180,
          "x_min" : 235,
          "y_min" : 98
        },
        "landmarks" : [ [ 260, 129 ], [ 273, 127 ], [ 258, 136 ], [ 257, 150 ], [ 269, 148 ] ],
        "similarity" : 0.97858,
        "execution_time" : {
          "age" : 59.0,
          "gender" : 30.0,
          "detector" : 177.0,
          "calculator" : 70.0,
          "mask": 36.0
        }
      }],
    "plugins_versions" : {
      "age" : "agegender.AgeDetector",
      "gender" : "agegender.GenderDetector",
      "detector" : "facenet.FaceDetector",
      "calculator" : "facenet.Calculator",
      "mask": "facemask.MaskDetector"
    }
  }]
}
```

ElementTypeDescriptionsource\_image\_faceobjectadditional info about source image faceface\_matchesarrayresult of face verificationageobjectdetected age range. Return only if [age plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledgenderobjectdetected gender. Return only if [gender plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledmaskobjectdetected mask. Return only if [face mask plugin](https://github.com/exadel-inc/CompreFace/blob/master/docs/Face-services-and-plugins.md) is enabled.embeddingarrayface embeddings. Return only if [calculator plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledboxobjectlist of parameters of the bounding box for this faceprobabilityfloatprobability that a found face is actually a facex\_max, y\_max, x\_min, y\_minintegercoordinates of the frame containing the facelandmarksarraylist of the coordinates of the frame containing the face-landmarks. Return only if [landmarks plugin](https://github.com/exadel-inc/CompreFace/tree/master/docs/Face-services-and-plugins.md#face-plugins) is enabledsimilarityfloatsimilarity between this face and the face on the source imageexecution\_timeobjectexecution time of all pluginsplugins\_versionsobjectcontains information about plugin versionsExample:

```
let source_image_location = "../images/boy.jpg";
let target_image_location = "../images/team.jpg";
let options = {
    limit: 0,
    det_prob_threshold: 0.8,
    face_plugins: "calculator,age,gender,landmarks",
    status: "true"
}

verificationService.verify(source_image_location, target_image_location, options)
    .then(response => {
        console.log(JSON.stringify(response));
    })
    .catch(error => {
        console.log(`Oops! There is problem with recognizing image ${error}`)
    })
```

Contributing
============

[](#contributing)

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

After creating your first contributing pull request, you will receive a request to sign our Contributor License Agreement by commenting your pull request with a special message.

Report Bugs
-----------

[](#report-bugs)

Please report any bugs [here](https://github.com/exadel-inc/compreface-javascript-sdk/issues).

If you are reporting a bug, please specify:

- Your operating system name and version
- Any details about your local setup that might be helpful in troubleshooting
- Detailed steps to reproduce the bug

Submit Feedback
---------------

[](#submit-feedback)

The best way to send us feedback is to file an issue at .

If you are proposing a feature, please:

- Explain in detail how it should work.
- Keep the scope as narrow as possible to make it easier to implement.

License info
============

[](#license-info)

CompreFace JS SDK is open-source facial recognition SDK released under the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0.html).

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

794d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/65276046?v=4)[DOG Lo.ML](/maintainers/aoding9)[@aoding9](https://github.com/aoding9)

---

Top Contributors

[![aoding9](https://avatars.githubusercontent.com/u/65276046?v=4)](https://github.com/aoding9 "aoding9 (9 commits)")

### Embed Badge

![Health badge](/badges/aoding9-compreface-laravel-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/aoding9-compreface-laravel-sdk/health.svg)](https://phpackages.com/packages/aoding9-compreface-laravel-sdk)
```

###  Alternatives

[backpack/crud

Quickly build admin interfaces using Laravel, Bootstrap and JavaScript.

3.4k3.7M223](/packages/backpack-crud)[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

23.9k69.5k](/packages/grumpydictator-firefly-iii)[statamic/cms

The Statamic CMS Core Package

4.8k3.6M982](/packages/statamic-cms)[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[firefly-iii/data-importer

Firefly III Data Import Tool.

8035.8k](/packages/firefly-iii-data-importer)[ronasit/laravel-helpers

Provided helpers function and some helper class.

2085.6k30](/packages/ronasit-laravel-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
