114 lines
2.6 KiB
PHP
114 lines
2.6 KiB
PHP
<?php defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
|
|
include_once APPPATH.'/vendor/autoload.php';
|
|
use Aws\Rekognition\RekognitionClient;
|
|
//use Aws\AwsClient;
|
|
// use Aws\Exception\Rekognition;
|
|
use Aws\Exception\AwsException;
|
|
use Aws\CommandPool;
|
|
|
|
class AWS_REKONITION
|
|
{
|
|
private $RekognitionClient;
|
|
private $name = "TEST";
|
|
private $CI;
|
|
private $s3_properties;
|
|
public function __construct()
|
|
{
|
|
// Construct the parent class
|
|
//parent::__construct();
|
|
|
|
$this->CI =& get_instance();
|
|
$this->s3_properties = array('region'=>'ap-south-1','version'=>'latest','credentials' => array(
|
|
'key' =>'AKIAR7TQUR2JRVZMMGLC',
|
|
'secret' => 'G0tLAEkHaaWfoTzm0y7f3RyxBsAN6JDJjElHufKW'
|
|
));
|
|
$this->RekognitionClient = RekognitionClient::factory($this->s3_properties);
|
|
//print_r($this->s3_properties);
|
|
// echo "Called";
|
|
// $this->setCors('lender8');
|
|
// die();
|
|
|
|
}
|
|
|
|
public function yyy()
|
|
{
|
|
echo "listAllBuckets";
|
|
}
|
|
|
|
public function comparePhotos($url1,$url2)
|
|
{
|
|
// echo "listAllBuckets";
|
|
$result = null;
|
|
$sourceImg = 'will1.jpg';
|
|
$targetImg = 'will2.jpg';
|
|
//echo $url1;die();
|
|
|
|
try{
|
|
$result = $this->RekognitionClient->compareFaces([
|
|
// 'QualityFilter' => 'NONE|AUTO|LOW|MEDIUM|HIGH',
|
|
'QualityFilter' => 'NONE',
|
|
'SimilarityThreshold' => 0,
|
|
'SourceImage' => [ // REQUIRED
|
|
'Bytes' => file_get_contents($url1),
|
|
// 'S3Object' => [
|
|
// 'Bucket' => 'awsrekonition',
|
|
// 'Name' => $sourceImg,
|
|
// 'Version' => 'any',],
|
|
//
|
|
],
|
|
'TargetImage' => [ // REQUIRED
|
|
'Bytes' => file_get_contents($url2),
|
|
// 'S3Object' => [
|
|
// 'Bucket' => 'awsrekonition',
|
|
// 'Name' => $targetImg,
|
|
// 'Version' => 'any',
|
|
// ],
|
|
],
|
|
]);
|
|
|
|
} catch(AwsException $e){
|
|
print_r($e->getMessage());
|
|
//echo "ex";
|
|
// echo "\n"; .
|
|
die();
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
|
|
public function detectFaces($imgurl)
|
|
{
|
|
$result = null;
|
|
try
|
|
{
|
|
$result = $this->RekognitionClient->detectFaces([
|
|
'Attributes' => ["DEFAULT"],
|
|
'Image' => [ // REQUIRED
|
|
'Bytes' => file_get_contents($imgurl),
|
|
// 'S3Object' => [
|
|
// 'Bucket' => '<string>',
|
|
// 'Name' => '<string>',
|
|
// 'Version' => '<string>',
|
|
// ],
|
|
],
|
|
]);
|
|
}
|
|
catch(AwsException $e)
|
|
{
|
|
print_r($e->getMessage());
|
|
//echo "ex";
|
|
// echo "\n"; .
|
|
die();
|
|
}
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
?>
|