PHP code example of aoding9 / compreface-laravel-sdk

1. Go to this page and download the library: Download aoding9/compreface-laravel-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aoding9 / compreface-laravel-sdk example snippets


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;

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

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

$recognitionService->recognize($path_to_image);

$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);

let recognitionService = compreFace.initFaceRecognitionService(api_key);

let detectionService = compreFace.initFaceDetectionService(api_key);

let verificationService = compreFace.initFaceVerificationService(api_key);

$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)

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

$faceCollection->add($image_location, $name, $options);
javascript
let subjects = recognitionService.getSubjects();
subjects.add("John");