a
This commit is contained in:
parent
a2ab069e6e
commit
9a8108cc23
|
|
@ -210,6 +210,7 @@ class ControleurFichebeneficiaire extends Controleur
|
|||
$this->rediriger("Ficheadherent/".$_SESSION['idAdherent_C']);
|
||||
}
|
||||
|
||||
/*
|
||||
public function ebeneenregistrerface()
|
||||
{
|
||||
$_SESSION['messageFace'] = "";
|
||||
|
|
@ -293,5 +294,220 @@ class ControleurFichebeneficiaire extends Controleur
|
|||
unlink($chemin);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public function ebeneenregistrerface()
|
||||
{
|
||||
$_SESSION['messageFace'] = "";
|
||||
$compare_face = $_POST['compare_face'];
|
||||
$del_face = $_POST['del_face'];
|
||||
|
||||
if(isset($_POST['image_face']))
|
||||
{
|
||||
$_SESSION['okId_face'] = "-1";
|
||||
$_SESSION['okId'] = "-1";
|
||||
|
||||
$path = "Temp/";
|
||||
$extension = "jpeg";
|
||||
|
||||
$data = $_POST['image_face'];
|
||||
|
||||
$data = str_replace('data:image/jpeg;base64,', '', $data);
|
||||
|
||||
$data = base64_decode($data);
|
||||
|
||||
$username = $_SESSION['numeroBeneficiaire_C'];
|
||||
|
||||
$date = date('YmdHis');
|
||||
$file_name = "img_v_".$date.uniqid().".".$extension;
|
||||
$chemin = $path.$file_name;
|
||||
|
||||
file_put_contents($chemin, $data);
|
||||
|
||||
$rand = rand(1,1000000);
|
||||
$nomImage = $username."_".$rand.'.'. $extension;
|
||||
|
||||
if ($compare_face=="1")
|
||||
{
|
||||
if($del_face=="1")
|
||||
{
|
||||
$this->beneficiaire->init_traiterlaface('3');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->beneficiaire->init_traiterlaface('2');
|
||||
}
|
||||
|
||||
$arrgs = [
|
||||
'credentials' => [
|
||||
/*
|
||||
'key' => 'AKIARKWWQN5L3CY26JXS',
|
||||
'secret' => 'Mo613SKHaBKSH+IMPoMObafFiavN7kRqgp56gePX',
|
||||
*/
|
||||
/*
|
||||
'key' => 'AKIARKWWQN5LZYQYF5HJ',
|
||||
'secret' => '8dI1CAe+/vMsOJXs11Gv+nSQGMZiRCr0nIeEFS1H',
|
||||
*/
|
||||
'key' => 'AKIA2O2PTXQ7XN5OATO3',
|
||||
'secret' => 'Rzq5mKG80tqfePQYF6iFZ5AMCM/bY2l6i5IxxLzL',
|
||||
],
|
||||
'version' => 'latest',
|
||||
'region' => 'us-west-2'
|
||||
// 'region' => 'Oregon'
|
||||
// 'region' => 'eu-west-1'
|
||||
|
||||
];
|
||||
/*
|
||||
regions
|
||||
us-east-2
|
||||
us-east-1
|
||||
us-west-1
|
||||
us-west-2
|
||||
af-south-1
|
||||
ap-east-1
|
||||
ap-south-2
|
||||
ap-southeast-3
|
||||
ap-southeast-4
|
||||
ap-south-1
|
||||
ap-northeast-3
|
||||
ap-northeast-2
|
||||
ap-southeast-1
|
||||
ap-southeast-2
|
||||
ap-northeast-1
|
||||
ca-central-1
|
||||
eu-central-1
|
||||
eu-west-1
|
||||
eu-west-2
|
||||
eu-south-1
|
||||
eu-west-3
|
||||
eu-south-2
|
||||
eu-north-1
|
||||
eu-central-2
|
||||
me-south-1
|
||||
me-central-1
|
||||
sa-east-1
|
||||
us-gov-east-1
|
||||
us-gov-west-1
|
||||
*/
|
||||
|
||||
$client = new RekognitionClient($arrgs);
|
||||
|
||||
$sourceImage = $chemin;
|
||||
$targetImage = $_SESSION['dossierPhoto_C'].$_SESSION['dossierSociete'].'/Photos/'.$_SESSION['lienPhoto_C'];
|
||||
|
||||
try
|
||||
{
|
||||
$result = $client->compareFaces
|
||||
(
|
||||
[
|
||||
'SimilarityThreshold' => 80,
|
||||
'SourceImage' => [
|
||||
'Bytes' => file_get_contents($sourceImage)
|
||||
],
|
||||
'TargetImage' => [
|
||||
'Bytes' => file_get_contents($targetImage)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$faceMatches = count($result['FaceMatches']);
|
||||
if ($faceMatches==0)
|
||||
{
|
||||
$_SESSION['messageFace'] = "Les faces ne correspondent pas! / The faces do not match!";
|
||||
$this->beneficiaire->resultat_traitement_face($username, '0', $_SESSION['messageFace']);
|
||||
$this->genererVueAjax(array('messageFace' => $_SESSION['messageFace'], 'msgErreur' => $_SESSION['messageFace'], 'photo_succes' => "0"));
|
||||
}
|
||||
elseif ($del_face=="1")
|
||||
{
|
||||
$motif = $_POST['motif'];
|
||||
|
||||
$this->beneficiaire->resultat_traitement_face($username, '1', $motif);
|
||||
|
||||
|
||||
$idBeneficiaire = $_SESSION['idBeneficiaire_C'];
|
||||
$this->beneficiaire->supprimerPhoto($idBeneficiaire);
|
||||
$this->beneficiaire->unregisterface($username, $motif);
|
||||
$_SESSION['messageFace'] = "Face supprimée pour motif : $motif / Face removed for reason : $motif";
|
||||
|
||||
$this->genererVueAjax(array('messageFace' => $_SESSION['messageFace'], 'photo_succes' => "1"));
|
||||
$_SESSION['lienPhoto_C']="";
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->beneficiaire->resultat_traitement_face($username, '1', '');
|
||||
|
||||
$_SESSION['okId_face'] = "1";
|
||||
$_SESSION['messageFace'] = "Face confirmée! / Face confirmed!";
|
||||
$this->genererVueAjax(array('messageFace' => $_SESSION['messageFace'], 'msgErreur' => $_SESSION['messageFace'], 'photo_succes' => "1"));
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
// echo 'Message: ' .$e->getMessage();
|
||||
// exit();
|
||||
$msgErreur = $e->getMessage();
|
||||
$_SESSION['messageFace'] = "Un problème lors du traitement! / A problem during treatment!";
|
||||
|
||||
$this->beneficiaire->resultat_traitement_face($username, '9', $msgErreur);
|
||||
|
||||
$this->genererVueAjax(array('messageFace' => $_SESSION['messageFace'], 'msgErreur' => $_SESSION['messageFace'], 'photo_succes' => "0"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->beneficiaire->init_traiterlaface('1');
|
||||
|
||||
$cheminNew = $_SESSION['lienPhotoFace'] . $nomImage;
|
||||
|
||||
$_SESSION['okId_face'] = "1";
|
||||
|
||||
// réduction de la taille de l'immage
|
||||
$infosImg = getimagesize($chemin);
|
||||
$src = $chemin;
|
||||
$imgtype = image_type_to_mime_type($infosImg[2]);
|
||||
|
||||
switch ($imgtype)
|
||||
{
|
||||
case 'image/jpeg':
|
||||
$source_image = imagecreatefromjpeg($src);
|
||||
break;
|
||||
case 'image/jpg':
|
||||
$source_image = imagecreatefromjpeg($src);
|
||||
break;
|
||||
case 'image/png':
|
||||
$source_image = imagecreatefrompng($src);
|
||||
break;
|
||||
}
|
||||
|
||||
$width = imagesx($source_image);
|
||||
$desired_width = $width;
|
||||
if ($desired_width > $_SESSION['largeurPhoto'])
|
||||
{
|
||||
$desired_width = $_SESSION['largeurPhoto'];
|
||||
}
|
||||
$height = imagesy($source_image);
|
||||
|
||||
$desired_height = floor($height * ($desired_width / $width));
|
||||
|
||||
$virtual_image = imagecreatetruecolor($desired_width, $desired_height);
|
||||
|
||||
imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
|
||||
|
||||
if (imagejpeg($virtual_image, $cheminNew, -1))
|
||||
// if (imagejpeg($virtual_image, $cheminNew, 60))
|
||||
{
|
||||
$this->beneficiaire->registerface($username);
|
||||
|
||||
$idBeneficiaire = $_SESSION['idBeneficiaire_C'];
|
||||
$this->beneficiaire->changerPhoto($idBeneficiaire, $nomImage);
|
||||
|
||||
$_SESSION['messageFace'] = "Enrôlement effectué avec succès! / Enrollment completed successfully!!";
|
||||
$this->genererVueAjax(array('messageFace' => $_SESSION['messageFace'], 'msgErreur' => $_SESSION['messageFace'], 'photo_succes' => "1"));
|
||||
}
|
||||
$this->beneficiaire->resultat_traitement_face($username, '1', '');
|
||||
}
|
||||
unlink($chemin);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user