PHP code example of michaeljwright / aws-rekognition
1. Go to this page and download the library: Download michaeljwright/aws-rekognition library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
class LabelDetectionImage extends Model
{
/**
* Upload image to S3
*
* @param Illuminate\Http\UploadedFile $file
*
* @return string
*/
public function upload(UploadedFile $file) : string
{
$name = time() . $file->getClientOriginalName();
\Rekognition::uploadImageToS3(file_get_contents($file), null, self::BUCKET, $name);
return $name;
}
}
// FIRST call startLabelDetection to create a rekognition job
$config = [
'MinConfidence' => 80, //set confidence level for probability of correct labels
'Video' => [
'S3Object' => [
'Bucket' => 'YOUR_BUCKET_NAME',
'Name' => 'YOUR_VIDEO_FILE_NAME',
],
],
];
$job = \Rekognition::startLabelDetection($config); //start a job in rekognition for specific video file
dd($job['JobId']); //output job id so you can use it to get the labels
// THEN call getLabelDetection to get the labels for the specific job
$config = [
'JobId' => 'YOUR_JOB_ID',
'SortBy' => 'NAME', //set to whatever you want to sort the labels by
];
$job = \Rekognition::getLabelDetection($config);
dd($job['Labels']); //output the labels
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.