Google-cloud-php: maxResults with ImageAnnotatorClient

Created on 8 May 2020  路  3Comments  路  Source: googleapis/google-cloud-php

I am trying to request more than 10 results using ImageAnnotatorClient and getLabelAnnotations but cannot find a solution, who can that be done?

Thanks!

vision question

Most helpful comment

Hi @joseflorido,

You can provide a custom value to max_results when configuring a feature:

use Google\Cloud\Vision\V1\Feature;
use Google\Cloud\Vision\V1\Feature\Type;
use Google\Cloud\Vision\V1\ImageAnnotatorClient;

$client = new ImageAnnotatorClient();

$res = $client->annotateImage(fopen(__DIR__ . '/image.jpg', 'r'), [
    new Feature([
        'type' => Type::LABEL_DETECTION,
        'max_results' => 20
    ])
]);

Please continue the conversation if you have any issues!

All 3 comments

Hi @joseflorido,

You can provide a custom value to max_results when configuring a feature:

use Google\Cloud\Vision\V1\Feature;
use Google\Cloud\Vision\V1\Feature\Type;
use Google\Cloud\Vision\V1\ImageAnnotatorClient;

$client = new ImageAnnotatorClient();

$res = $client->annotateImage(fopen(__DIR__ . '/image.jpg', 'r'), [
    new Feature([
        'type' => Type::LABEL_DETECTION,
        'max_results' => 20
    ])
]);

Please continue the conversation if you have any issues!

Thanks! This worked perfectly :)

Thank you so much, was wasting hours trying to get this right!

Was this page helpful?
0 / 5 - 0 ratings