Google\Cloud\Vision\VisionClient::annotateBatch PHP Method

annotateBatch() public method

Example: $images = []; $familyPhotoResource = fopen(__DIR__ .'/assets/family-photo.jpg', 'r'); $eiffelTowerResource = fopen(__DIR__ .'/assets/eiffel-tower.jpg', 'r'); $images[] = $vision->image($familyPhotoResource, [ 'FACE_DETECTION' ]); $images[] = $vision->image($eiffelTowerResource, [ 'LANDMARK_DETECTION' ]); $result = $vision->annotateBatch($images);
public annotateBatch ( array $images, array $options = [] ) : Annotation[]
$images array An array consisting of instances of {@see \Google\Cloud\Vision\Image}.
$options array Configuration Options
return Annotation[]
    public function annotateBatch(array $images, array $options = [])
    {
        $this->validateBatch($images, Image::class);
        $requests = [];
        foreach ($images as $image) {
            $requests[] = $image->requestObject();
        }
        $res = $this->connection->annotate(['requests' => $requests] + $options);
        $annotations = [];
        if (isset($res['responses'])) {
            foreach ($res['responses'] as $response) {
                $annotations[] = new Annotation($response);
            }
        }
        return $annotations;
    }