Integrate Amazon Rekongition service With PHP.

Ahh! If you have never heard AWS Rekognition service that no need to worry. Rekognition is a service provided by Amazon in the year 2016. Your program can recognize faces, you can compare face, find a specific face, find content from the image and videos.You can moderate the uploaded images/video according to your need. It doesn’t sound excited now but it is a very important and useful in many use case.
Suppose you have an e-commerce site, where seller uploads their product. The seller is free to upload any product seller can upload an image of Weapon, Drug and some content that you really don’t want to allow on your application. To remove them you have to moderate the products manually. Here AWS Rekognition comes in the picture, by using this service you can write your logic in code and moderate images and video. It helps you to understand the image and you can write your algorithm accordingly.

Listed things, that you will be required to integrate AWS Recognition.

1. AWS account. If you don’t have an account you can create.
2. It will be better if you will create an IAM user and provide the sufficient access permission to him.(Obtain key and secret )
3. You can get the key, login to aws console -> search IAM -> Users(from left panel)-> security Credential-> Create access key
4. AWS PHP SDK.

There are 33 methods exposed by AWS underrecognition service. You can use according to your need. Visit this link to get all methods.

How to implement this: This service support almost all language. For PHP, AWS has SDK. You need to download this SDK. Follow Command to get AWS PHP SDK.

Go to your project folder and run command.

curl -sS https://getcomposer.org/installer | php

Run composer command and install PHP SDK

php composer.phar require aws/aws-sdk-php

That’s it. Now you have PHP SDK with you. You can Use this SDK to integrate all service provided By Amazon.

You can use aws recognition service with S3 as well as local storage. so let’s start your IDE and Write first code:

require 'vendor/autoload.php';

use Aws\Rekognition\RekognitionClient;
$options = [
    'region' => 'us-west-2',
    'version' => '2016-06-27',
    'credentials' => array(
        'key' => 'Your key',
        'secret'  => 'Your Secret',
      )
    
    ];
$rekognition = new RekognitionClient($options);
$fp_image = fopen('test.jpg', 'r');
$image = fread($fp_image, filesize('test.jpg'));
fclose($fp_image);