1. Go to this page and download the library: Download moe-mizrak/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/ */
// Path to the image file
$imagePath = __DIR__.'/resources/images/test_labels.jpg';
// Read the image file into bytes
$image = file_get_contents($imagePath);
// Create an ImageData object
$imageData = new ImageData(
bytes: $image,
);
// Create an S3ObjectData object
$s3Object = new S3ObjectData(
bucket: 'your_bucket_name',
name : 'your_image_name.jpg',
);
// Create an ImageData object by providing the S3 object
$imageData = new ImageData(
s3Object: $s3Object,
);
// Create a DetectLabelsData object
$detectLabelsData = new DetectLabelsData(
image: $imageData,
);
// Create a DetectLabelsData object with optional parameters
$detectLabelsData = new DetectLabelsData(
image : $imageData,
maxLabels : 10, // Maximum number of labels to return
minConfidence: 80.0, // Minimum confidence level for the labels to return
settings : new SettingsData(
generalLabels: new GeneralLabelsSettingsData(
labelCategoryExclusionFilters: ['Person Description'],
labelCategoryInclusionFilters: ['Animals and Pets'],
labelExclusionFilters : ['Man', 'Woman'],
labelInclusionFilters : ['Dog', 'Cat'],
),
),
);
// Create a CreateCollectionData object
$createCollectionData = new CreateCollectionData(
collectionId: 'your_collection_id', // Unique identifier for the collection
tags : ['tag_key' => 'tag_value'], // Optional tags for the collection (A set of tags key-value pairs that you want to attach to the collection)
);
// Create a DeleteCollectionData object
$deleteCollectionData = new DeleteCollectionData(
collectionId: 'your_collection_id', // Unique identifier for the collection
);
// Create a ListCollectionsData object.
$listCollectionsData = new ListCollectionsData(
maxResults: 10, // Maximum number of collection IDs to return - optional
nextToken : 'your_next_token', // Pagination token from the previous response - optional
);
// Create a UserData object
$createUserData = new UserData(
collectionId : 'your_collection_id', // The ID of an existing collection - /*
* Optional - Idempotent token used to identify the request to createUser.
* If you use the same token with multiple createUser requests, the same response is returned.
* Use clientRequestToken to prevent the same request from being processed more than once.
*/
clientRequestToken: 'your_client_request_token',
);
// Delete a user from a collection
$deleteUserData = new UserData(
collectionId : 'your_collection_id', // The ID of an existing collection - request to deleteUser.
* If you use the same token with multiple deleteUser requests, the same response is returned.
* Use clientRequestToken to prevent the same request from being processed more than once.
*/
clientRequestToken: 'your_client_request_token',
);
// Create a ListUsersData object
$listUsersData = new ListUsersData(
collectionId: 'your_collection_id', // The ID of an existing collection - s response - optional
);
// Path to the image file
$imagePath = __DIR__.'/resources/images/test_labels.jpg';
// Read the image file into bytes
$image = file_get_contents($imagePath);
// Create an ImageData object
$imageData = new ImageData(
bytes: $image,
);
// Create an S3ObjectData object
$s3Object = new S3ObjectData(
bucket: 'your_bucket_name',
name : 'your_image_name.jpg',
);
// Create an ImageData object by providing the S3 object
$imageData = new ImageData(
s3Object: $s3Object,
);
// Create an IndexFacesData object
$indexFacesData = new IndexFacesData(
collectionId : 'your_collection_id', // The ID of an existing collection - onal
qualityFilter : 'AUTO', // The quality filter for the face detection - optional
externalImageId : 'your_external_image_id', // ID you want to assign to all the faces detected in the image - optional
detectionAttributes: ['ALL'], // An array of facial attributes you want to be returned - optional
);
// Create an AssociateFacesData object
$associateFacesData = new AssociateFacesData(
collectionId : 'test_collection_id', // The id of an existing collection containing the userId - : 'test_user_id', // The userId to associate with the faceIds. (The id for the existing userId.) -
// Create a ListFacesData object
$listFacesData = new ListFacesData(
collectionId: 'your_collection_id', // The ID of an existing collection - face IDs to return information about - optional
maxResults : 10, // Maximum number of face IDs to return - optional
nextToken : 'your_next_token', // Pagination token from the previous response - optional
);
// Path to the image file
$imagePath = __DIR__.'/resources/images/test_labels.jpg';
// Read the image file into bytes
$image = file_get_contents($imagePath);
// Create an ImageData object
$imageData = new ImageData(
bytes: $image,
);
// Create an S3ObjectData object
$s3Object = new S3ObjectData(
bucket: 'your_bucket_name',
name : 'your_image_name.jpg',
);
// Create an ImageData object by providing the S3 object
$imageData = new ImageData(
s3Object: $s3Object,
);
// Create a SearchUsersByImageData object
$searchUsersByImageData = new SearchUsersByImageData(
collectionId : 'test_collection_id', // The id of an existing collection containing the userId - shold: 80.0, // Specifies the minimum confidence in the UserID match to return - optional
qualityFilter : 'MEDIUM', // A filter that specifies a quality bar for how much filtering is done to identify faces - optional
);