'); define('AWS_SECRET', ''); // Crear el cliente de AWS Rekognition function getRekognitionClient() { return new RekognitionClient([ 'region' => AWS_REGION, 'version' => 'latest', 'credentials' => [ 'key' => AWS_KEY, 'secret' => AWS_SECRET, ], ]); } // Detectar el rostro y extraer el vector facial function extractFaceVector($imagePath) { $rekognition = getRekognitionClient(); try { // Leer la imagen $imageData = file_get_contents($imagePath); // Enviar la imagen a AWS Rekognition $result = $rekognition->detectFaces([ 'Image' => ['Bytes' => $imageData], 'Attributes' => ['ALL'] // Devuelve landmarks y otros atributos ]); if (!empty($result['FaceDetails'])) { return $result['FaceDetails'][0]; // Devuelve los detalles del primer rostro detectado } else { throw new Exception('No se detectó ningún rostro en la imagen.'); } } catch (Exception $e) { throw new Exception('Error al procesar la imagen: ' . $e->getMessage()); } } // Ejemplo de uso try { $faceVector = extractFaceVector('ruta/a/tu/imagen.jpg'); echo "Vector facial: " . json_encode($faceVector); } catch (Exception $e) { echo "Error: " . $e->getMessage(); }