youverse/face-api

为 Youverse.Face 提供生物特征处理(检测、验证和识别)功能。

v1.0.5 2022-10-24 15:34 UTC

README

https://yk-website-images.s3.eu-west-1.amazonaws.com/LogoV4_TRANSPARENT.png

Youverse Face API 客户端 SDK PHP

License Version

本仓库实现了一个集成 SDK,以简化对 Youverse.Face API 的使用,该 API 是 Youverse 服务提供的一部分。

如需更多信息,请联系我们

要求

PHP 5.5 及以上版本

入门指南

composer require youverse/face-api

示例

验证两张 base 64 编码的图片中人脸的相似度

require dirname(__DIR__) . '/vendor/autoload.php';

$apiKey = "YOUR-X-API-KEY";
$baseUrl = "YOUR-API-ENDPOINT";
$image1 = "<IMAGE_PATH>";
$image2 = "<IMAGE_PATH>";

$client = new Youverse\Face\Client\Face(
    $apiKey,
    $baseUrl
);

$payload = new Youverse\Face\Model\VerifyImages();

//convert image 1 to base64
$img = file_get_contents($image1);
$imgdata = base64_encode($img);
$payload->setFirstImage($imgdata);

//convert image 2 to base64
$img = file_get_contents($image2);
$imgdata = base64_encode($img);
$payload->setSecondImage($imgdata);

try {
    $result = $client->verifyImages($payload);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling FaceApi->verifyImages: ', $e->getMessage(), PHP_EOL;
}

如果您对使用 Youverse.Face API 进行身份识别感兴趣,请访问我们的示例