Giter Club home page Giter Club logo

laravel_microsoft_face_api's Introduction

LMFA

This Package Help You To Connect To Microsoft Face APi by Mohammad Najafian

Installation

install With Composer

 composer require ikosar/lmfa 

After :

 php artisan vendor:publish 

Config

Open lmfa.php in config folder in laravel root then you can enter you'r api_key in this file !

Usage

Normal Request (Return To You Face's info)

1 . First we need to do this ๐Ÿ’ฏ :

 $face = new CheckFace();

2 . We Set The Url :

if you want to customize the url , Do this ๐Ÿ’ฏ : (default : https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect)

  $face->setUrl($url);

3 . Also Set Request Type ( post , get , delete , put ) ๐Ÿ’ฏ :

To this step we set the request's type (only lowercase) :

  $face->setMethod("post");

4 . Set Headers ๐Ÿ’ฏ :

We Must to set headers to use Microsoft's Face APi (only lowercase) :

if you want to put APi_key in Headers or Parameters Use This :
  $face->getApiKey();
  $face->setHeaders(array(
     'Content-Type' => 'application/json',
     'Ocp-Apim-Subscription-Key' => $face->getApiKey(),
  ));

5 . Set Parameters ๐Ÿ’ฏ :

To this step we can set the Parameters :

  $face->setParameters(array(
      'returnFaceId' => 'true', // Recommended : True 
      'returnFaceLandmarks' => 'false', // Very information about face sizes
      'returnFaceAttributes' => 'age,gender,glasses,smile,noise,hair,accessories,emotion,makeup', // Your Requsted info
  ));

You can set these in the returnFaceAttributes in parameters Some Face Attributes : age , gender , glasses , smile , noise , hair , accessories , emotion , makeup ... //

6 . Set image ๐Ÿ’ฏ :

Then , we need to set image :-) : We must to put image URL in the array Like This.

  $image = array(
      'url' => 'http://cdn-tehran.wisgoon.com/dlir-s3/10531466806488528869.JPG',
  );
  $face->setBody($image,true); // Set Image
        

7 . Check Request to complete seted ๐Ÿ’ฏ :

We must to Check Before $face->send().

         $face->check();
         $face->send();        

8 . Get Face Information in JSON ๐Ÿ’ฏ :

Do This :

         $face->check();
         $result = $face->send();
         // Now JSON in $result  
         return $result;      

Finish And a Example:

       $image = array(
           'url' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Donald_Trump_August_19%2C_2015_%28cropped%29.jpg/245px-Donald_Trump_August_19%2C_2015_%28cropped%29.jpg',
       );
       $url = "http://..."; 
       $face = new CheckFace();
       $face->setUrl($url);
       $face->setImage($image);
       $face->setMethod("post");
       $face->setHeaders(array(
           'Content-Type' => 'application/json',
           'Ocp-Apim-Subscription-Key' => $face->getApiKey(),
       ));
       $face->setParameters(array(
           'returnFaceId' => 'true',
           'returnFaceLandmarks' => 'false',
           'returnFaceAttributes' => 'age,gender,glasses,smile,noise,hair,accessories,emotion,makeup',
       ));
       $face->setBody($image);
       $face->check();
       $result = $face->send();

##Licence This Project is under the MIT Licence ##Read About Microsoft Face Api ###Types of requests

https://westcentralus.dev.cognitive.microsoft.com/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236

laravel_microsoft_face_api's People

Contributors

loverdeveloper avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.