A PHP Library built for the Microsoft's Face API.

v1.1 2017-02-10 12:03 UTC

This package is auto-updated.

Last update: 2024-11-12 19:46:41 UTC


README

A PHP Library built for the Microsoft's Cognitive Services.

Cognitive Services: Face API

Actively Maintained Latest Stable Version Total Downloads Scrutinizer Code Quality Build Status Codacy Badge License

Table of contents

Requirements

Kindly subscribe for an API key to Microsoft's Cognitive Services API page.

Installation

Open your composer.json file and add the following to the require key:

"ridvanbaluyos/face": "v1.1"

After adding the key, run composer update from the command line to install the package

composer install

or

composer update

Configuration

Add your subscription key in src/Ridvanbaluyos/Face/config.json file

{
	"url" : "https://westus.api.cognitive.microsoft.com/face/v1.0/detect",
	"subscriptionKey" : "zWwPD7BGWYEArX6u6QxvS25TTsNge2Qw"
}

Usage

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

Detecting a face

$face->getFaces();

Analyzing Face Landmarks

$face->analyzeFaceLandmarks()->getFaces();

Analyzing Face Attributes

$face->analyzeFaceAttributes()->getFaces();

Chaining options

$face->analyzeFaceLandmarks()->analyzeFaceAttributes()->getFaces();

Alternatively, you can analyze all possible options

$face->analyzeAll()->getFaces();

References