face
Version 1.1 Release
為微軟的認知服務構建的PHP庫。
認知服務:面對API
請訂閱Microsoft的認知服務API頁面的API鍵。
打開您的composer.json文件,並將以下內容添加到require鍵:
"ridvanbaluyos/face": "v1.1"
添加密鑰後,從命令行中運行作曲家更新以安裝軟件包
composer install或者
composer update在src/Ridvanbaluyos/Face/config.json文件中添加您的訂閱密鑰
{
"url" : " https://westus.api.cognitive.microsoft.com/face/v1.0/detect " ,
"subscriptionKey" : " zWwPD7BGWYEArX6u6QxvS25TTsNge2Qw "
}
<?php
// namespace and autoloaders
use Ridvanbaluyos Face FaceDetection as FaceDetection ;
require_once __DIR__ . ' /vendor/autoload.php ' ;
// let's use Justin Bieber's photo
$ image = array (
' url ' => ' http://img2.timeinc.net/people/i/2014/database/140831/justin-bieber-300.jpg ' ,
);
// instantiate face detection object
$ face = new FaceDetection ( $ image );
?> $ face -> getFaces (); $ face -> analyzeFaceLandmarks ()-> getFaces (); $ face -> analyzeFaceAttributes ()-> getFaces (); $ face -> analyzeFaceLandmarks ()-> analyzeFaceAttributes ()-> getFaces (); $ face -> analyzeAll ()-> getFaces ();