/** * Annotate a set of images. * * Example: * ``` * $images = []; * * $familyPhotoResource = fopen(__DIR__ .'/assets/family-photo.jpg', 'r'); * $images[] = $vision->image($familyPhotoResource, [ * 'FACE_DETECTION' * ]); * * $eiffelTowerResource = fopen(__DIR__ .'/assets/eiffel-tower.jpg', 'r'); * $images[] = $vision->image($eiffelTowerResource, [ * 'LANDMARK_DETECTION' * ]); * * $result = $vision->annotateBatch($images); * ``` * * @param Image[] $images An array consisting of instances of * {@see Google\Cloud\Vision\Image}. * @param array $options 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; }